====== RAID ======
===== Create new RAID =====
==== dev nodes: ====
If you built raid into the kernel as modules
modprobe raid5
Create some nodes
mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2
==== create: ====
RAID0
mdadm --create --level=0 --chunk=4 --raid-devices=2 /dev/md0 /dev/hde2 /dev/hdg2
mdadm --create --level=0 --chunk=4 --raid-devices=2 /dev/md1 /dev/hde3 /dev/hdg3
RAID1
mdadm --create --level=1 --chunk=32 --raid-devices=2 /dev/md0 /dev/sda3 /dev/sdb3
RAID5
mdadm --create --level=5 --chunk=32 --raid-devices=3 /dev/md0 /dev/sdc2 /dev/sdd2 /dev/sde2
mdadm --create --level=5 --chunk=64 --raid-devices=3 /dev/md1 /dev/sdc3 /dev/sdd3 /dev/sde3
Stop a raid build: mdadm -S /dev/md1
Watch the raid being built: watch -n 10 cat /proc/mdstat
===== Reassemble RAID =====
mdadm --assemble /dev/md0 /dev/sda3 /dev/sdb3
===== Take a disk offline =====
===== Build a raid from scratch =====
modprobe raid5
# mknod /dev/md0 b 9 0 <- not sure needed now, mdadm might create it
fdisk /dev/sdb g enter, n enter 1 enter enter enter, t raid, w enter
fdisk /dev/sdc g enter, n enter 1 enter enter enter, t raid, w enter
fdisk /dev/sdd g enter, n enter 1 enter enter enter, t raid, w enter
mdadm --create --level=5 --chunk=64 --raid-devices=4 /dev/md0 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
===== Rebuild array with replaced disk =====
mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1 --add /dev/sdf1
--- Add as hot spare, then replace/with, then remove failed
mdadm /dev/md0 --add /dev/sdb1
mdadm /dev/md0 --detail
mdadm /dev/md0 --replace /dev/sdf1 --with /dev/sdb1
mdadm /dev/md0 --remove /dev/sdf1
mdadm --detail --scan > /etc/mdadm/mdadm.conf
update-initramfs
===== Add a new disk to a existing raid =====
mdadm --manage /dev/md0 --add /dev/hdb1
===== Rename a array =====
mdadm --stop /dev/md0
mdadm -A /dev/md6 -m0 --update=super-minor /dev/sda5 /dev/sdb5
===== Boot auto assemble =====
''If you have more then 4 raids then you need to pass the others to the kernel as it will not find these automatically.''
title Gentoo Linux 2.6.16-gentoo-r7.1
root (hd0,0)
kernel /kernel-2.6.16-gentoo-r7.1 root=/dev/md4 md=4,/dev/md0,/dev/md1 md=5,/dev/md2,/dev/md3