# RAID 1 in linux

I'd like to setup RAID 1 with two drives in linux. I don't have a hardware RAID controller and don't want to buy one, so what is the best software RAID option for linux?

Note: If it makes a difference, I'm running Gentoo.

-
A retagged your question 'software-raid' because you explicitly asked for that. –  wzzrd Aug 12 '10 at 20:47
since you'll be using mdadm you might want to consider using raid10,f2 which can work on 2 drives and should offer a read performance benefit. –  xenoterracide Aug 12 '10 at 22:13

Use mdadm, check the manpage. However, I will list one gotcha here. If you do this and really want reliability, you should make sure your master boot record is copied to both drives. By default it will likely only get copied to one drive. If that drive dies, you cannot boot from the other drive, even though all your data is safe.

To copy the mbr to both drives, use something like dd to copy the first 446 bytes of one drive to the other.

dd if=/dev/sda of=/dev/sdb bs=446 count=1


If you're building the RAID on top of the devices (/dev/sda) rather than on top of partions on the devices (/dev/sda1), then you probably shouldn't do what I am suggesting because you're writing data directly to the device underneath the md driver. At least, I've never tried it that way.

-
How do you ensure that the MBR is copied to both drives? do you have a link to instructions? –  Kris Aug 10 '10 at 21:02
Thanks for noting the possible problem. –  mouche Aug 11 '10 at 6:43
You might want to fix the 'md' typo in your snippet there. Also, any specific reason you mention the first 446 bytes, whereas I think to remember an mbr being 512 bytes? –  wzzrd Aug 12 '10 at 20:46
@wzzrd: fixed, thanks. While the whole 512 is properly called the MBR, the first 446 bytes contain everything BUT the partition table. Copying the partition table is sometimes not what people want You could make a RAID1 out of partions on different devices that aren't the same drive and would have different partition info. –  kbyrd Aug 12 '10 at 23:10

mdadm: array /dev/md1 started.