Locate disk in SAS enclosure

21,218

Solution 1

After cycling around /sys for a while, I found this solution:

# echo /sys/class/enclosure/*/*/device/block/sdaa
/sys/class/enclosure/2:0:35:0/Slot 15/device/block/sdaa
# echo 1 > '/sys/class/enclosure/2:0:35:0/Slot 15/locate' 

Or:

# echo 1 > /sys/class/enclosure/*/*/device/block/sdaa/../../enclosure*/locate

To blink all detected devices:

parallel echo 1 \> ::: /sys/class/enclosure/*/*/device/block/sd*/../../enclosure*/locate

This is useful if you have a drive that is so broken that is not even detected by Linux (e.g. it does not spin up).

Edit:

I have made a small tool (called blink) to blink slots. https://gitlab.com/ole.tange/tangetools/tree/master/blink

Solution 2

This ugly script adds enclosure and slot information to lsblk output:

lsblk -d -o VENDOR,MODEL,SERIAL,HCTL,NAME | sed -e "`ls -1d /sys/class/enclosure/*/*/device/block/*|sed "s+.*enclosure/\(.*\)/device/block/\(.*\)+s-\2\\$-\2 \1-+"`"

(you can change list of columns, but last column should be NAME)

Solution 3

Check what /sys/class/block/sdh links to. You can see the host, target and LUN this way. Usually this is enough to pinpoint the device's hardware address.

Solution 4

lsscsi can give you this information.

lsscsi -g

will return the /dev/sgX address beside the /dev/sdX address.

Share:
21,218

Related videos on Youtube

Ole Tange
Author by

Ole Tange

I am strong believer in free software. I do not believe in Santa, ghosts, fairies, leprechauns, unicorns, goblins, and gods. Author of GNU Parallel.

Updated on September 18, 2022

Comments

  • Ole Tange
    Ole Tange almost 2 years

    I want to blink the failing device in my 24-disk SAS enclosure.

    I have found sg_ses --index 7 --set=locate /dev/sg24 which is supposed to identify slot 7.

    But how do I figure out which slot/index /dev/sdh is?

    This is not obvious as Linux does not name /dev/sdX after the slot, but after the sequence it was detected. Think what happens if slot 1 is empty at boot, but is filled later.

    Edit:

    The controller is a SAS2008.

    • phemmer
      phemmer about 12 years
      This is completely dependent upon your array controller hardware. You need to tell us what that is.
    • Admin
      Admin almost 12 years
      I checked my system (Sles11 sp2), the sg_ses doesn't have a --index and --set as input params, and there is no /sys/class/enclosure* in the sles11 sp2. What's your Linux environment? Did you install other utilities in the OS by yourself?
    • Ole Tange
      Ole Tange almost 12 years
      Debian Stable: Linux server 3.2.0-0.bpo.1-amd64
  • Ole Tange
    Ole Tange about 12 years
    Thanks for pointing me to /sys. As you can see the solution is a bit more involved.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' about 12 years
    @OleTange Ok. You should post your solution as an answer, please don't post answers in questions as they are not easily visible to future visitors. It's OK to ask and answer your own question.. I'll leave my answer because it shows the general approach, but you should accept your own answer (when the system lets you, there's a delay) since it's more complete for this particular task on this particular enclosure.
  • terdon
    terdon about 9 years
    Hi and welcome to the site. We like answers to be more comprehensive here. Could you edit your answer and provide an example of how the OP could use this tool to achieve their objective? As it stands, it is not an answer but a comment.
  • Zepps
    Zepps about 9 years
    Look, if I have a tool and know where I can find this tool, whats wrong with answer? I definitely know that edited answer is wrong, since initially author of this question requested a locate led. But, anyway, this answer provide much easiest way to made led on enclosure blink than previous.