Linux Software RAID

One of my drives in my RAID died, so I went and bought a 3TB drive for a replacement. The RAID is only 1T, so I’ll use the rest of it for something else.

It drives me nuts that every site out there describes in great detail how to do different things. Anyone can read the man page, or issue the parted “help mkpart” for example; but what I usually look for is a quick start.  So, here’s a quick rundown on how I re-set up the RAID drive. At the bottom is a full rundown on how I think I originally setup the RAID, but don’t quote me on it. 😀

We run through the basic use of parted and mdadm.

Create and Add RAID Mirror

parted /dev/sdb
mklabel gpt
mkpart primary 1 1T
set 1 raid on
align-check
mdadm --manage /dev/md10 -a /dev/sdb1
cat /proc/mdstat

 

RAID Setup

# create a mirror with two devices
mdadm --create /dev/md10 --force --level=1 --raid-devices=2 /dev/sdb1 /dev/sde1

That’s really all there is to it. From there, you can just use /dev/md10 as you would any other drive or partition. You can use it as a raw disk with partitions, or turn it into an encrypted volume, or a physical volume for LVM, etc.

 

RAID Cheat Cheat

# create mirror with only one device
mdadm --create /dev/md10 --force --level=1 --raid-devices=1 /dev/sdb3

# create a mirror with two devices
mdadm --create /dev/md10 --force --level=1 --raid-devices=2 /dev/sdb3 /dev/sdd1

# grow and add a mirror instantly.
mdadm --grow /dev/md10 --raid-devices=2 -a /dev/sdd1

# fail and remove a device
mdadm --manage /dev/md10 --fail /dev/sdd1
mdadm --manage /dev/md10 -r /dev/sdd1

# turn a mirror with one disk into a striped array.
mdadm --grow /dev/md10 --level=raid5
mdadm --grow /dev/md10 --raid-devices=2 -a /dev/sdd1