Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
Dear all, 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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2012
    Posts
    45

    Get Hard Drive Physical Slot


    Dear all,
    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:

    12009441818-orig.jpg

    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.

    Stu

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    have you tried using the info in udev (that is, the info in the /sys filesystem)? try something like this, to see if it gives you enough info to work with:

    Code:
    udevadm info --query=all --path=/block/sda
    note: the path above is relative to /sys.

  3. #3
    Just Joined!
    Join Date
    Apr 2012
    Posts
    45
    Ok so I eventually figured out that on centos 5.8 its udevinfo, but i only get the same information I had before really as shown here:
    12306521394-orig.jpg
    Unless I am missing something and somewhere burried in there is something that can be used to identify a different physical slot the drive is plugged into. (Can be anything, so long as its consistent)

    Stu

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by stu2000 View Post
    Ok so I eventually figured out that on centos 5.8 its udevinfo, but i only get the same information I had before really as shown here:
    12306521394-orig.jpg
    Unless I am missing something and somewhere burried in there is something that can be used to identify a different physical slot the drive is plugged into. (Can be anything, so long as its consistent)

    Stu
    I see that you are using the mpt2sas driver, so I assume you are using some sort of an LSI SAS card? And by "slots", you mean ports on the card? Or something else? In any event, that driver should make available the following directory:

    /sys/class/sas_host/

    You can check there to see if devices are enumerated individually, maybe. see this thread, that's where I got the idea.

  6. #5
    Just Joined!
    Join Date
    Apr 2012
    Posts
    45
    Yes, I am using an LSI SATA+SAS Host bus Adapter (9201-16i)
    - In the past I had tried to get some kind of Cli interface for it from the LSI website but it appeared that there was only stuff for raid cards (MegaRaid Cli).

    I realised after making my post that the outputted 'id_path' variable from the command you gave me, looks like it may be enumerated based on the 'port/slot'. Its not obvious in the print screen I linked as it only shows drives sda and sdb and the sda drive is not plugged into the LSI device, but sdc and sdd were one integer different in the output for that variable.

    Thanks for the help so far, I will look at I will look at sys/class/sas_host/ if it turns out I'm wrong.

    Stu

  7. #6
    Just Joined!
    Join Date
    Apr 2012
    Posts
    45
    Turns out the id_path is exactly what I needed. Thanks again for that command. I can now identify the physical bay position of each drive remotely.
    Unfortunately this site wont let me paste a link to the script in pastebin yet....
    Thanks for the help

  8. #7
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by stu2000 View Post
    Turns out the id_path is exactly what I needed. Thanks again for that command. I can now identify the physical bay position of each drive remotely.
    Unfortunately this site wont let me paste a link to the script in pastebin yet....
    Thanks for the help
    glad you got it sorted.

    fyi, if you want to post a link, you can always just leave off the http:// part, or just use hxxp:// instead.

  9. #8
    Just Joined!
    Join Date
    Apr 2012
    Posts
    45
    Thanks its here if you want to view it:
    hxxp://pastebin.com/CbKPPUh9

    Not my finest work, i tried to clean it up a bit before pasting. Has been tested and seems to work. Had to do one to one hard-coded mapping rather than logical due to not plugging all the drives perfectly into the card. Also allows moving things around later.

  10. #9
    Just Joined!
    Join Date
    Apr 2012
    Posts
    45
    Can anyone tell me if running the smartctl or udevinfo will cause the drives to spin up if they are 'sleeping'?

  11. #10
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by stu2000 View Post
    Can anyone tell me if running the smartctl or udevinfo will cause the drives to spin up if they are 'sleeping'?
    i would seriously doubt it, but i'm not sure. maybe you could try spinning it down manually w/hdparm and then running a udevinfo/smartctl test command?

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •