mdadm Cheat Sheet

Shashank Tiwari
Feb 22, 2018 · 1 min read

mdadm is a GNU/Linux utility used to manage and monitor software RAID devices. It is used in modern GNU/Linux distributions in place of older software RAID utilities such as raidtools2 or raidtools.


Glossary: md: multiple devices

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_liit_min=10000 : Set minimum raid rebuilding speed to 10000 kiB/s (default 1000)

sfdisk -d /dev/sda | sfdisk /dev/sdb: Copy partition table from sda to sdb


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!)

2Sync

News, updates & tutorials from 2Sync

Shashank Tiwari

Written by

2Sync

2Sync

News, updates & tutorials from 2Sync