Wednesday, December 3, 2008

Create software RAID with mdadm

Here, I will briefly list the steps to create a software RAID5 with mdadm.

1) use "fdisk -l" to check the available hard drives. In my case, I will allocate 4 drives: /dev/sdb, to /dev/sde.
2) to create partitions on raid drives, "fdisk /dev/sdb"; "n->p->1" to create a new partition, /dev/sdb1, "t" to change partition type, use code "fd" to set it as Linux raid autodetect. Do the same for the rest drives.
3) to create the raid "mdadm --create /dev/md0 --chunk=64 --level=raid5 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1". And it will report that /dev/md0 is created and started. (note that it's md0, 0 as number zero, not letter o).
4) "cat /proc/mdstat" and wait for the reshaping process to complete. It will take hours, so don't wait, come back later. After this is done, continue the following.
5) to format the new device "mkfs.ext3 /dev/md0". It will also takes a little while to complete.
6) create a mount point and mount /dev/md0 there. You can also edit /etc/fstab to mount it automatically next time.
7) "mdadm --detail --scan > /etc/mdadm.conf" to save the raid configuration,
8) use "mdadm --detail /dev/md0" to check raid status. also "smartctl --all -d ata /dev/sdb" to check the SMART status of each hard drive.

No comments: