mdadm (multiple device administration) — Software RAID configuration and management
Linux / File and disk management / mdadm.html
A tool for creating, growing and monitoring software RAID arrays with the Linux md driver.
Basic Information
| Command Name | mdadm (multiple device administration) |
|---|---|
| One-line Introduction | A tool for creating, growing and monitoring software RAID arrays with the Linux md driver. |
| Provided by | mdadm (distribution package) |
| Official Documentation | https://man7.org/linux/man-pages/man8/mdadm.8.html |
| Supported Operating Systems | Linux |
| Installation Status | Requires the mdadm package |
| Category | Linux file and disk management (tags: RAID, mdadm, mirroring, disk, recovery) |
What is this command?
mdadm combines several block devices into RAID 0, 1, 5, 6 or 10 arrays. Array status appears in /proc/mdstat, and mirrors or parity keep data available when one disk fails.
Array metadata is stored in /etc/mdadm/mdadm.conf so it can be assembled at boot. After replacing a disk, use --add and --grow to rebuild and expand.
What problems does it solve?
- You want to combine several disks into one volume
- You need a mirror that survives a disk failure
- You are replacing a failed disk and rebuilding
- You need array status and rebuild progress
Key features
Create an array
--create builds an array from a level and a device list.
- When to use: You are building a new RAID set
- What you get: An array device such as /dev/md0
- Limitations: Existing data on the devices is erased.
Monitor status
--detail and /proc/mdstat show members and health.
- When to use: During routine checks or incident response
- What you get: Per-device state and rebuild progress
- Limitations: Without a monitoring daemon you get no alerts.
Replace and grow
Mark a disk failed, remove it, add the new one, then grow if needed.
- When to use: Replacing a failed disk or adding capacity
- What you get: A rebuilt array with more capacity
- Limitations: Performance drops significantly during a rebuild.
Installation and usage
Check whether it is installed
mdadm --version
sudo apt install mdadm # Debian/Ubuntu sudo dnf install mdadm # Fedora
Real-world examples
Create a RAID 1 mirror
Combine two devices into a mirrored array.
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
Check status
Show array details and kernel status.
sudo mdadm --detail /dev/md0
cat /proc/mdstat
Save configuration
Record the array so it is assembled automatically at boot.
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u