I want to know which hard disk drive corresponds to which device path. It's trivial to match the hard disk stats (brand, size) with the dev path, but I want more. I want to know which drive is which inside my case. What's a good way to go about getting this info?
Constraints
- I am lazy. I don't want to tear apart my server to remove all the drives, then add back one by one.
- Reboots are acceptable.
- The drives are inconveniently scrunched together in the case. The label information is hidden.
- The case can be opened. Most disks are SATA, so theoretically hot swappable. Unplugging cables is fair game.
Bonus
I'll award answer to the best/easiest gui or cli answer, and give a bounty to the next-best answer of the other kind. I prefer a cli answer, but understand that a lot of other folks will appreciate a good point-and-click method.
Best Answer
hdparm -i /dev/sdX
gives you the serial number, which is the simplest way I know of to tell apart hard disks of the same brand and size.The serial number is normally printed on a label on the disk, so although you need to open the case to find it, there's no need disassemble the computer.
Example:
If you want more info
lshw -c storage -c disk
gives the most readable output. It's pretty much the same data as Disk Utility, just in command line format.Here is an annotated example from the most complex setup I have access to, with four disk controllers, seven hard disks, a DVD ROM and a USB disk.
The output has been cut down to size to focus on the interesting parts:
I think the Disk Utility is faster to read; the command line version has the advantage of being usable over ssh and in scripts.
And I still think the serial number is the most reliable solution :)
The "Physical ID" of each drive corresponds to where it is connected to the motherboard. and starts with 0. so a physical ID of 2 would mean that the drive is attached to the 3rd sata port of your mobo or other applicable device.