Raid How-To

How to setup and configure Raid devices

Scan Devices and Start Raid

This helps when not /dev/md0 has been found:
mdadm --assemble --scan
Check the device for errors:
e2fsck -f /dev/md2
Resize the file system and make it a little smaller than necessary:
resize2fs /dev/md2 25G
Resize the Raid device:
mdadm --grow /dev/md2 --size=33554432
Resize the file system to the maximum:
resize2fs /dev/md2
Check the file system again:
e2fsck -f /dev/md2
Remove one partition from the Raid:
mdadm /dev/md2 --fail /dev/sdb4
Stop the Raid array:
mdadm --stop /dev/md2
Resize the partitions using fdisk or gdisk. Run partprobe to refresh the partition table to the kernel. Add the partition to the raid array:
mdadm --zero-superblock /dev/sdb4
mdadm -a /dev/md2 /dev/sdb4
Watch the resync:
cat /proc/mdstat
Create a new raid 1:
mdadm --create --verbose /dev/md3 --level=mirror --raid-devices=2 /dev/sda5 /dev/sdb5

Delete Raid volume

umount /mnt/raidvolume
mdadm --stop /dev/md0
mdadm --zero-superblock /dev/sda4
# remove /mnt/raidvolume in /etc/fstab
# remove raidvolume in /etc/mdadm/mdadm.conf