Smokes your problems, coughs fresh air.

Author: halfgaar (Page 24 of 26)

Halfgaar is Wiebe. Wiebe is a contributing author on this weblog. He also has a lot of stuff (such as long, in-depth articles) on his personal website.

Wiebe's day job is as a senior software developer and system administrator at YTEC.

In his free time, he built the free, open-source FlashMQ software. Together with Jeroen and Rowan, he is now building a managed MQTT hosting business around his open masterpiece.

Really enabling portage compile cache

I always thought I had portage’s compile cache enabled, but upon recent inspection, it appears that I didn’t. What was missing, was the package dev-util/ccache. I also increased the cache size to 2 GB, as per the Gentoo documentation.

I noticed this because recently, portage started saying this:

!!! Directory does not exist: '/usr/lib/ccache/bin'
!!! Disabled FEATURES='ccache'

Correcting Spamassassins stale mirror configuration

My spamassassin updates daily by running sa-update. Recently, I’ve been getting failure notices that mirror spamassassin.kluge.net was no longer available. This was because of a known bug, apparantly. So, I deleted the MIRROR.BY file and ran sa-update again.

This caused problem number two: GPG key verification failed. This was also a known issue, so I had to do:

wget http://spamassassin.apache.org/updates/GPG.KEY
sa-update --import GPG.KEY

And then everything was OK again.

Adding locales in Ubuntu

I wanted the dates on my Kubuntu system to be shown as Dutch dates. Therefore, I needed to add a locale. The place to do it is in /var/lib/locales/supported.d/local. It now contains this:

en_US.UTF-8 UTF-8
nl_NL.UTF-8 UTF-8

Then run locale-gen to generate the locales.

Set the following environment vars (in profile or something) to let everything behave properly:

export LANG="nl_NL.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_COLLATE="C"

I don’t know anymore why I chose this specific configuration. I guess this means that everything, from thousand and decimal separators to dates is Dutch, and messages are English. I don’t know, however, why the collate is C. I vaguely remember something about it otherwise not including some characters in the sorting, causing weird sorting in words with dashes and such.

Increasing (encrypted) disk image size with dd

When you have a raw disk image file, you may need to increase its size at some point. With dd, you can do this:

dd conv=notrunc oflag=append if=/dev/zero of=backups bs=1M count=1024

This will add 1GB of zero data to the image file ‘backups’. You can then use resize2fs on it to increase the file system size (that is, if you use ext2/3/4):

e2fsck (-f) backups
resize2fs backups

However, if the disk image is a volume encrypted with cryptsetup + luks, first open it:

losetup /dev/loop/0 backups
cryptsetup luksOpen /dev/loop/0 encrypted-backups

Then resize the encrypted volume:

cryptsetup resize encrypted-backups
e2fsck (-f) /dev/mapper/encrypted-backups
resize2fs /dev/mapper/encrypted-backups

And I know, I still have to add LVMs to my set of skills…

Encoding a motion jpg video produced by a canon A430 to xvid

I sometimes need to encode video recorded with my Canon A430 digital camera to a format that works, so I want to convert it to xvid. The sound stream included is so weird (PCM at 11024 Hz, no, not 11025 Hz) that encoding with sound always results in async video/audio. Therefore I don’t encode sound. I use this:

mencoder video.avi -o video.xvid.avi -ffourcc XVID -ovc lavc -lavcopts vcodec=libxvid:mbd=2:v4mv:vqscale=4:aspect=4/3 -nosound

The vqscale can be made 3 for slightly higher quality, but with the crap quality it starts with, there is not much use.

Silent change in URLs of Ruby on Rails svn repository

I don’t know why, but everything associated with Ruby on Rails seems to change all the time, without notice, or (in the case of URLs) without redirect.

We used http://svn.rubyonrails.org/rails for our svn:external deployment of rails 1.2.6. But that suddenly stopped working. The Ruby on Rails weblog doesn’t contain any information on it (that I can find), going to svn.rubyonrails.org with my web browser yielded just the front page of the weblog and Googling didn’t help much. That is, until I accidentally found http://dev.rubyonrails.org/svn/rails.

So, I changed the svn:externals from “rails http://svn.rubyonrails.org/rails/tags/rel_1-2-6/” to “rails http://dev.rubyonrails.org/svn/rails/tags/rel_1-2-6/” and now it works again.

Creating a custom device node for specific hardware with udev

Sometimes you want specific hardware to get a specific device name in /dev. For example, I want my backup hard disk to have the same device name. I can’t automate anything if sometimes the device is sdc and other times it’s sdd.

To do that, you need to create a specific udev rule. I put this one in 10-local for my backup hard disk:

BUS=="scsi", KERNEL=="sd*", SYSFS{vendor}=="ST325062", NAME="usbhd%n"

Everything with dual equal sign it uses as match, and I assign a different name at the end with a single equals sign.

You can look up the specific attributes to match in “/sys/bus/scsi/devices/[devicenumber]/”. The file “vendor” contains the “ST325062” I match for. My internal drives have vendor ATA (for whatever reason), so there will never be a conflict.

After having made the rule, you can use “udevstart”, “udevtrigger”, “udevadm trigger” or whatever your distro uses to test it.

Edit, this has been deprecated. Now it’s:

SUBSYSTEM=="scsi", KERNEL=="sd*", ATTR{vendor}=="ST325062", NAME="usbhd%n"

Clonezilla as disk imager

I was always using partimage to make backups of the hard disks of workstations. When trying to restore one the other day, it just started giving CRC errors. After recreating the image and running a simulated restore, it gave CRC errors again. So, apparently, it’s not incidental. It must be due to the experimental NTFS support. So, I set out to find a new tool. And that’s how I found Clonezilla, which gives me a very good first impression.

Clonezilla is a wizard-style live CD. It uses several tools, including partimage. However, it prefers ntfsclone over partimage at it’s default settings. Besides its handy interface, it has some very cool features: It doesn’t only create the image, but also some other useful files, such as the MBR (first 512 bytes of a disk), the data between the MBR and the first partition, an sfdisk dump of the partition table and some files with info about the PCI devices and other hardware. All this ensures you can properly restore the image.

Also, it has support for leaving out the page- and hybernation files on Windows systems, which can save you several gigabytes of space. And, to top it off, it calls “sync” when everything is done. They must have read my backup article :).

And the last major thing: it allows you to remove the CD when rebooting or halting. It is so incredibly annoying when live CD’s don’t do that…

A must have live CD for any sysadmin, I would say.

Ultra Cheap dual Eizo monitor setup

As people who know me know, I passionately hate TFT screens, for reasons not relevant right now. It is unfortunate that marketing has caused the superior type of monitor, the CRT, to disappear.

But, there are good sides to it, though. I was walking through a second-hand store the other day and saw and Eizo T961 21″ Flatscreen. Most people wouldn’t want such a thing because of its size, and that was probably the reason it was only 15 euros. I was curious as to its quality, so I bought it.

Aside from a few minor things and after recalibration (which these Eizo CRTs make possible through the on-screen menu), the image quality was very nice. In some respects even better than my own 19″ T766 (but granted, that one was better with it’s old picture tube, which was replaced when I had it repaired).

In any case, I now have a dual Eizo CRT setup, which cost me practically nothing.

Dual Eizo monitor setup

Dual Eizo monitor setup

Edit: I use this image for calibration:

monitor-calibrate

Finding and deleting duplicate files

I needed to remove all duplicates In a collection of hundreds of thousands of files. I first came across this, which generates a script with commented out rm statements, but I quickly found another tool, fdupes, which made life a lot easier for me; I didn’t want manual control. I just wanted to have all the duplicates deleted, except one of them.

Fdupes has a feature to omit the first file in a set. So I made a simple script which found all duplicates, omit the first of the set, and put rm statements before the file names:

#!/bin/sh
OUTF='rm-dups.sh'
 
echo "#!/bin/sh" > $OUTF
fdupes -r -f . |sed -r 's/(.+)/rm \1/' >> $OUTF
chmod +x $OUTF

This script in turn generates another script, which can then be executed, but not before checking if it is actually correct, of course.

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑