Linux lsscsi - list SCSI devices (or hosts) and their attributes

70 篇文章 ¥9.90 ¥99.00
lsscsi是一个实用工具,用于列出连接到系统的SCSI设备和主机及其属性。它利用sysfs中的信息来显示设备或主机。默认情况下,它会列出每个条目的scsi_host、通道、目标号和LUN。此外,lsscsi还能显示设备的主要节点名、SCSI通用节点名和内核名称之间的关系。用户可以使用过滤选项来定位特定设备,并获取详细信息,如主次设备号、传输设备信息等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值