md: multiple devices https://linux.die.net/man/8/mdadm http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch26_:_Linux_Software_RAID https://raid.wiki.kernel.org/index.php/RAID_setup Grow, shrink or otherwise reshape an array in some way. Currently supported growth options including changing the active size of component devices in RAID level 1/4/5/6 and changing the number of active devices in RAID1. https://raid.wiki.kernel.org/index.php/Growing ------------ Verify, check RAID array ------------------------- cat /proc/mdstat or mdadm --detail /dev/md0 monitor status -------------- watch cat /proc/mdstat Create a new RAID array ----------------------- Create (mdadm --create) is used to create a new array: RAID1 with 2 drives mdadm --create --verbose /dev/md0 --level=1 /dev/sda1 /dev/sdb2 or using the compact notation: mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[ab]1 If you get “mdadm: no raid-devices specified” try adding the raid-devices option: mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb2 RAID5 with 5 Drives: mdadm --create --verbose /dev/md0 --level=5 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 RAID6 with 4 Drives and 1 spare: mdadm --create --verbose /dev/md0 --level=6 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /etc/mdadm.conf --------------- /etc/mdadm.conf or /etc/mdadm/mdadm.conf (on debian) is the main configuration file for mdadm. After we create our RAID arrays we add them to this file using: mdadm --detail --scan >> /etc/mdadm.conf or on debian mdadm --detail --scan >> /etc/mdadm/mdadm.conf Remove a disk from an array ---------------------------- We can’t remove a disk directly from the array, unless it is failed, so we first have to fail it (if the drive it is failed this is normally already in failed state and this step is not needed): mdadm --fail /dev/md0 /dev/sda1 and now we can remove it: mdadm --remove /dev/md0 /dev/sda1 This can be done in a single step using: mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1 Add a disk to an existing array ------------------------------- mdadm --add /dev/md0 /dev/sdb1 (only added as a spare) mdadm --grow /dev/md0 -n [new number of active disks -- spares] (grow the size of the array) When new disks are added, existing raid partitions can be grown to use the new disks. After the new disk was partitioned, the RAID level 1/4/5/6 array can be grown for example using this command (assuming that before growing it contains three drives): mdadm --add /dev/md1 /dev/sdb3 mdadm --grow --raid-devices=4 /dev/md1 Stop and delete a RAID array ----------------------------- If we want to completely remove a raid array we have to stop if first and then remove it: mdadm --stop /dev/md0 mdadm --remove /dev/md0 and finally we can even delete the superblock from the individual drives: mdadm --zero-superblock /dev/sda Finally in using RAID1 arrays, where we create identical partitions on both drives this can be useful to copy the partitions from sda to sdb: sfdisk -d /dev/sda | sfdisk /dev/sdb (this will dump the partition table of sda, removing completely the existing partitions on sdb, so be sure you want this before running this command, as it will not warn you at all). # # # cat /proc/mdstat show status of all raids mdadm --detail /dev/md0 detailed status of raid md0 mdadm --create /dev/md0 -n2 -l1 /dev/sda1 /dev/sdb1 new raid /dev/md0 with 2 disks, raid level 1 on /dev/sda1 and /dev/sda2 mdadm --fail /dev/md0 /dev/sda1 ; mdadm --remove /dev/md0 /dev/sda1 remove /dev/sda1 from /dev/md0 mdadm --add /dev/md0 /dev/sda1 add /dev/sda1 to /dev/md0 mdadm --grow /dev/md0 -n3 use 3 disks in raid /dev/md0 (e.g. add an additional disk, so a damaged drive can be removed later-on) mdadm --assemble /dev/md0 Assemble /dev/md0 (e.g. when running live system) mdadm --detail --scan >> /etc/mdadm/mdadm.conf Update list of arrays in /etc/mdadm/mdadm.conf ; you should remove old list by hand first! mdadm --examine /dev/sda1 What is this disk / partition? sysctl -w dev.raid.speed_limit_min=10000 Set minimum raid rebuilding speed to 10000 kiB/s (default 1000) To boot a machine even with a degraded array, modify /etc/initramfs-tools/conf.d/mdadm and run update-initramfs -c -kall (Use with caution!)