3

Under the /sys/class/scsi_device folder I have the following:

 root@linux01:/sys/class/scsi_device # ls
 1:0:0:0  2:0:0:0  2:0:1:0  3:0:0:0

How can I know how each of these devices is related to the disk?

For example, how can I determine if device 2:0:1:0 is disk /dev/sdb?

root@linux01:/sys/class/scsi_device # sfdisk -s
/dev/sdb:  15728640
/dev/sdc: 524288000
/dev/sda:    153600
[...]
# more /etc/redhat-release  ( Linux VM machine ) 
Red Hat Enterprise Linux Server release 6.5 (Santiago)
4

An easy way to get the correspondence is to look at the device/block subdirectory in the /sys hierarchy:

# ls -1d /sys/class/scsi_device/*/device/block/*
/sys/class/scsi_device/1:0:0:0/device/block/sr0
/sys/class/scsi_device/2:0:0:0/device/block/sda
/sys/class/scsi_device/2:0:1:0/device/block/sdb
/sys/class/scsi_device/2:0:2:0/device/block/sdc
/sys/class/scsi_device/2:0:3:0/device/block/sdd
/sys/class/scsi_device/2:0:4:0/device/block/sde
/sys/class/scsi_device/2:0:5:0/device/block/sdf

The directory name in there correspond to the block device name in /dev.

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.