Easy Linux raid 1 to raid 5 in 5 steps without reboot

Migration from RAID1 the RAID5 turned out to be much easier than I thought 🙄 are broadly 5 simple steps a little waiting and 1 a beer for courage.

To me the system has created RAID array md0 involving 2 disk sda and sdb. I'll add to them the 3rd sdc to create the RAID5 3 disc. Generally this is for scientific purposes, the acrobatics of virtualka I have not yet tested in real environment, but don't expect dramas and the real time machine.

  1. Create the same file system layout as other drives us – sfdisk -d /dev/sdb | sfdisk /dev/sdc
  2. Build upon our current array of RAID5 – mdadm –grow /dev/md0 –level=5
  3. Add the new disk to the array – mdadm –manage /dev/md0 –add /dev/sdc . Here comes the thin point that the array is still going to be RAID1 and won't start sync because the new disc is spare
  4. The most important moment sdc becomes active and starts the synchronization – mdadm –grow /dev/md0 –raid-devices=3 . A good time to open the beer if not done 😉 stay in no case process!!!
  5. Once completed the synchronization stuck to resize the partition because the loss of space in 1/e RAID1 and RAID5 for n e 1-1/n

The big bonus is that you don't have a system restart or pulling and making additional arrays.

sfdisk -d /dev/sdb | sfdisk /dev/sdc
mdadm --grow /dev/md0 --level=5
mdadm --manage /dev/md0 --add /dev/sdc
mdadm --grow /dev/md0 --raid-devices=3
resize2fs /dev/md0

Good night 😛

leave a reply

Your email address will not be published. Required fields are marked *

anti SPAM *