4

lsscsi tells me that I have a number of disks and enclosures.

I can use $ ls /sys/class/enclosure/6:0:10:0/ArrayDevice*/device/scsi/disk to get a listing of all the scsi addresses of disks under the 6:0:10:0 enclosure.

I can correlate that list with lsscsi output to see where each disk is.

But surely I don't need to write a script to automate this. Is there a tool like udevadm or sg_ses or something that can do this task for me?

0

You can install sg3_utils package. lsssci command will help you identify the bus id of the enclosure. You could query sg_ses -p 7 /dev/bsg/<busid>

here is an example:

[0:0:64:0]   disk    HGST     HUHAJLGALLLAAAAA  A384  /dev/sdbl
[0:0:65:0]   enclosu HGST     4U60G2_STOR_ENCL 0101  -

Once you have the bus ID:

sg_ses --page=7 /dev/bsg/0:0:65:0
0

Is it an answer?

[root@hard-3 ~]# ls -ldF /sys/block/sda/device/enclosure_device\:0
lrwxrwxrwx. 1 root root 0 июл 26 18:25 /sys/block/sda/device/enclosure_device:0 -> ../../../../../../port-1:0:4/end_device-1:0:4/target1:0:1/1:0:1:0/enclosure/1:0:1:0/0/
[root@hard-3 ~]# 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.