Setting up a RAID matrix

I wanted to create a RAID1 matrix with only one drive initially. Then I wanted to add second drive to it. At first, I created a RAID1 matrix with one device. Mdadm complained, but I forced.

“It’s probably a mistake” said mdadm. Well, it was one. You can’t change number of devices in a RAID matrix. The proper way to do it was to create a matrix with two devices, but one of them needs to be specified as missing. So you can start this matrix with one device only, put files there, and add the second device afterwards. So it would look like:

mdadm --create -a --level=1 --raid-devices=2 \\
/dev/md0 /dev/hda1 missing

The device is started, you can create a file system, move all files there, and once the second device is ready, you can:

mdadm --manage --add /dev/md0 /dev/hdc1

It will take a little while until the matrix is synchronized. And you don’t want to reboot until the sync is done, or else you’ll have to add the device again. You can check the synchronization state by cat /proc/mdstat


Author: automatthias

You won't believe what a skeptic I am.