Question:
We can use smartctl to get the disk serial ID in case of disk replacement or crashes, with the following:
smartctl -a /dev/sdX
Where X is the device identifier like, for the first disk, this would be sda, second sdb etc. But in case the devices are behind the RAID, this command returns an error:
[root@tampa-lb ~]# smartctl -a /dev/sda smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1127.el7.x86_64] (local build) Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org Smartctl open device: /dev/sda failed: DELL or MegaRaid controller, please try adding '-d megaraid,N'
How to make this work?
Answer:
To get the serial numbers behind the LSI MegaRAID, you would first need to find out the device ID using LSI Megaraid tools. A quick way to install LSI Megaraid tool is available here:
How to: Install LSI Command Line Tool
One you have installed the LSI Megaraid command line tools, now you may use the following command to identify your device:
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll | egrep 'Slot\ Number|Device\ Id|Inquiry\ Data|Raw|Firmware\ state' | sed 's/Slot/\nSlot/g'
This would output something like the following:
Slot Number: 1 Device Id: 11 Raw Size: 447.130 GB [0x37e436b0 Sectors] Firmware state: Online, Spun Up Inquiry Data: 50026B72822A7D3A KINGSTON SEDC500R480G SCEKJ2.3
In this server, it has one disk, but you may have multiple disk with different ‘Firemware state’ and ‘Device Id’. To use smartmontools, you need to pick the ‘Device Id’, mentioned here, which is 11. Now you can run the following command to get the device details using smartctl:
smartctl -d megaraid,N -a /dev/sdX
Here, N is the device ID, and X is the device name, you may get the device name using df -h command or fdisk -l. For our case, this command would be like the following:
smartctl -d megaraid,11 -a /dev/sda
This would print a lot of information about your device, but if you are looking to identify the Serial Number only, you may run the following:
~ smartctl -d megaraid,11 -a /dev/sda|grep Serial Serial Number: 50026B72822A7D3A
One thing to note, we can also get Serial number from the MegaCli tools Inquiry data, you may have already noticed:
[root@tampa-lb ~]# /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll | grep 'Inquiry Data' Inquiry Data: 50026B72822A7D3A KINGSTON SEDC500R480G SCEKJ2.3
Here, the first parameter in the return is the same as smartctl returns as Serial number, it’s because it’s the serial number that megacli gets/identifies as well.
Good article and thanks for your sharing.
There is another way to get the id of the physical disk behind the disks controller(the raid card)
# smartctl –scan
My serialnumbers dont match up between smartctl and megacli..
megacli -PDList -aALL | grep “Slot\|Raw Size:\|Inquiry Data:\|Drive has”
*snip*
Slot Number: 9
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Inquiry Data: HGST HUC101860CSS200 A9020BG2LW9H
Drive has flagged a S.M.A.R.T alert : No
*snip*
smartctl -a -d megaraid,9 /dev/sda | grep “Product\|Serial”
Product: HUC101860CSS200
Serial number: 0BG2MAUH
Have a look at the details from command: megacli -PDList -aALL
But the Serial from Smartctl should be correct.