It's a useful tool, list SCSI devices, scsi hosts and their attributes. It uses information in sysfs to list scsi devices(or host), attached to the system. Because most users have permissions to read sysfs, there is no permission for users.
In addition to the device list, lsscsi can also show the relationship between a device's primary node name, its SCSI generic node name and its kernel name.
Default output, list devices
# lsscsi -k [0:0:0:0] disk ServeRA 8k-l Mirror V1.0 /dev/sda [0:1:0:0] disk IBM-ESXS GNA300C3ESTT0Z N BH0G - [0:1:1:0] disk IBM-ESXS ST3300555SS BA33 - [0:3:0:0] enclosu IBM-ESXS VSC7160 1.06 - [2:0:0:0] cd/dvd MATSHITA UJDA770 DVD/CDRW 1.21 /dev/sr0 [3:0:0:1] disk IBM DCS9550 4.03 /dev/sdb [3:0:0:2] disk IBM DCS9550 4.03 /dev/sdc [3:0:0:3] disk IBM DCS9550 4.03 /dev/sdd [3:0:0:4] disk IBM DCS9550 4.03 /dev/sde [3:0:0:9] disk IBM DCS9550 4.03 /dev/sdf [3:0:0:10] disk IBM DCS9550 4.03 /dev/sdg ...
The first entry on each line is the scsi_host,channel,target_number,LUN
[H:C:T:L] H == hostadapter id (first one being 0) C == SCSI channel on hostadapter (first one being 0) T == ID L == LUN (first one being 0)
Filter device by specify device <h:c:t:l>, default is all
# lsscsi 4:0:3:16 [4:0:3:16] disk IBM DCS9550 4.03 /dev/sdbm
Wild card use case for Filter, the colons don't have to be present
# lsscsi 4 0 0 [4:0:0:1] disk IBM DCS9550 4.03 /dev/sdah [4:0:0:2] disk IBM DCS9550 4.03 /dev/sdai ... # lsscsi 4 0 0 ? [4:0:0:1] disk IBM DCS9550 4.03 /dev/sdah [4:0:0:2] disk IBM DCS9550 4.03 /dev/sdai ... Note: '*' is a bit different # lsscsi 4 0 0:* [4:0:0:1] disk IBM DCS9550 4.03 /dev/sdah [4:0:0:2] disk IBM DCS9550 4.03 /dev/sdai ... # lsscsi 4 0 0 - [4:0:0:1] disk IBM DCS9550 4.03 /dev/sdah [4:0:0:2] disk IBM DCS9550 4.03 /dev/sdai ... To list host 4 all devices # lsscsi 4 [4:0:0:1] disk IBM DCS9550 4.03 /dev/sdah [4:0:0:2] disk IBM DCS9550 4.03 /dev/sdai ...
List device in long, addition information output
# lsscsi -l [0:0:0:0] disk ServeRA 8k-l Mirror V1.0 /dev/sda state=running queue_depth=238 scsi_level=3 type=0 device_blocked=0 timeout=45 [0:1:0:0] disk IBM-ESXS GNA300C3ESTT0Z N BH0G - state=running queue_depth=1 scsi_level=6 type=0 device_blocked=0 timeout=0 [0:1:1:0] disk IBM-ESXS ST3300555SS BA33 - state=running queue_depth=1 scsi_level=6 type=0 device_blocked=0 timeout=0 [0:3:0:0] enclosu IBM-ESXS VSC7160 1.06 - state=running queue_depth=1 scsi_level=4 type=13 device_blocked=0 timeout=0 [2:0:0:0] cd/dvd MATSHITA UJDA770 DVD/CDRW 1.21 /dev/sr0 state=running queue_depth=1 scsi_level=6 type=5 device_blocked=0 timeout=30 [3:0:0:1] disk IBM DCS9550 4.03 /dev/sdb ...
List device major and minor numbers
# lsscsi -d [0:0:0:0] disk ServeRA 8k-l Mirror V1.0 /dev/sda [8:0] [0:1:0:0] disk IBM-ESXS GNA300C3ESTT0Z N BH0G - [0:1:1:0] disk IBM-ESXS ST3300555SS BA33 - [0:3:0:0] enclosu IBM-ESXS VSC7160 1.06 - [2:0:0:0] cd/dvd MATSHITA UJDA770 DVD/CDRW 1.21 /dev/sr0 [11:0] [3:0:0:1] disk IBM DCS9550 4.03 /dev/sdb [8:16]
List device with corresponding scsi generic device name:
# lsscsi -g [0:0:0:0] disk ServeRA 8k-l Mirror V1.0 /dev/sda /dev/sg0 [0:1:0:0] disk IBM-ESXS GNA300C3ESTT0Z N BH0G - /dev/sg1 [0:1:1:0] disk IBM-ESXS ST3300555SS BA33 - /dev/sg2 [0:3:0:0] enclosu IBM-ESXS VSC7160 1.06 - /dev/sg3 [2:0:0:0] cd/dvd MATSHITA UJDA770 DVD/CDRW 1.21 /dev/sr0 /dev/sg4 [3:0:0:1] disk IBM DCS9550 4.03 /dev/sdb /dev/sg5 [3:0:0:2] disk IBM DCS9550 4.03 /dev/sdc /dev/sg6 [3:0:0:3] disk IBM DCS9550 4.03 /dev/sdd /dev/sg7
List host information, plus verbose output and long option for additional attributes
# lsscsi -Hlv [0] aacraid cmd_per_lun=256 host_busy=0 sg_tablesize=65 unchecked_isa_dma=0 dir: /sys/class/scsi_host//host0 device dir: /sys/devices/pci0000:00/0000:00:03.0/0000:04:00.0/host0 [1] ata_piix cmd_per_lun=1 host_busy=0 sg_tablesize=128 unchecked_isa_dma=0 dir: /sys/class/scsi_host//host1 device dir: /sys/devices/pci0000:00/0000:00:1f.2/host1 [2] ata_piix cmd_per_lun=1 host_busy=0 sg_tablesize=128 unchecked_isa_dma=0 dir: /sys/class/scsi_host//host2 device dir: /sys/devices/pci0000:00/0000:00:1f.2/host2 [3] qla2xxx cmd_per_lun=3 host_busy=0 sg_tablesize=1024 unchecked_isa_dma=0 dir: /sys/class/scsi_host//host3 device dir: /sys/devices/pci0000:00/0000:00:04.0/0000:10:00.0/host3 [4] qla2xxx cmd_per_lun=3 host_busy=0 sg_tablesize=1024 unchecked_isa_dma=0 dir: /sys/class/scsi_host//host4 device dir: /sys/devices/pci0000:00/0000:00:04.0/0000:10:00.1/host4
List transporation device info
# lsscsi -Ht [0] aacraid [1] ata_piix ata: [2] ata_piix ata: [3] qla2xxx fc:0x2100001b32175a9f,0x010900 [4] qla2xxx fc:0x2101001b32375a9f,0x010900
In above case, fc port identifier shown in the output.
# lsscsi -g -t [0:0:0:0] disk /dev/sda /dev/sg0 [0:1:0:0] disk - /dev/sg1 [0:1:1:0] disk - /dev/sg2 [0:3:0:0] enclosu - /dev/sg3 [2:0:0:0] cd/dvd ata: /dev/sr0 /dev/sg4 [3:0:0:1] disk fc:0x21000001ff040d62,0x011000 /dev/sdb /dev/sg5 [3:0:0:2] disk fc:0x21000001ff040d62,0x011000 /dev/sdc /dev/sg6 ...
In the case about, FC port identifier shown in output.
Same way you can do with ISCSI,SATA, SAS, USB and SPI etc..
There is another tool called systool, which uses API of libsys to get sysfs information