Saturday, 2 July 2011

Replacing a hard drive on my QNAP debian install

My replacement drive arrived - time to add it to the existing raid. From my exisiting hard drive I get the following output:

Partition Table: gpt
Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  3000MB  3000MB               Root  raid
 2      3000MB  4000MB  1000MB               Var   raid
 3      4000MB  4512MB  512MB                Swap  raid
 4      4512MB  2000GB  1996GB               Data  raid
Here are the commands I issued in parted:
mktable gpt
mkpart Root 17.4kB 3000MB
toggle 1 raid true
mkpart Var 3000MB 4000MB
toggle 2 raid true
mkpart Swap 4000MB 4512MB
toggle 3 raid true
mkpart Data 4512MB 100%
toggle 4 raid true
To add the partitions to the existing, degraded arrays you have to first drop the old drive and add the new one using mdadm. Double check which drive you are replacing and type the following:
mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1
mdadm --manage --add /dev/md0 /dev/sdb1
mdadm /dev/md1 --fail /dev/sdb2 --remove /dev/sdb2
mdadm --manage --add /dev/md1 /dev/sdb2
mdadm /dev/md2 --fail /dev/sdb3 --remove /dev/sdb3
mdadm --manage --add /dev/md2 /dev/sdb3
mdadm /dev/md3 --fail /dev/sdb4 --remove /dev/sdb4
mdadm --manage --add /dev/md3 /dev/sdb4
I found that for some reason the /dev/md2 (swap partition) didn't seem to be happy - so I totally deleted /dev/md2: and created a new one from scratch
swapoff /dev/md2
mdadm --stop /dev/md2
mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3
mkswap /dev/md2
swapon /dev/md2
I used the new UUID information to alter the /etc/fstab info to amke sure swap came on every reboot.

No comments:

Post a Comment