/proc/mdstat

The /proc/mdstat file in Linux is used to monitor the status of RAID arrays managed by the MD (Multiple Devices) subsystem, which includes software RAID configurations (such as RAID 0, 1, 5, 6, 10, etc.). It provides a live, dynamic view of the state of the RAID arrays, including whether the arrays are operational, degraded, or in the process of rebuilding.

Key Information Provided by /proc/mdstat:

  1. RAID Device Status:

    • Displays the status of each RAID array (e.g., whether it’s active, degraded, or in the process of rebuilding or reshaping).

  2. RAID Level:

    • Shows the RAID level of the array (e.g., RAID 1, RAID 5, RAID 10).

  3. Number of Devices:

    • Displays the number of devices that make up the RAID array and their current state (e.g., active, spare, failed).

  4. Resync Progress:

    • If the RAID array is being rebuilt (in the process of resyncing), it shows the progress of the resynchronization operation, typically in percentage.

  5. Write Intent Bitmap:

    • For certain RAID levels (like RAID 1), it may display whether a write intent bitmap is used. This can help improve the speed of rebuilds by tracking areas of the array that have been modified.

  6. Array Health:

    • Shows the overall health of the RAID array, including any potential failures or if a disk is marked as "faulty" or "missing."

Example Output of /proc/mdstat:

$ cat /proc/mdstat
Personalities : [raid1] [raid5] [raid6] [linear] [multipath]
md0 : active raid1 sda1[0] sdb1[1]
      1953514496 blocks super 1.2 [2/2] [UU]
      bitmap: 0/15 pages [0KB], 65536KB chunk

md1 : active raid5 sdc1[0] sdd1[1] sde1[2]
      7816121600 blocks super 1.2 level 5, 64k chunk, algorithm 2 [3/3] [UUU]
      bitmap: 0/15 pages [0KB], 65536KB chunk

Explanation of the Output:

  1. Personalities:

    • Shows the RAID levels supported by the kernel (e.g., RAID1, RAID5, RAID6). It indicates the possible configurations for software RAID.

  2. md0:

    • This is the name of the RAID array (in this case, md0).

    • Status: active raid1 — The array is actively using RAID 1 (mirroring).

    • Devices: sda1[0] sdb1[1] — The array consists of two devices (sda1 and sdb1), with both devices marked as "active" ([UU]).

    • Blocks: The array has 1953514496 blocks of data storage.

    • Health: [UU] — Indicates both devices are online and functioning properly.

  3. md1:

    • This is another RAID array (md1).

    • Status: active raid5 — The array is actively using RAID 5 (striped with parity).

    • Devices: sdc1[0] sdd1[1] sde1[2] — The array consists of three devices (sdc1, sdd1, and sde1).

    • Health: [UUU] — Indicates all three devices are active and healthy.

    • Resync: If the RAID array were in a degraded state or being rebuilt, you'd see a progress indicator (e.g., 10% complete).

Key Indicators:

  • [UU]: All devices are active and functioning (RAID is healthy).

  • [U_]: One device is active, and another is in a degraded state (e.g., missing or failed).

  • [__]: Devices are missing or failed.

  • Resync: If the RAID is rebuilding or synchronizing after a failure, this field shows the progress of the resync operation (e.g., Resyncing or Rebuild in progress with a percentage).

Other Information:

  • Bitmap: Shows if a bitmap is being used for the array, which helps optimize rebuilds by keeping track of changes.

  • Chunk Size: The chunk size of the RAID (especially important for RAID 5/6 arrays).

Use Cases for /proc/mdstat:

  1. Monitoring RAID Status: /proc/mdstat is commonly used to check the health and status of software RAID arrays. It is a quick way to verify if an array is degraded or has failed.

  2. RAID Rebuild Monitoring: When a disk in a RAID array fails, it needs to be replaced. /proc/mdstat allows you to monitor the progress of the rebuild operation, which can take a significant amount of time depending on the size of the array and the disk speed.

  3. Troubleshooting RAID Issues: By examining the output of /proc/mdstat, you can identify if a device is missing or failed, helping you take corrective actions such as replacing the failed disk.

Conclusion:

The /proc/mdstat file is an essential tool for Linux administrators managing software RAID arrays. It provides real-time status and health information about RAID devices, which can help in troubleshooting and monitoring the RAID subsystem. Always monitor /proc/mdstat after making changes to your RAID configuration (e.g., adding, removing, or replacing disks) to ensure the array remains healthy and performs optimally.

Last updated