How To Check The Status Of Software Raid On Linux

Do you have a server with software raid and are looking to check its status? If so this article is for you,

On this page
  1. What Is RAID?
  2. Using /proc/mdstat
  3. Using Mdadm To Check Raid Status
  4. Using Mdadm To Check A Disk
  5. Logs
  6. Conclusion
  7. Additional Links

Do you have a server with software raid and are looking to check its status? If so this article is for you, we will look at how to check the raid array status as well as how to check specific disks in the context of the RAID array.

#What Is RAID?

The term RAID stands for redundant array of inexpensive disks, it is a technology that allows you to combine multiple disks into one or more logical units. With RAID arrays you can increase redundancy, performance, or both.

Introduction To Software Raid

Before software RAID arrays, raid was typically done with a hardware device that would be between the disks and the rest of the system.

Since software RAID was added the need for a separate hardware device has been greatly reduced if not eliminated. On Linux, software raid is provided by the utility mdadm.

#Using /proc/mdstat

If you are looking for quick stats on your RAID array this is the command you want.

Code
user@example:~$ cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sdb[1] sdc[0]
      10476544 blocks super 1.2 [2/2] [UU]
      
unused devices: <none>

Understanding The Results

  • md0 is the name of the array
  • active means the array is active
  • List the raid level which in this case is raid1
  • sdb and sdc are members of the array
  • 10476544 blocks is the size of the array
  • super 1.2 indicated the version of superblock used
  • [2/2] means the array is composed of 2 devices both of which are active
  • [UU] is the status of the drives in the array

#Using Mdadm To Check Raid Status

Both the -D and –details flags for mdadm will display even more detailed information about the array and an example is shown below.

Code
user@example:~$ sudo mdadm -D /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Wed Jun 19 11:54:22 2024
        Raid Level : raid1
        Array Size : 10476544 (9.99 GiB 10.73 GB)
     Used Dev Size : 10476544 (9.99 GiB 10.73 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

       Update Time : Wed Jun 19 11:57:41 2024
             State : clean 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : resync

              Name : example:0  (local to host example)
              UUID : 359234d1:da054d1a:a883c4b3:aebf5906
            Events : 22

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

Understanding The Results

Let’s dive into the results to understand what everything means:

1.2 indicated the version of the superblock used

When the RAID array was created

The RAID level of the array, in this case, that is RAID 1 (mirroring)

This is the usable size of the array

This is the space used on each device

The number of devices in the current array

All related devices included spares and failed devices

Indicates the metadata about the array is stored on the disks

When the status of the array was last updated

The state of the RAID array, where clean means everything is good

The number of devices active in the array

The number of working devices in the array

The number of failed devices in the array

The number of spare devices in the array

Indicated the policy used to maintain data consistency

The hostname and array number

The UUID of the array

The number of recorded events for the array

Shows both disks are active and in sync now but if a disk has failed you will find it here.

#Using Mdadm To Check A Disk

This section uses mdadm to pull information on a single disk.

Code
user@example:~$ sudo mdadm -E /dev/sdc
/dev/sdc:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : 359234d1:da054d1a:a883c4b3:aebf5906
           Name : example:0  (local to host example)
  Creation Time : Wed Jun 19 11:54:22 2024
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 20953088 sectors (9.99 GiB 10.73 GB)
     Array Size : 10476544 KiB (9.99 GiB 10.73 GB)
    Data Offset : 18432 sectors
   Super Offset : 8 sectors
   Unused Space : before=18280 sectors, after=0 sectors
          State : clean
    Device UUID : 3e5fb78b:c0444da6:c61f5cc9:557b629b

    Update Time : Wed Jun 19 11:57:03 2024
  Bad Block Log : 512 entries available at offset 136 sectors
       Checksum : 5cc406ac - correct
         Events : 22

   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)

Understanding The Results

An identifier indicating RAID metadata

1.2 indicated the version of superblock used

Bitmask indicates features

The UUID of the array

The hostname and array number

When the RAID array was created

The RAID level of the array, in this case, that is RAID 1 (mirroring)

The number of devices in the raid array

The available size of the device in sectors, GiB, and GB.

The total size of the raid array

The offset where the data starts on the device

The offset where RAID metadata starts on the device

The amount of unused space before and after the RAID data

The state of the RAID array, where clean means everything is good

The UUID of this specific disk

When the status of the array was last updated

Information on how many entries are in the bad block log and where it is located on the disk

The checksum of the RAID metadata shows it is correct

The number of recorded events for the array

The device number from the array starting at 0

The state of the array showing both disks active

#Logs

Logs for software raid will log to the location that kernel messages will be saved to. The most common locations for kernel messages are listed below:

  • /var/log/kern.log
  • /var/log/messages
  • /var/log/syslog
  • The dmesg command
  • Systemd Journal using journalctl

#Conclusion

With Software RAID you no longer need to rely on hardware raid cards. In this blog post, we discuss how to check the status of your software raid on your Linux server. We also go through what everything means so you will be sure to understand.

Done reading and looking for additional information, why not check these out/

Illustrated avatar of CJ Saathoff
Written by

CJ Saathoff

CJ Saathoff writes for the NameHero blog.

More from CJ →