Main Contents

Software RAID in Linux

April 25, 2008

Create the device special files:

mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2

Partition the disks, set type to fd (Linux raid autodetect). Set partition sizes the same.
Create the arrays:

mdadm --create -v /dev/md1 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm --create -v /dev/md2 --level=5 --raid-devices=3 /dev/sda2 /dev/sdb2 /dev/sdc2

Check array status:

cat /proc/mdstat

Now use /dev/md device instead of /dev/sd device:

mke2fs -j /dev/md1
mount /dev/md1 /boot

For performance, no need to put swap on raid. Use mount option pri=1 to stripe swap.
If /boot is mirrored, setup grub on both disks so you can boot from either:

root (hd0,0)
setup (hd0)
root (hd1,0)
setup (hd1)

Install and configure mdadm. In /etc/mdadm.conf:

DEVICE /dev/sd[ab]1
DEVICE /dev/sd[abc]2

Add ARRAY option to /etc/mdadm.conf:

mdadm --detail --scan >> /etc/mdadm.conf

Test with:

mdadm -Fs1t

Run regular checks with this in your crontab:

echo check >> /sys/block/mdX/md/sync_action

Enable write intent bitmaps to reduce reconstruction time; only out-of-sync data will be synced. Careful, this impacts performance negatively:

mdadm -G /dev/md0 -binternal

Modify grub.conf to use the raid root:

kernel /kernel-2.6.22 root=/dev/md2

Filed under: Linux | Comments Off on Software RAID in Linux

Sorry, the comment form is closed at this time.