How to get the serial number of a badly failed disk

Posted on Thu 08 December 2011 in Sysadmin

One of my server disks has failed - so badly that smartctl cannot even read basic disk information from it! But to replace the disk I need its serial number, because I have been clever enough to print the serial number of each disk onto its bay door. Ironic, huh?

So how do you get the serial number of a disk that doesn’t want to give it up?

Answer: You get the serial numbers from all other disks, and then you apply the exclusion principle!

$ for i in /dev/sd[a-z]; do sn=$(sudo smartctl -i $i | grep 'Serial Number' | awk '{print $3}'); echo $i: $sn; done
/dev/sda: 9S...
/dev/sdb: WD...
/dev/sdc:
/dev/sdd: 5V...
/dev/sde: WD...
/dev/sdf: WD...
/dev/sdg: 9Q...
/dev/sdh: WD...
/dev/sdi: 5Q...
/dev/sdj: WD...
/dev/sdk: 5L...
/dev/sdl: WD...
/dev/sdm:

Good thing I came up with that before I started to do trial-and-error disk pulling! :-) (Oh, and in case you wonder, /dev/sdc is the faulty disk whereas /dev/sdm is my boot USB stick that smartctl doesn’t recognize.)