Online resize a Linux RAID

Today we want to swap the 2 hard disks in a RAID 1 array for 2 bigger ones. Let’s avoid downtime and try to do this online.

I found a HowTo here:

And basics about RAID on Linux here:

These are the steps:

  1. Do the Backup
  2. Hotplug one of the 2 new disks (make sure that your SATA-Controller is in AHCI mode…….
  3. Partition it in a convenient way
  4. Add it to the RAID1 (as a 3rd disk)
  5. Go out, jump around on a slackline, play some badminton, throw a frisbee, go climbing…
  6. Remove one of the 2 old disks from the RAID and the computer
  7. Add the 2nd one of the new disks
  8. Wait again
  9. Throw out the remaining old disk (don’t forget to remove it from the RAID before
  10. Grow the RAID Device
  11. Grow the filesystem
  12. Make sure your computer can still boot afterwards – especially if you messed around with the /boot partition

Okay. Let’s look at some steps a bit closer:

Adding a third partition to a RAID1:

mdadm /dev/md0 --grow -n3
mdadm /dev/md0 --manage --add /dev/sdc3
watch cat /proc/mdstats

Slacking of

Removing the 1st one of the old disks

mdadm /dev/md0 --manage -f /dev/sdb3 -r /dev/sdb3

Add the 2nd new one, remove the 2nd old one, change RAID back to 2 drives

mdadm /dev/md0 --manage --add /dev/sdb3
watch cat /proc/mdstats
mdadm /dev/md0 --manage -f /dev/sda3 -r /dev/sda3
mdadm /dev/md0 --grow -n2

Grow MD and ReiserFS

mdadm --grow /dev/md0 -z max
resize_reiserfs /dev/md0
watch cat /proc/mdstat

The first step again takes quite a long time because of the resync of md0. Nevertheless I ran the resize_reiserfs command directly afterwards und it worked fine.

Tell Debian to look after your Grub and initramfs

As we use Debian Squeeze and use grub (“grub-pc”) I did the following

cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_back
/usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
dpkg-reconfigure grub-pc
dpkg-reconfigure grub-pc
dpkg-reconfigure initramfs-tools

I had to do the first 2 steps because the UID of the RAID did change (why?). 3rd and 4th step are the same but grub didn’t want to install itself into the new boot sectors in the first place because I also changed the /boot partition to now be a RAID1 on its own (and not to reside on one hd only). It can’t do any harm, so I propose it here as well. 5th is necessary because the mdadm.conf was changed.

In case you – like me – forgot the very last step, you are presented Debians initrams busybox rescue prompt. Here I did

mdadm /dev/md0 --assemble /dev/sda3 /dev/sdb3
...wait some time... (why that?)
mdadm -r /dev/md0 (why?)
mount -t reiserfs /dev/md0 /root

Now normal boot process jumped in.

And that’s it. It wouldn’t had been easier if we had used LVM on top of the RAID1 as we didn’t add disks but had to replace them. You don’t necessarily have to deal with 3 disks at a time but degrade the array before. But as I was dealing with old disks I didn’t have much trust in any of them.