Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

mdadm DegradedArray event on /dev/md0: find the failed member and replace it

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When the mdadm monitor logs DegradedArray event detected on md device /dev/md0, or mails a message with the subject DegradedArray event on /dev/md0:<hostname>, the array is running without one of its members. The mdadm manual says this event is generated "only when mdadm notices that an array is degraded when it first sees the array", so it often follows a reboot or a monitor restart. A separate Fail event reports a member failing under a running monitor. Protect the data first, find the missing member with mdadm --detail, then re-add it if it is healthy or replace it.

What the error means

The mdadm monitor polls md arrays and raises named events. The manual defines this one: "A newly noticed array appears to be degraded. This message is not generated when mdadm notices a drive failure which causes degradation, but only when mdadm notices that an array is degraded when it first sees the array." It lists the failure event separately: Fail is "An active component device of an array has been marked as faulty."

The text is built in the monitor's source. In mdadm 4.2 and 4.3 the log message uses the format %s event detected on md device %s, and the mail subject uses %s event on %s:%s (event name, array, host name). In 4.2 the event is raised for an array the monitor has not seen before when its status pattern contains an underscore; the 4.2 header comment says the pattern uses "U for up, _ for down". So [U_] in /proc/mdstat is a two-member array with its second member down. The manual says only Fail, FailSpare, DegradedArray, SparesMissing and TestMessage cause an email, and that syslog priority for this event is Critical.

The kernel reports the same state without mdadm. The md documentation says the degraded file "contains a count of the number of devices by which the arrays is degraded", that an optimal array shows 0 and "A single failed/missing drive will show 1, etc." The sync_action file shows recover when "a hot spare is being built to replace a failed/missing device".

Likely causes

Cause What you see How to confirm
A member failed earlier A Fail event before this one; the member shows faulty mdadm --detail /dev/md0 lists a member as faulty
A member is missing (cable, controller, renamed device) The member is absent from mdadm --detail; the disk may be absent from the system mdadm --examine of the partition reads its metadata, or the device does not exist
The monitor started after the array was already degraded DegradedArray appears at boot or after the monitor restarts, with no Fail event The degraded file reads 1 or more
A rebuild is already running RebuildStarted or recover in sync_action sync_action reads recover; /proc/mdstat shows progress
The array has no spare The array stays degraded after a failure mdadm --detail shows zero spare devices

Prove the cause before changing anything

Everything here only reads. Use the array name from the event in place of /dev/md0, and run the commands as root.

1. Read the kernel's summary. The manual says /proc/mdstat lists all active md devices:

cat /proc/mdstat

A good result shows every member present. A bad result shows an underscore in the member status, for a RAID 1 pair [U_].

2. Read the array detail. The manual says --detail prints "details of one or more md devices":

mdadm --detail /dev/md0

Note which member is faulty, removed or missing, and the state of the array. Save the output for the replacement decision.

3. Read the exit status. With --test the manual says the exit status of --detail is 0 when the array is functioning normally, 1 for "The array has at least one failed device", 2 for "The array has multiple failed devices such that it is unusable", and 4 for an error getting information:

mdadm --detail --test /dev/md0; echo "exit status $?"

4. Read the member's own metadata. The manual says --examine prints the "contents of the metadata stored on the named device(s)". Use the partition that should be a member:

mdadm --examine /dev/sdb1

A metadata block naming this array confirms the partition belonged to it.

5. Read the degraded count and device state. The kernel documentation names these files:

cat /sys/block/md0/md/degraded
cat /sys/block/md0/md/sync_action
cat /sys/block/md0/md/dev-sdb1/state

The device state file lists faulty for "device has been kicked from active use due to a detected fault" and in_sync for a fully in-sync member.

Fix

Protect the data first

Protect the data before any change, because a degraded array has lost some or all of its redundancy and a second failure ends it. Confirm that a recent copy exists outside this array. If the surviving disk shows read errors, image it before the repair: see A failing disk in a Linux server: image it before you repair it. For a disk that is reporting pending sectors, see smartd: "Currently unreadable (pending) sectors" on a Linux disk: what to check first.

The member is healthy but was dropped

The manual says --re-add re-adds "a device that was previously removed from an array". If its metadata "reports that it is a member of the array, and the slot that it used is still vacant", the device goes back in the same position, and with a write-intent bitmap "the recovery may only require sections that are flagged by a write-intent bitmap to be recovered".

First save the current state:

mdadm --detail /dev/md0 > md0-detail-before.txt
cat /proc/mdstat > mdstat-before.txt

Risk: the next command puts the named partition back into the array and starts recovery onto it. Use it only on a partition whose disk you have confirmed is healthy, and not on a disk that is itself failing.

Re-add the member:

mdadm /dev/md0 --re-add /dev/sdb1

To undo it: mark the same member faulty and remove it again. The manual says a device can only be removed once it is failed or a spare, and its example combines the two operations in one command:

mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1
mdadm --detail /dev/md0

Compare the output with md0-detail-before.txt.

The disk failed: remove the member, fit a new disk, add it

The manual says --remove removes devices that "must not be active. i.e. they should be failed or spare devices", and "To remove an active device, it must first be marked as faulty". If mdadm --detail already shows the member as faulty, only the removal is needed.

Before changing anything, select and show the exact member. In mdadm --detail /dev/md0 read the device name of the faulty member, match it to the drive's serial number with the server's own disk tools, and read mdadm --examine of that partition. Failing the wrong member of a two-disk mirror removes the only good copy.

First save the current state:

mdadm --detail /dev/md0 > md0-detail-before.txt
cat /proc/mdstat > mdstat-before.txt

Disruptive step: the next command marks the named member faulty and removes it from the array. If it is the wrong member, the array loses a working copy of the data.

Mark the failed member faulty and remove it (skip --fail if it is already faulty):

mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1

To undo it: while the slot is still vacant and the disk is still present, --re-add returns the member, then check the detail:

mdadm /dev/md0 --re-add /dev/sdb1
mdadm --detail /dev/md0

If --re-add is refused, the member is not restored. Read mdadm --detail /dev/md0, and do not use --add on that disk unless you intend to rebuild onto it: the manual says --add tries a re-add first and, if that fails, adds the device as a spare and starts a rebuild onto it.

The new disk needs a partition at least as large as the members' partitions. mdadm's pages give no partitioning command, so that step is not covered here. Once the partition exists, show it without writing to it:

mdadm --examine /dev/sdc1

If this prints metadata, the partition already belongs to some array: stop and identify it before adding anything.

First save the current state again:

mdadm --detail /dev/md0 > md0-detail-before-add.txt

Disruptive step: the next command adds the new partition to the degraded array. The manual says "If the array is degraded, it will immediately start to rebuild data onto that spare", which overwrites the partition.

Add the new partition:

mdadm /dev/md0 --add /dev/sdc1

To undo it: mark the new partition faulty and remove it, then compare with the saved detail. The previous contents of the partition are not restored, and the array stays degraded:

mdadm /dev/md0 --fail /dev/sdc1 --remove /dev/sdc1
mdadm --detail /dev/md0

For a disk that still works but is suspect, the manual describes --replace, which keeps the old device in service "to increase resilience against multiple failures" while a spare is rebuilt. The manual says the replacement starts as soon as a spare is available. It is not covered by the steps here.

Example (illustrative): db01 has /dev/md0, a RAID 1 of /dev/sda1 and /dev/sdb1, each 1 TB, so the array holds 1 TB. After a reboot the log shows DegradedArray event detected on md device /dev/md0. /proc/mdstat shows [U_], /sys/block/md0/md/degraded reads 1, and mdadm --detail --test /dev/md0 exits with status 1, so one device has failed. mdadm --detail lists sdb1 as faulty. The engineer saves the detail, removes sdb1, fits a new 1 TB disk with a partition sdc1, checks that --examine prints no metadata, and adds it. The rebuild runs and the degraded count returns to 0.

Confirm the fix

  1. cat /proc/mdstat shows no recovery in progress, and the member status has no underscore.
  2. mdadm --detail /dev/md0 shows every member active and in sync. The manual says --wait makes mdadm "wait for any resync, recovery, or reshape activity to finish before returning":
mdadm --wait /dev/md0
  1. cat /sys/block/md0/md/degraded reads 0, and mdadm --detail --test /dev/md0 exits with status 0.
  2. The progress during the rebuild is in sync_completed and sync_speed under /sys/block/md0/md/.

What to watch afterwards

  • Keep monitoring on. The manual says --monitor needs a mail address or alert program in the config file (MAILADDR), or on the command line, when --scan is used.
  • The manual says "Running mdadm --monitor --scan -1 from a cron script will ensure regular notification of any degraded arrays."
  • Check the other member and the new disk with SMART after the rebuild.

Risks and limits

  • These commands have not been run or lab-tested.
  • Failing or removing the wrong member of a mirror, or of a single-parity array, can destroy the array.
  • --add overwrites the new partition. The mdadm manual gives no way to restore it.
  • RAID 0 and linear arrays have no redundancy and cannot be rebuilt this way.
  • The mail body differs between mdadm 4.2 and 4.3; only the subject and the log message are described here.
  • The monitor raises DegradedArray only for an array it first sees degraded. A degraded array on a monitor that has been running continuously produces Fail, not this event.

Sources

  • mdadm(8) — Debian Manpages, bookworm (mdadm 4.2-5), source last updated 24 February 2023, accessed 2 December 2026
  • mdadm.conf(5) — Debian Manpages, bookworm (mdadm 4.2-5), source last updated 24 February 2023, accessed 2 December 2026
  • Monitor.c at tag mdadm-4.2 — mdadm source code at a fixed tag, no date shown, accessed 2 December 2026
  • Monitor.c at tag mdadm-4.3 — mdadm source code at a fixed tag, no date shown, accessed 2 December 2026
  • mdadm.h at tag mdadm-4.2 — mdadm source code at a fixed tag, no date shown, accessed 2 December 2026
  • RAID arrays — The Linux Kernel documentation, v6.12.0, no date shown, accessed 2 December 2026