MDRAID Sysfs Components
The MDRAID subsystem has sysfs components that provide information or can be used to tweak behavior and performance. All MDRAID devices present in the system are shown in /sys/block/.
Example:
# ls -l /sys/block/md*
lrwxrwxrwx 1 root root 0 May 17 13:26 /sys/block/md126 -> ../devices/virtual/block/md126
lrwxrwxrwx 1 root root 0 May 17 13:26 /sys/block/md127 -> ../devices/virtual/block/md127Mapping between a device number and its name can be found as shown below:
# ls -l /dev/md/ total 0
lrwxrwxrwx 1 root root 8 May 17 13:26 imsm0 -> ../md127
lrwxrwxrwx 1 root root 8 May 17 13:26 raid1 -> ../md126
# ls -l /dev/md/ total 0
lrwxrwxrwx 1 root root 8 May 17 13:26 imsm0 -> ../md127
lrwxrwxrwx 1 root root 8 May 17 13:26 raid1 -> ../md126MD devices in /sys/block are symbolic links pointing to /sys/devices/virtual/block. All MD devices are in the md subdirectory in the /sys/devices/virtual/block/mdXYZ directory. In the md directory the following contents can be found:

Since the MD device is a container, the metadata version file will show:
# cat /sys/devices/virtual/block/md127/md/metadata_version external:imsmThe directory contains subdirectories dev-nvme1n1 and dev-nvme2n1 specifying the disks that the container is assembled from.
The MD volume contents look like below:

Several new files are present, and they are related to the RAID volume properties. Base information can be read from the following files:
Array size:
# cat /sys/devices/virtual/block/md126/md/array_size 1048576Array state:
# cat /sys/devices/virtual/block/md126/md/array_state cleanRaid level:
# cat /sys/devices/virtual/block/md126/md/level raid1Strip size:
# cat /sys/devices/virtual/block/md126/md/chunk_size 65536Metadata:
# cat /sys/devices/virtual/block/md126/md/metadata_version external:/md127/0And this is what is shown in the /proc/mdstat file for the example RAID information:
# cat /proc/mdstat Personalities : [raid1]
md127 : active raid1 nvme0n1[1] nvme1n1[0]
78148256 blocks super external:/md0/0 [2/2] [UU]
md0 : inactive nvme1n1[1](S) nvme0n1 [0](S) 2210 blocks super external:imsm
unused devices: <none>Last updated

