Upgrading a RAID-1 array…in only a week
750GB hard disks have been at the $/GB sweet spot for a while now, and now that they’ve hit $100, I decided to upgrade my home directory RAID-1 from 250GB to 750GB. I really dread these upgrades, as there’s always a chance you can really screw things up. So, for when I upgrade to 2TB or whatever in two years, I wrote up some notes.
In my configuration, sdb1 and sdc1 are the partitions currently part of my RAID-1 md0. sdd is one of the 750GB disks. I’m adding one 750GB disk at a time, because 1) I want at least two copies of my data to be available at all times and 2) I only have one free drive bay and don’t want disks dangling next to the machine for hours.
- Change the number of active devices in the array from two to three. This will cause any newly added drive to become active (i.e. actually write the array’s data onto the new drive)
mdadm -G /dev/md0 -n 3 - A little burn-in testing for the new disk
badblocks -svw -t random -p 2 /dev/sdd - Partition, not forgetting to set the partition type to 0xfd, Linux raid autodetect
- Add the new drive as a spare to the existing array
mdadm /dev/md0 --add /dev/sdd1 - Once recovery is done (check `mdadm -D /dev/md0`), fail and remove one of the old disks from the array
mdadm /dev/md0 -f /dev/sdc1 -r /dev/sdc1 - Shred the removed drive
shred -v -n 2 -z /dev/sdc - (Physically) swap out the removed drive and replace it with the second new one
- Repeat steps 2-5 above for the second new disk. Hold off on the shredding, as this is going to be our backup
- Reset the number of active devices in the array to two
mdadm -G /dev/md0 -n 2 - Grow the array
sudo mdadm -G /dev/md0 --size=max - Let it resync, then unmount and resize the filesystem
umount /home
resize_reiserfs /dev/md0
mount /home
- Finally, if everything seems okay, shred that second old disk
shred -v -n 2 -z /dev/sdb
…and we’re done! The one annoying thing is that with testing and a couple of resyncs, you end up with loads of down time between really short and simple tasks. So it’s possible (and I speak from experience) to stretch this weekend project out over a whole week.