Preparing a disk for software RAID1

Posted in May 2012 by under sysadmin

In order to prepare a new drive for use in RAID1, we need to ensure the new disk partition layout is the same as the existing disk partition layout.

You can use a number of tools to do this but the easiest way is to use sfdisk.

To create a partition layout exactly the same as the existing disk. Use

sfdisk -d /dev/sda | sfdisk /dev/sdb
            

If you get told by sfdisk that "sfdisk: I don't like these partitions - nothing changed", it is because the installer for some modern distributions, including CentOS6, create partitions that are the size you specify and do not necessarily end at cylinder boundaries.

This shouldn't cause any problems during day to day running but does when manually partitioning disks.

Fortunately we can force sfdisk to do this, like this

sfdisk -d /dev/sda | sfdisk --force /dev/sdb
            

Now the disk partitions are identical, you can add the new drive to the existing RAID1 device.

UPDATE - 26 December 2012

I received an email from John Moras who unfortunately had a disk failure this Christmas. He has written up a step by step guide on recoving RAID1 based on my notes that you can read on his personal blog.