Linux – How to add software RAID-1 to an existing system

linuxmdadmraidubuntu-14.04

I couldn't find any tutorials for converting a non-RAID Linux system (Ubuntu 14.04 in my case) into a disk-level RAID-1 system after installing a second disk (/dev/sdb)

Is the following correct?

sgdisk --replicate=/dev/sdb /dev/sda # copy partition table
sgdisk -G /dev/sdb # randomize IDs
mdadm --create /dev/md --level=mirror --raid-devices=2 /dev/sda missing
mdadm /dev/md -a /dev/sdb
echo "DEVICE /dev/sda /dev/sdb" >> /etc/mdadm/mdadm.conf # is this needed?
mdadm --detail --scan >> /etc/mdadm/mdadm.conf  
dpkg-reconfigure mdadm

Do I need to do anything about grub, or will it be copied together with the rest of /dev/sda?

(Extra: I found a tutorial here: http://feeding.cloud.geek.nz/posts/setting-up-raid-on-existing/, but it advocates copying data manually from a live partition, which seems wrong (data race), and also it applies mdadm at the partition level, while I want to mirror the whole disk)

Best Answer

I would very highly not recommend doing what you're suggesting - you'll have a very non-standard configuration that puts you in "if you've gotten this far you should know what you are going" territory, decreasing the chances of support for this down the track.

The approach that will get you a sane configuration will be:

  1. take backups
  2. reinstall system
  3. restore from backup

You can run RAID in whole-of-disk mode, but you'll have to make sure that any replacement disks are exactly the same size (or bigger); plus you'll have to make sure that your BIOS doesn't try to interpret the start of the disk as a partition table. See this superuser question for some of the pitfalls.

Related Topic