Safely Inspect and Assemble Linux Software RAID with mdadm
You will finish with a read-only way to identify Linux Software RAID members, inspect an active array, and assemble an existing array from known components. The guide uses mdadm 4.3, package version 4.3-1ubuntu2.1, installed on Ubuntu here. Allow 15 minutes for inspection, or longer if you need to identify disks from labels or serial numbers.
The route
Jump straight to the step you need, or tick off Done means at the end.
You need a shell, mdadm, and the device names for the array you are investigating. Inspection commands can usually run as an ordinary user. Assembly, management, and configuration changes require root and can change storage state.
1. Confirm the installed command
Start with the version and the mode list. These commands only read the program installation:
$ command -v mdadm
/usr/sbin/mdadm
$ mdadm --version
mdadm - v4.3 - 2024-02-15 - Ubuntu 4.3-1ubuntu2.1
$ mdadm --help | sed -n '1,20p'
Usage: mdadm --create device options...
Create a new array from unused devices.
mdadm --assemble device options...
Assemble a previously created array.
The important distinction is between --create, which writes new metadata and activates a new array, and --assemble, which activates an array that already has metadata. Do not use --create as a way to repair an array you have just discovered.
2. Check the kernel's current arrays
/proc/mdstat reports arrays that the kernel currently knows about. It is ordinary read-only information:
$ cat /proc/mdstat
Personalities : [raid1] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 ...
... blocks super 1.2 [2/2] [UU]
unused devices: <none>
The exact devices, sizes and personalities are host-specific. For a healthy two-device mirror, [UU] means both expected members are present. A missing position appears as an underscore, for example [U_]. Treat that as a prompt to investigate, not as permission to remove or recreate anything.
Checkpoint
Record the md device names and whether an array is active before you run a command that might change state.
3. Inspect a running array
For an active array, ask mdadm for its detailed state. This normally needs root because the kernel device is protected:
$ sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Raid Level : raid1
Raid Device : 2
State : clean
...
Number Major Minor RaidDevice State
0 ... ... 0 active sync
1 ... ... 1 active sync
Do not copy the ellipses as values. Check the real output for the RAID level, state, expected number of devices, and the component paths. --detail --test is useful for automation: mdadm documents exit status 0 for a normally functioning array, 1 for at least one failed device, 2 for multiple failures that make it unusable, and 4 when it cannot obtain useful information.
$ sudo mdadm --detail --test /dev/md0
$ printf 'mdadm status: %s\n' "$?"
mdadm status: 0
4. Inspect an unassembled component safely
If an array is not active, examine a suspected member without assembling it:
$ sudo mdadm --examine --brief /dev/disk/by-id/ata-EXAMPLE_DISK-part1
/dev/disk/by-id/ata-EXAMPLE_DISK-part1: UUID=... DEVICE=... TYPE=... ARRAY=...
Use a stable /dev/disk/by-id path when available, and compare several members. The UUID, metadata version, array identity and role should agree. A brief result is suitable for reviewing a candidate configuration, but the punctuation and fields depend on the metadata and installed release.
To scan devices named by configuration, --examine --scan reads the configured device list. If you need to avoid the system configuration while testing, --config=partitions tells mdadm to use device numbers from /proc/partitions; it does not mean that every device is safe to use.
5. Assemble an existing array
Warning
Assembly activates storage. Confirm the UUID and member set first, ensure the filesystem is not already mounted elsewhere, and have a recovery plan. Do not guess a component path, substitute a different disk, or add --force because an ordinary assembly failed.
When the identity and components are known, assemble the pre-existing array explicitly:
$ sudo mdadm --assemble /dev/md0 \
/dev/disk/by-id/ata-EXAMPLE_DISK_A-part1 \
/dev/disk/by-id/ata-EXAMPLE_DISK_B-part1
mdadm checks the superblocks against the array identity. It normally starts the array after assembly. If you deliberately provide fewer expected members, mdadm does not normally start it without --run, which is a safety check. A degraded start can expose data while another member is unavailable, but it also creates recovery and write risks; use it only after confirming the RAID level and failure state.
Checkpoint
Verify the result before mounting anything:
$ cat /proc/mdstat
$ sudo mdadm --detail /dev/md0
If the array is not the one you expected, stop. Do not mount it read/write and do not overwrite its members while investigating.
6. Keep mdadm.conf focused
Configuration is a workflow aid, not a substitute for checking metadata. The default locations are /etc/mdadm.conf, its .d directory, or the alternative /etc/mdadm/mdadm.conf locations when the first file cannot be opened. Files in a configuration directory are read in lexical order.
A small configuration can identify the devices to scan and one array by UUID:
DEVICE /dev/disk/by-id/ata-EXAMPLE_DISK_*
ARRAY /dev/md0 UUID=REPLACE-WITH-THE-VERIFIED-UUID
Replace the UUID with the value from --detail or --examine. The DEVICE line controls where mdadm looks. An ARRAY line identifies an array; multiple identity fields must all match. Review generated output before installing it, because --detail --scan and --examine --scan can include unwanted device details.
After a configuration change, test the intended lookup explicitly:
$ sudo mdadm --assemble --scan --readonly
$ cat /proc/mdstat
Read-only assembly still changes which md device is active, so use a maintenance window and verify that no duplicate host is using the same members. To undo a configuration-only change, restore the previous file. To deactivate an array, sudo mdadm --stop /dev/md0 requires that it is not in use and is a service-disrupting action, so unmount filesystems and stop dependent services first.
7. Avoid the common traps
--createwrites superblocks. Never use it to make an unknown existing array appear healthy.--zero-superblock,--fail,--removeand--growchange storage state. Take a verified backup and check the exact target before using them.--forceoverrides selected safety checks. It does not reconstruct missing data or make mismatched disks safe.--scanobtains missing information from configuration or kernel state. It is not a guarantee that every discovered array belongs to this host.- Do not confuse an active array with a mounted filesystem. Check mounts separately before stopping or assembling anything.
Done means
- You confirmed mdadm 4.3 and recorded the current
/proc/mdstatstate. - You inspected the active array or member superblocks and verified the UUID and RAID level.
- You used explicit, stable component paths for assembly.
- You reviewed mdadm.conf instead of trusting generated scan output blindly.
- You did not create, grow, fail, remove or erase metadata while investigating.