Monday to Saturday 8:00–19:00, Sunday closedFree courier collection throughout Switzerland · drop-off in Lugano, Zurich and Sant'Antonino

NAS and RAID

mdadm array will not assemble: a checklist before any write

Linux software RAID is robust, and most arrays that refuse to start can be brought back. The arrays we receive in the lab are usually the ones where somebody typed one command too many. This checklist keeps you on the read-only side until you know exactly what you are dealing with.

Published 2 min readBy Mirush Murataj

Cover of the RecDati guide: mdadm array will not assemble: a checklist before any write
Collect everything read-only first: mdstat, --examine for every member, kernel log.

In short

  • Collect everything read-only first: mdstat, --examine for every member, kernel log.
  • Compare event counts and update times to find the stale member.
  • Write commands only on overlays or clones, and never --create on an array that holds data.

Step 1: collect, without writing

  • cat /proc/mdstat: what the kernel sees right now.
  • mdadm --examine /dev/sdX1 for every member partition, saved to a file.
  • dmesg or the journal from the moment the array failed: which disk produced errors, and when.
  • smartctl -a for each disk: reallocated, pending and uncorrectable sectors.
  • Disk serial numbers and the bay or port each one sits in.

Keep these files outside the array. They are what anybody, including a lab, will ask for first.

Step 2: protect the members

If a disk shows read errors or rising pending sectors, image it with GNU ddrescue before anything else, or have it imaged. If cloning everything is not possible, work on copy-on-write overlays: device-mapper snapshots that send every write to a separate file. Your real disks are then never modified, whatever you try.

Step 3: compare the members

In the --examine output, line the members up side by side:

FieldWhat to look for
Array UUIDThe same on every member of this array
Raid Level, Raid DevicesThe expected level and number of members
Chunk Size, LayoutIdentical everywhere: stripe size and parity rotation
Device RoleEach position present once
EventsMembers within a few events of each other are in sync
Update TimeThe date and time of the last write on that member
Array StateHow each member last saw the others

A member whose event count is far behind the others dropped out earlier and holds old data. Leave it out of the first assembly attempt.

Step 4: assemble read-only

Try mdadm --assemble --readonly with the members you selected. If mdadm refuses because the event counts differ slightly, --force accepts the newest members and rewrites the superblock of the one that lags. That is a write: do it on overlays, and only when the gap is small and you understand where it comes from.

Then mount read-only: mount -o ro for ext4, and -o ro,norecovery for XFS so the log is not replayed. Copy the data off before anything else.

Step 5: know the commands that destroy arrays

  • mdadm --create, even with --assume-clean, writes new superblocks. A different chunk size, member order, metadata version or data offset turns the array into noise, and the original superblocks are gone. Newer mdadm versions also choose a different default data offset than old ones.
  • --zero-superblock on the wrong device.
  • fsck or xfs_repair on an array assembled in the wrong order.

When to stop

Stop as soon as a disk makes noise, drops off the bus or its error counters keep rising, when two members have very different event counts and you cannot tell which is current, or when the file system will not mount read-only. From here, each attempt reduces what can be saved. See RAID data recovery and, for hardware controllers, Second disk error during a RAID 5 rebuild: what the next 48 hours should look like.

Frequently asked questions

Is mdadm --assemble --force safe?

Reasonably safe when the event counts differ by a few units and all disks are healthy, but it writes to the superblocks. If the data is important, never run it on the real disks.

What does a large gap in the Events field mean?

That member left the array long before the others. Its data is stale and it should normally stay out of the assembly.

Can a lab work from our overlays and logs?

The logs and the --examine output help a lot. The lab still needs the disks themselves to clone them.

Official sources and useful links

Is your data important?

Do not try anything that could make the fault worse. The diagnosis is free and you get a fixed quote before any work starts.

Request a free diagnosis RAID data recovery

Device not responding any more? Unplug it and let us take a look.

Get a price