Get Hard Drive Physical Slot
I can pull all the details of a hard drive using smartctl, however I cannot find out physical bay the drive is plugged into.
I have noticed that if I run dmesg, I can get the 'phy(x)' which represents the physical slot the drive is plugged into, and i can cross reference this against the model number to find the slot. See below:
However, if I have two of the exact same drive this presents a problem? I need to be able to cross-reference against the serial number. Also, dmesg is a log, so I have to go backwards through the file (which can grow really large), and so I would prefer not to have to do that.
Can anyone provide a better and foolproof way of getting the physical bay slot of a hard drive? (Using centos 5)
(at the moment i am pulling the hard drive details from
smartctl --all /dev/sg* where sg1, sg2, etc represents each physical drive.