2009-08-11

resizing images for lazy people

One of my friends spent *five hours* yesterday resizing many pictures to 1280x1024. I told him to spend five *seconds* next time, running this script:

for i in *.JPG
do
convert -resize 1280x1024 $i 1280_$i
done

Five hours ? In five hours, anyone can learn to write little scripts.

Computers exist to automate things. Computers should do the repetitive work, not humans. Lazy humans take the time to learn how stuff works, so they can have fun while the computer does the work for them. I am a lazy human!

2009-08-04

Linux Software RAID and LVM

Wouter configured my nas with two raid1 setups and two lvm partitions like this:

md0 = sdb1 + sdd1
md1 = sda1 + sdc1

/ mounted on wolf/root on md1
swap mounted on wolf/swap on md0

What I wanted was raid5 with four disks, but without rebooting (and possibly bricking) the intel SS4000. Like this:

md0 = sda1 + sdb1 + sdc1 + sdd1
/ mounted on wolf/root on md0

Step 1: remove the swap partition:

swapoff /dev/wolf/swap
vi /etc/fstab
lvremove wolf/swap

Step 2: remove md0 from lvm and stop the raid1

vgreduce wolf /dev/md0
pvremove /dev/md0
mdadm --stop /dev/md0

Step 3: remove one disk from the remaining raid1

mdadm /dev/md1 --fail /dev/sdb1
mdadm /dev/md1 --remove /dev/sdb1

Step 4: build a degraded raid5 with four disks

mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 missing


Step 5: add the raid5 to lvm and move the root partition to it

pvcreate /dev/md0
vgextend wolf /dev/md0
pvmove -v /dev/md1 /dev/md0

Step 6: remove and stop md1

vgreduce wolf /dev/md1
pvremove /dev/md1
mdadm --stop /dev/md1

Step 7: complete the raid5 and update initrd

mdadm /dev/md0 --add /dev/sdd1
update-initramfs -k $(uname -r) -u

Debian on Intel SS4000

My little nas is much happier now running Debian Linux. Many thanks to Wouter for setting it up and making sure there is official Debian support for it.

Some screenshots:
wolf:~# grep Proc /proc/cpuinfo
Processor : XScale-80219 rev 0 (v5l)


wolf:~# uname -rm
2.6.30-1-iop32x armv5tel


wolf:~# fdisk -l /dev/md0

Disk /dev/md0: 2250.5 GB, 2250460889088 bytes
2 heads, 4 sectors/track, 549428928 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk identifier: 0x00000000

wolf:~# cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4]
md0 : active raid5 sdd1[3] sdc1[2] sdb1[1] sda1[0]
2197715712 blocks level 5, 64k chunk, algorithm 2 [4/4] [UUUU]