Monday, January 16, 2023

Listing Physical Disks behind Hardward RAID Controller on Linux

Without rebooting into BIOS and hardware RAID controller's firmware, can we figure out the disks controlled by the controller? The answer is generally yes. However, the method can vary from one RAID controller to another. To list the physical disks on Linux, we need to figure out the RADI controller model, such as,


lspci | grep RAID

In my case, I have a MegaRAID, a popular RAID controller. To figure out the disks connected to the RAID controller, we can use smartctl as follows,


sudo smartctl -i -d megaraid,0 /dev/sdb

where "metaraid" is the controller model, and "0" is the 0-th disk, and "/dev/sdb" is the Linux device for the disk array

Having understood this, we can list all disks by a script as follows:


#!/bin/bash
device=/dev/sdb
disk=0
while [ 1 ]; do
   sudo smartctl -i -d megaraid,${disk} ${device}
   if [ $? -ne 0 ]; then
     break
   fi
   let disk=${disk}+1
done

No comments:

Post a Comment