May 19

Sometimes, code isn’t written to be especially portable and requires some hand editing to coax it to run on a new machine. A shortcut that I’m fond of using is to set off a perl script to search for every instance of $WORD inside of $FILE. So if I wanted to replace every instance of “jason” inside of all of the files that are “.html” with the word “dude” I would use the following.

perl -pi -e ‘s/jason/dude/g’ *.html

To make that caps insensitive, run it like so

perl -pi -e ‘s/jason/dude/gi’ *.html

May 12

I do a lot of work with MythTV and find it invaluable to run changes and latest builds inside a virtualization platform like VMWare or KVM. When using KVM through virt-manager in Ubuntu Hardy Heron, you don’t have an option to add a soundcard to a virtual machine. To get sound to work though, all you need to do is start the virtual machine from the command line and provide the -soundhw option like so.

kvm -m 1024 -soundhw all /home/jason/MythBuntu-1.img

Where -m is the amount of memory allocated to this vm.

May 8

the -k parameter lets you sort based on a key field instead of the first string. To use it to sort a batch of strings that look like this
-rw-rw-r-- 1 user prod 2406912 May 7 05:00 ./backups/daily/BaseClassAO-050708.tar
-rw-rw-r-- 1 user prod 1703424 May 7 05:00 ./backups/daily/BaseClassP-050708.tar

by the file size, use sort like so

sort -n -k5

telling sort to use the 5th field (as delimited by the space character) to sort on.

May 5

Just a random tidbit I thought I would post. I have a server at home acting as an iSCSI SAN. I ran a batch of hdparm tests against it, a single SATA drive in that array, a 5 disc SAS array in a compaq server and a 4 disc RAID 5 3Ware SATA array. here are the results. These are averages ran over 5 passes BTW on an otherwise silent machine. The CPU’s are all different speeds, but are all of the same class (dual core 800mhz FSB)

5 disc SAS array with 136g 10k drives

Timing cached reads: 13336 MB in 2.00 seconds = 6673.96 MB/sec
Timing buffered disk reads: 98 MB in 1.18 seconds = 83.31 MB/sec

4 disc Linux RAID 5 with 3Ware 9650SE and 500g 7200RPM drives

Timing cached reads: 6576 MB in 2.00 seconds = 3293.08 MB/sec
Timing buffered disk reads: 448 MB in 3.00 seconds = 149.20 MB/sec

Single 500g 7200 RPM SATA drive

Timing cached reads: 14220 MB in 2.00 seconds = 7119.78 MB/sec
Timing buffered disk reads: 198 MB in 3.02 seconds = 65.51 MB/sec

6 500g 7200 RPM SATA drives in a software RAID 5 array

Timing cached reads: 14364 MB in 2.00 seconds = 7191.86 MB/sec
Timing buffered disk reads: 852 MB in 3.00 seconds = 283.64 MB/sec

Now, for those of you that have storage experience, yes I didn’t mention chunk size or any of that fun stuff. But the point that I’m trying to get across is that, if you have the CPU cycles to spare, software RAID can be wicked fast.

Next Entries »