Growing RAID1 array with mdadm

Few days ago I replaced a broken disk in my home server's RAID1 array. So it now has two active disks again. But I started to think that why wouldn't I add one more, now that I have also one spare disk.

I guess it might have a minor performance penalty, and it increases energy consumption slightly. But on the other hand, I don't have to hurry when a disk dies. Maintenance strategy can be summed up as follows:

Array status Task
3/3 Look for a spare disk.
2/3 Replace the broken disk.
1/3 Backup and replace broken disks, fast!

And even if I miss one phase, I won't lose data. I might not be at home when a disk dies, and if I'm having a long vacation, it's possible that also another disk dies while I'm away. But it's highly unlikely that all three disks die before I manage to replace disks.

First I copied partitions from an active disk to the new disk:

sudo sh -c 'sfdisk -d /dev/sda | sfdisk /dev/sdc'

Then I added the new disk to the array:

sudo mdadm --manage /dev/md0 --add /dev/sdc1

Because the number of active disks in the array was previously two, the newly added disk got added as a spare disk. To activate it and start synchronizing data, I increased the size of the array by one:

sudo mdadm --grow --raid-devices=3 /dev/md0

Finally, I installed grub to make the disk bootable:

sudo grub-install /dev/sdc

Comments

Comments powered by Disqus