I typically buy a couple new drives for my file server once or twice a year, and as such I have a quite heterogeneous collection of drives in it. Keeping track of what drives are where can be a bit of a detective game.
In order to plan out purchases, replacements, and RAID shuffling work, I want to know what I have, how it’s wired up, how big it is, etc. I’d love to be able to visualize them somehow:
For now though, a command line tool will have to suffice! Specific info I’d like to know includes the existing drive manufacturer and model, serial number, size, usage, what array it’s part of, and where it’s mounted. All this information is available either through sysfs or various system tools, but not summarized in one place.
lshdd is a wrapper script that collects the data from the system and presents it in a tidy table, like this:
Bus Target Device Array Model ID SN# Size Used MB/sec 0000:00:01.0 4:0:0:0 /dev/sde md0 WDC WD20EARX-00PASB0 50014ee104aaa42c WD-WMAZA9300056 2000 GB 70% 115.0 0000:00:01.0 7:0:0:0 /dev/sdf Hitachi HDS721010CLA332 5000cca373d19a27 JP2940HD17RD3C 1000 GB 132.8 0000:00:1c.0 9:0:0:0 /dev/sdg md0 ST2000DL003-9VT166 5000c50036aa7060 5YD36Y9G 2000 GB 70% 136.3 0000:00:1c.0 11:0:0:0 /dev/sdh ST31000340AS 5000c50002675551 3QJ02E22 1000 GB 104.3 0000:00:1f.2 0:0:0:0 /dev/sda INTEL SSDSC2CT240A4 5001517387e9cffb CVKI246300R6240DGN 240 GB 5% 387.4 0000:00:1f.2 1:0:0:0 /dev/sdb INTEL SSDSA2M160G2GC 50015179591fa938 CVPO00930308160AGN 160 GB 236.3 0000:00:1f.5 2:0:0:0 /dev/sdc md1 WDC WD4000FYYZ-01UL1B0 50014ee2b24798b3 WD-WCC130149937 4000 GB 88% 156.9 0000:00:1f.5 3:0:0:0 /dev/sdd md1 WDC WD4000FYYZ-01UL1B0 50014ee2078d8c6a WD-WCC130130855 4000 GB 88% 171.1 0000:00:1f.2 0:0:1:0 /dev/sr0 OPTIARC DVD-ROM DDU1681S 0.0 0000:00:1f.2 1:0:1:0 /dev/sr1 OPTIARC DVD-ROM DDU1681S 0.0
The rightmost columns unfortunately require use of tools that must be run as root, so they’re not displayed if not root. To get the read speeds, lshdd runs a benchmark against each drive, which means that when you run as root the output is slow. However, I find these measurements quite handy at helping me select which drives to replace so I’ve opted to include them for now. Perhaps in a future iteration I’ll make a command line option control whether they’re captured.
The one piece of data I don’t yet have is where the drive is physically located. But at least with the model and serial number I can just shut down the machine and look in each slot for the drive.
lshdd can be had at my github account: https://github.com/bryceharrington/lshdd