Use it when replacing a failed RAID member.
Rebuild
A rebuild (resync/recovery) copies or reconstructs data onto a replacement disk after a failure, restoring redundancy.
1. Identify the failed disk by serial (ls -l /dev/disk/by-id).
2. Fail and remove it from the array.
3. Copy the partition table: sfdisk -d /dev/<good> | sfdisk /dev/<new> (or sgdisk -R).
4. mdadm /dev/md0 --add /dev/<new>1.
5. Watch /proc/mdstat until done; reinstall bootloader if needed.
failed member removed → new disk partitioned → added → recovery copies/reconstructs → array clean
For RAID → Rebuild, continue with the first unproven Topic check: Capture pre-rebuild array/member state, exact failed device evidence and health of every surviving source member. If that boundary is healthy, advance to the adjacent check: Verify replacement identity, usable size/geometry and clean intended metadata state before adding it to the array. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
degraded array + healthy source members → validated replacement → add/re-add → md recovery/resync reads + reconstructed writes → active in-sync member → clean redundant array → upper-layer/workload verification
Healthy evidence: validated source members reconstruct onto the intended replacement, recovery reaches completion, the new member becomes active/in-sync and upper-layer verification succeeds.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Capture pre-rebuild array/member state, exact failed device evidence and health of every surviving source member.
- Verify replacement identity, usable size/geometry and clean intended metadata state before adding it to the array.
- Monitor /proc/mdstat/md detail plus kernel and device errors through the full recovery, not only the percentage indicator.
- At completion, show expected active/working counts, no pending recovery/check, upper filesystem/LVM consistency and the original workload.
Verification chain. degraded array + healthy source members → validated replacement → add/re-add → md recovery/resync reads + reconstructed writes → active in-sync member → clean redundant array → upper-layer/workload verification
Step 3 Commands Verify boundary
mdadm /dev/md0 --fail /dev/sdc1 --remove /dev/sdc1
mdadm /dev/md0 --add /dev/sdd1
watch cat /proc/mdstat
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: surviving members show read errors, recovery stalls/restarts, replacement remains spare, speed masks contention or the array reaches 100% while redundancy/data verification is incomplete.
Step 5 Common mistakes Narrow the fault
- Replacing the wrong disk (check serial numbers).
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Mark the failed disk faulty and remove it (mdadm /dev/md0 --fail /dev/sdX1 --remove /dev/sdX1), partition the new disk like the others, add it (--add). Progress in /proc/mdstat. Rebuild speed limits: /proc/sys/dev/raid/speed_limit_min/max. Avoid heavy load during rebuild.
cat /proc/mdstat— md arrays and sync statusmdadm --detail /dev/md<n>— array state and membersmdadm --examine /dev/<dev>— member superblocksmartctl -H /dev/<disk>— disk health
ReferenceWhat it is1 section · depth on demand
Core model
Before rebuild, establish why the array is degraded and whether remaining source members are healthy enough for reconstruction. During recovery, track progress, speed, read/write errors, state transitions and workload pressure. After 100%, show the replacement is an active in-sync member and verify upper-layer data; percentage completion alone is not closure.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
Rebuild closure requires restored in-sync membership with no new member/path errors and successful upper-layer read-back; a progress bar or successful mdadm add is only intermediate evidence.
In depth
Watch and steer a rebuild
$ cat /proc/mdstat
md0 : active raid1 sdb1[2] sda1[0]
976630464 blocks super 1.2 [2/1] [U_]
[=====>...............] recovery = 27.4% (267611136/976630464) finish=81.3min speed=145288K/sec
bitmap: 3/8 pages [12KB], 65536KB chunk
$ cat /sys/block/md0/md/sync_action
recover
$ cat /sys/block/md0/md/sync_speed_min /sys/block/md0/md/sync_speed_max
1000 (system)
200000 (system)
The kernel md documentation describes per-array sync_speed_min/sync_speed_max in KiB/s (falling back to /proc/sys/dev/raid/speed_limit_*), sync_action values (idle, resync, recover, check, repair), mismatch_cnt after check/repair, and the write-intent bitmap that limits resync to regions that may be out of sync.
Speed vs. production load
| Goal | Setting |
|---|---|
| Finish faster in a quiet window | echo 500000 > /sys/block/md0/md/sync_speed_min |
| Protect production I/O | Lower sync_speed_max, e.g. echo 50000 > ... |
| Back to system defaults | echo system > /sys/block/md0/md/sync_speed_min |
The rebuild is the riskiest period: the array has no redundancy (RAID1/5) or reduced redundancy (RAID6). Avoid heavy maintenance (backups, large copies) during it if possible.
Replace without losing redundancy first
mdadm /dev/md0 --add /dev/sdc1
mdadm /dev/md0 --replace /dev/sda1 --with /dev/sdc1
--replace rebuilds onto the new disk while the old one stays active — better than failing a disk that still works.
After the rebuild
| Check | Command |
|---|---|
| Array clean | mdadm --detail /dev/md0 → State : clean, all active sync |
| Consistency scrub | echo check > /sys/block/md0/md/sync_action, then cat .../mismatch_cnt |
| Boot loader on the new disk (RAID1 boot) | Install GRUB / EFI partition copy on the replaced disk |
| Config file | mdadm --detail --scan matches /etc/mdadm/mdadm.conf; update initramfs |
A non-zero mismatch_cnt on RAID1 with swap or unaligned writes can be harmless; on RAID5/6 investigate (and run repair only with a backup).
*The mdstat recovery percentage and estimated completion time are illustrative, not a measured array resynchronization.*
How it works at runtime
Rebuild is part of RAID → Rebuild. Rebuild covers Linux md recovery/resynchronization after a member is added, replaced, re-added or an array requires synchronization, with emphasis on source-member health, progress, completion semantics and post-recovery verification.
Topic-specific state model. Rebuild covers Linux md recovery/resynchronization after a member is added, replaced, re-added or an array requires synchronization, with emphasis on source-member health, progress, completion semantics and post-recovery verification.
Interpretation rule. - Replacement added ≠ rebuild started; member can remain spare or be rejected by metadata/size/state constraints.
- Rebuild 100% ≠ restored protection unless the member is active/in-sync and no new failure/mismatch occurred.
- Fast rebuild ≠ safer rebuild; source devices, controller/path health and workload contention determine risk.
- Successful block reconstruction ≠ application data is logically correct or an independent backup exists.
Method
Replacing a failed md member and rebuilding:
mdadm --detail /dev/md0 # which member failed
mdadm /dev/md0 --fail /dev/sdc1 --remove /dev/sdc1
# replace disk, copy partition table
sgdisk -R /dev/sdc /dev/sdb && sgdisk -G /dev/sdc
mdadm /dev/md0 --add /dev/sdc1
watch cat /proc/mdstat
mdadm /dev/md0 --replace /dev/sdd1 --with /dev/sde1 # proactive replace keeps redundancy
Tune rebuild speed with /proc/sys/dev/raid/speed_limit_min|max (KiB/s). For boot disks, reinstall the boot loader on the new disk.
Limits and how it fails
Primary failure point. Rebuild closure requires restored in-sync membership with no new member/path errors and successful upper-layer read-back; a progress bar or successful mdadm add is only intermediate evidence.
Preserve at least three independent checks: prerequisite/interface or identity/transport state; the responsible control/service/policy state; then effective data-plane, backend or workload state. A healthy upstream step does not show the downstream consumer or return path.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Rebuild owns Linux md recovery execution and verification. RAID level Topics own reconstruction tolerance; Physical Media owns replacement-device health; Filesystem/Data Integrity/Backup own content validation and independent recovery.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in RAID → Rebuild. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/admin-guide/md.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Rebuild operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Rebuild.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Rebuild covers Linux md recovery/resynchronization after a member is added, replaced, re-added or an array requires synchronization, with emphasis on source-member health, progress, completion semantics and post-recovery verification. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin exact host + array UUID/name → capture /proc/mdstat + md detail → examine every candidate member superblock/role/event count → prove lower device/path health → identify clean/degraded/recovery/reshape state → change one demonstrated cause → verify expected active membership/redundancy → read back LVM/filesystem → repeat original workload and regression. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | degraded array + healthy source members → validated replacement → add/re-add → md recovery/resync reads + reconstructed writes → active in-sync member → clean redundant array → upper-layer/workload verification | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Rebuild closure requires restored in-sync membership with no new member/path errors and successful upper-layer read-back; a progress bar or successful mdadm add is only intermediate evidence. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux RAID evidence can establish this proof path: degraded array + healthy source members → validated replacement → add/re-add → md recovery/resync reads + reconstructed writes → active in-sync member → clean redundant array → upper-layer/workload verification | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured host/VM, array UUID, metadata generation, member set, device/path health, recovery window, upper filesystem/LVM, time or workload scope. Rebuild closure requires restored in-sync membership with no new member/path errors and successful upper-layer read-back; a progress bar or successful mdadm add is only intermediate evidence. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven RAID boundary: capture exact member metadata and downstream state, preserve recoverability, change only the demonstrated cause, verify stable array membership/redundancy, then repeat the original upper-layer workload and adjacent regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
Rebuild · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Rebuild |
|---|---|
| Topic path | RAID → Rebuild |
| Runtime state | Rebuild covers Linux md recovery/resynchronization after a member is added, replaced, re-added or an array requires synchronization, with emphasis on source-member health, progress, completion semantics and post-recovery verification. |
| Fast checks | - Capture pre-rebuild array/member state, exact failed device evidence and health of every surviving source member. - Verify replacement identity, usable size/geometry and clean intended metadata state before adding it to the array. - Monitor /proc/mdstat/md detail plus kernel and device errors through the full recovery, not only the percentage indicator. - At completion, prove expected active/working counts, no pending recovery/check, upper filesystem/LVM consistency and the original workload. |
| Verification chain | degraded array + healthy source members → validated replacement → add/re-add → md recovery/resync reads + reconstructed writes → active in-sync member → clean redundant array → upper-layer/workload verification Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | Rebuild closure requires restored in-sync membership with no new member/path errors and successful upper-layer read-back; a progress bar or successful mdadm add is only intermediate evidence. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. Preserve at least three independent checks: prerequisite/interface or identity/transport state; the owning control/service/policy state; then effective data-plane, backend or workload state. A healthy upstream boundary does not prove the downstream consumer or return path. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |