smartctl and MegaRAID

I’ve never found an entirely satisfactory way of asking our Linux machines for the models, specifications and serial numbers of their disks.

Until now our server monitoring scripts have used the disk controller’s software utility to get disk information, then attempt to make sense of it. For most of our servers the disk controller is a Dell PERC, and this can be controlled using the MegaCli utility.

MegaCli can be asked to return “Inquiry Data” for each disk in the system. This inquiry data is typically a one line mixture of the disk’s manufacturer, its model number, its serial number and its current firmware level.

The problem is that the particular recipe differs from one disk model to another: sometimes the serial number appears before the manufacturer, model and firmware revision; sometimes after; sometimes the manufacturer is named, and sometimes not; sometimes these distinct pieces of data are separated by spaces, and sometimes not.

It’s a mess, and so is the script that tries to make sense of it.

So I was overjoyed – if exasperated – to find out recently that the smartctl utility has all along had the ability to disentangle this data, and present each item of disk inquiry data in a neat, individual, predictably separate way.

For a simple desktop, smartctl is easy enough to use. A command like smartctl -i /dev/sda might return information like:

Model Family:     Western Digital Blue
Device Model:     WDC WD5000AZLX-60K2TA0
Serial Number:    (withheld from blog)
LU WWN Device Id: (withheld from blog)
Firmware Version: (withheld from blog)
User Capacity:    500,107,862,016 bytes [500 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    7200 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 (unknown minor revision code: 0x006d)
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Fri Jan 12 14:47:44 2018 GMT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

That’s all very well as long as the operating system’s disk device – in this case /dev/sda – corresponds to a physical hard disk. For simpler machines this is the case, but more sophisticated servers and workstations will probably have multiple physical disks logically joined together into virtual disks.

If RAID is in use, smartctl can still produce the goods, but it needs to be told something about the RAID setup – the technology in use, the slot which houses the physical disk of interest, and the Linux device corresponding to the virtual disk of which that physical disk is part. For example,

smartctl -i -d megaraid,2 /dev/sdb

With careful use of MegaCli, a script could find out all of this information for each disk on a server with multiple physical and virtual disks, but it would be a tedious job.

So, imagine my surprise when I noticed that smartctl can be fed the slot number of any disk on the system, and the device name /dev/sda, and it’ll happily return the data on the disk in that slot, whether or not it constitutes part of /dev/sda or of some other virtual disk entirely.

So, on a server with eight physical disks RAIDed into three virtual disks, smartctl will happily supply information for any physical disk on the system if you specify disk device /dev/sda. All you need to vary is the slot number which houses the physical disk of interest. So for instance the disk in slot 7, which is actually part of /dev/sdc, can be queried with

smartctl -i -d megaraid,7 /dev/sda

A monitoring script would be a good deal easier to write if the same virtual disk device could be used for every disk on the system. Is that behaviour likely to stay, I wonder? Or will the maintainers fix it at some point?

Leave a Reply