Monday, January 19, 2009

Setting up s/w raid on gnu/linux

note to self

mdadm can be used to create raid volumes easily in the below way.

mknod -m 0640 /dev/mdX TYPE MAJOR MINOR
chgrp disk /dev/mdX
mdadm --create=/dev/mdX --level='RAID LEVEL' --raid-devices=n /dev/sdXX /dev/sdYY


RAID LEVEL can be any value from linear, raid0, 0, stripe, raid1, 1, mirror, raid4, 4, raid5, 5, raid6, 6, raid10, 10, multipath, mp, faulty.

Eg: Creating a RAID 0 with 2 physical devices /dev/sda1 and /dev/sdb1.

mknod -m 0640 /dev/md0 b 9 0
chgrp disk /dev/md0
mdadm --create='/dev/md0' --level=0 --raid-devices=2 /dev/sda1 /dev/sdb1


mknod is quite important, as otherwise mdadm will complain about non-existent device. Make sure to specify unused MAJOR and MINOR numbers when creating the (block)device. Refer to mknod man page for more info.

As usual, i keep forgetting this important step, and keep running in to trouble.

Very useful guides are here and here.

Some guides seem to suggest that the s/w raid configuration should be put on to a /etc/mdadm.conf, but i think this is no longer necessary.

From what i've gathered, the actual RAID configurations are kept in a superblock in member physical devices. The linux kernel identifies the and reads out that information from the physical devices( partitions ), at the boot-up, and they have to be of the type 'Linux raid autodetect' OR 'fd' for this to work properly.

No comments: