In preparation for building my vmware environment I created a linux software raid array for my iscsi SAN which is used to host my guest vm’s.  This is a basic guide on how to create and manage linux software raid arrays. Old hardware is really cheap these days plus I always have a few spares lying around, here’s a picture of the hardware I have running my raid arrays/SAN.

Create a new raid array:
sudo mdadm --create --verbose /dev/md2 --level=1 --raid-devices=2 /dev/sde /dev/sdf

Add raid config to mdadm config file so the array will be recognised after a reboot:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf

See the raid array status:
cat /proc/mdstat
mdadm --detail /dev/md2

Monitor the status of an array rebuild:
watch cat /proc/mdstat

Only a failed drive can be removed from an array:
mdadm --fail /dev/md2 /dev/sdf

Remove the failed drive:
mdadm --remove /dev/md2 /dev/sdf

Convert a 2 drive RAID1 array into a degraded RAID5 array:
mdadm --grow /dev/md2 --level=5

Add a new drive to the array:
mdadm --add /dev/md2 /dev/sdg
Then we need to grow the array to get a clean state for the array:
mdadm --grow /dev/md2 --raid-devices=3

Add online hot spares:
mdadm --add /dev/md2 /dev/sd[hi]

Stop the array:
mdadm --stop /dev/md2

Delete the array:
mdadm --remove /dev/md2
sudo nano /etc/mdadm/mdadm.conf

Delete the superblocks from the individual drives:
mdadm --zero-superblock /dev/sd[efghi]

Detecting an array that failed to start:
mdadm --assemble --scan

No Comment.

Add Your Comment