How to List RAID Arrays and Member Disks in Linux mdadm Configuration


2 views
# Basic array listing
cat /proc/mdstat

# Detailed array information
mdadm --detail /dev/md*

# Alternative verbose listing
mdadm --examine --scan

In Linux software RAID (mdadm), arrays are typically named as /dev/mdX where X is a number. The member disks can be whole drives (/dev/sdX) or partitions (/dev/sdX1).

To get comprehensive information about all arrays:

for array in /dev/md*; do
    echo -e "\n=== $array ==="
    mdadm --detail $array
done

Extract just the device names participating in each array:

mdadm --detail /dev/md0 | grep -o '/dev/sd[a-z][0-9]*'

The /proc/mdstat file contains real-time array status:

Personalities : [raid1] [raid6] [raid5] [raid4] 
md0 : active raid1 sdb1[1] sdc1[0]
      1953382464 blocks super 1.2 [2/2] [UU]
      
md1 : active raid5 sdd1[0] sde1[1] sdf1[2]
      2930266368 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

For systemd-based distributions:

systemctl list-units --type=target --all | grep mdadm

To create a persistent mdadm.conf:

mdadm --detail --scan > /etc/mdadm/mdadm.conf

If devices aren't showing up correctly, rescan with:

mdadm --assemble --scan

The most straightforward way to inspect your Linux software RAID configuration is using the mdadm utility. This tool provides comprehensive information about RAID arrays managed by the kernel's md (multiple devices) driver.

To get a quick overview of all active arrays:

sudo mdadm --detail --scan

This will output something like:

ARRAY /dev/md0 metadata=1.2 name=myserver:0 UUID=5b8c1a3d:12a3bc4f:8912d3e4:5678f901
ARRAY /dev/md1 metadata=1.2 name=myserver:1 UUID=9a8b7c6d:5e4f3g2h:1i2j3k4l:5678m901

For complete details about a specific array including its component devices:

sudo mdadm --detail /dev/md0

Sample output:

/dev/md0:
           Version : 1.2
     Creation Time : Wed Mar  1 10:30:00 2023
        Raid Level : raid1
        Array Size : 1953382464 (1863.01 GiB 2000.26 GB)
     Used Dev Size : 1953382464 (1863.01 GiB 2000.26 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

       Update Time : Thu Mar  2 14:45:22 2023
             State : clean 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : resync

              Name : myserver:0  (local to host myserver)
              UUID : 5b8c1a3d:12a3bc4f:8912d3e4:5678f901
            Events : 42

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       1       8       16        1      active sync   /dev/sdb

For systems without mdadm or when you need script-friendly output:

Using /proc/mdstat

cat /proc/mdstat

Example output:

Personalities : [raid1] 
md0 : active raid1 sdb[1] sda[0]
      1953382464 blocks super 1.2 [2/2] [UU]
      
md1 : active raid1 sdd[1] sdc[0]
      976691232 blocks super 1.2 [2/2] [UU]

Using lsblk for Visual Hierarchy

lsblk -o NAME,MAJ:MIN,RM,SIZE,RO,FSTYPE,MOUNTPOINT,LABEL,MODEL

This shows the block device tree with RAID members clearly indicated.

Here's a bash script to extract all RAID arrays with their component devices:

#!/bin/bash
for array in /dev/md*; do
    if [ -b "$array" ]; then
        echo "Array: $array"
        echo "Devices:"
        mdadm --detail "$array" | grep -A$(cat /proc/mdstat | grep "$array" | awk '{print $5}' | cut -d'[' -f2 | cut -d']' -f1) 'active sync'
        echo ""
    fi
done
  • Always use sudo or root privileges when working with mdadm
  • For failed arrays, check dmesg for kernel messages
  • The --examine flag can inspect component devices directly
  • Metadata version (1.2 vs 1.0) affects how devices are identified