All systems operational

Pay with Bitcoin, Monero, USDT & 11 more · email-only sign-up

Storage & RAID

Software RAID with mdadm: check, replace, rebuild

Read /proc/mdstat, spot a failed disk, and rebuild the mirror after we swap the drive.

7 min readReviewed 25 September 2026

About this guideGuide

Reading time
7 minutes
Written for
Debian 12 and 13, Ubuntu 24.04 and 26.04RHEL-family differences flagged in the text
Last reviewed
25 September 2026

Check the arrays

$ cat /proc/mdstat
$ mdadm --detail /dev/md2

A healthy RAID 1 shows [2/2] [UU]. [2/1] [U_] means one member is missing or failed.

Identify the failed drive

$ mdadm --detail /dev/md2 | grep -E 'faulty|removed'
$ nvme list                         # NVMe: model and serial number
$ smartctl -i /dev/sdb              # SATA/SAS drives

Open a ticket with the serial number of the failed drive (and of the healthy one, so we pull the right disk). Failed disks are replaced within 2 hours.

Rebuild after the swap

Copy the partition table from the healthy disk to the new one, give it new identifiers, then add its partitions back to each array. In this example nvme0n1 is healthy and nvme1n1 is new:

$ sgdisk -R /dev/nvme1n1 /dev/nvme0n1   # copy table TO the new disk
$ sgdisk -G /dev/nvme1n1                # randomise its GUIDs
$ mdadm /dev/md0 --add /dev/nvme1n1p2
$ mdadm /dev/md2 --add /dev/nvme1n1p3
$ watch -n 5 cat /proc/mdstat

Order matters: sgdisk -R copies to the first device from the second. Swapping them would wipe the healthy disk’s table.

Finally, reinstall the boot loader on the new disk (grub-install /dev/nvme1n1 on BIOS systems, or copy the EFI system partition on UEFI systems) so the server boots from either drive.

Get alerted next time

Set MAILADDR you@example.org in /etc/mdadm/mdadm.conf and make sure the mdmonitor service runs: mdadm emails you as soon as an array degrades.