Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

3 Answers 3

up vote 9 down vote accepted

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.

share|improve this answer
    
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
1  
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
add comment

You can use mdadm to manage software raid on linux.

share|improve this answer
add comment

livecd ~ $ mdadm --create /dev/md1 --level=1 --raid-devices=2 --metadata=0.90 /dev/sda1 /dev/sdb1

mdadm: array /dev/md1 started.
share|improve this answer
4  
This doesn't add anything useful to the existing answers. Or maybe it does - why do you force a specific metadata version? –  Mat Feb 1 '12 at 10:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.