Linux command – lsscsi

Loading

硬碟的相關資訊可以去哪裡看,除了 fdisk 外,我們可以透過 lsscsi 來看比較詳細的資訊.

測試環境為 Ubuntu 16.04 x86-64 (虛擬機 sda , sdb 與 sr0 )

root@ubuntu:~# lsscsi
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda 
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb 
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0

輸出的第一段 [H:C:T:L] 所代表意思如下:

  • H : SCSI host id
  • C : SCSI channel
  • T : Target Number
  • L : LUN

下面是幾個常用的參數

–classic , -c
generate output similar to ‘cat /proc/scsi/scsi’

root@ubuntu:~# lsscsi -c
Attached devices: 
Host: scsi2 Channel: 00 Target: 00 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0 
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Target: 01 Lun: 00
  Vendor: VMware,  Model: VMware Virtual S Rev: 1.0 
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi4 Channel: 00 Target: 00 Lun: 00
  Vendor: NECVMWar Model: VMware SATA CD01 Rev: 1.00
  Type:   CD-ROM                           ANSI SCSI revision: 05

–device , -d
show device node’s major and minor numbers

root@ubuntu:~# lsscsi -d
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda [8:0]
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb [8:16]
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0 [11:0]

–generic, -g
show scsi generic device node name

root@ubuntu:~# lsscsi -g
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda   /dev/sg0 
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb   /dev/sg1 
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0   /dev/sg2 

–hosts , -H
rather than list SCSI devices (logical units), list SCSI hosts instead

root@ubuntu:~# lsscsi -H
[0]    ata_piix      
[1]    ata_piix      
[2]    mptspi        
[3]    ahci          
[4]    ahci          
[5]    ahci          
[6]    ahci          
[7]    ahci          
[8]    ahci          
[9]    ahci          
[10]    ahci          
[11]    ahci          
[12]    ahci          
[13]    ahci    

–kname , -k
show kernel name (as found in sysfs) instead of device node name (as found in the /dev directory)

root@ubuntu:~# lsscsi -k
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda 
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb 
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0 

–list , -L
show = pairs, one per line, indented by two or more spaces

root@ubuntu:~# lsscsi -L
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda 
  device_blocked=0
  iocounterbits=32
  iodone_cnt=0x1bc72
  ioerr_cnt=0x6
  iorequest_cnt=0x1bc72
  queue_depth=32
  queue_type=simple
  scsi_level=3
  state=running
  timeout=30
  type=0
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb 
  device_blocked=0
  iocounterbits=32
  iodone_cnt=0x8c
  ioerr_cnt=0x6
  iorequest_cnt=0x8c
  queue_depth=32
  queue_type=simple
  scsi_level=3
  state=running
  timeout=30
  type=0
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0 
  device_blocked=0
  iocounterbits=32
  iodone_cnt=0xa48
  ioerr_cnt=0x3
  iorequest_cnt=0xa5d
  queue_depth=1
  queue_type=none
  scsi_level=6
  state=running
  timeout=30
  type=5

–long , -l
show = pairs, several to a line. can be used multiple times for more output and different format.

root@ubuntu:~# lsscsi -l
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda 
  state=running queue_depth=32 scsi_level=3 type=0 device_blocked=0 timeout=30
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb 
  state=running queue_depth=32 scsi_level=3 type=0 device_blocked=0 timeout=30
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0 
  state=running queue_depth=1 scsi_level=6 type=5 device_blocked=0 timeout=30

–lunhex , -x
show the LUN part of the tuple as hex following T10 (SAM-5) conventions.

root@ubuntu:~# lsscsi -x
[2:0:0:0x0000]              disk    VMware,  VMware Virtual S 1.0   /dev/sda 
[2:0:1:0x0000]              disk    VMware,  VMware Virtual S 1.0   /dev/sdb 
[4:0:0:0x0000]              cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0 

–protection , -p
show protection information (T10-DIF).

root@ubuntu:~# lsscsi -p
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda   -          none            
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb   -          none            
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0   -          none            

–protmode , -P
show negotiated protection information mode

root@ubuntu:~# lsscsi -P
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda   -   
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb   -   
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0   - 

–scsi_id , -i
show udev derived information in /dev/disk/by-id/ directory

root@ubuntu:~# lsscsi -i
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda   -
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb   -
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0   -

–size , -s
show disk size in human readable form

root@ubuntu:~# lsscsi -s
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda   21.4GB
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb   5.36GB
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0        -

–sysfsroot=PATH , -y
Uses PATH as sysfs mount point (default sysfs mount point is ‘/sys’)

root@ubuntu:~# lsscsi -y /sys/
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda 
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb 
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0 

–transport , -t
show transport information. If ‘–hosts’ not given then this will be for targets. If ‘–hosts’ is given then this will be for initiators (i.e. hosts). More information shown when used with ‘–list’.

root@ubuntu:~# lsscsi -t
[2:0:0:0]    disk    spi:0                           /dev/sda 
[2:0:1:0]    disk    spi:1                           /dev/sdb 
[4:0:0:0]    cd/dvd  sata:                           /dev/sr0 

–verbose , -v
increase verbosity of output. May be used multiple times to further increase verbosity.

root@ubuntu:~# lsscsi -v
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda 
  dir: /sys/bus/scsi/devices/2:0:0:0  [/sys/devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0]
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb 
  dir: /sys/bus/scsi/devices/2:0:1:0  [/sys/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0]
[4:0:0:0]    cd/dvd  NECVMWar VMware SATA CD01 1.00  /dev/sr0 
  dir: /sys/bus/scsi/devices/4:0:0:0  [/sys/devices/pci0000:00/0000:00:11.0/0000:02:05.0/ata4/host4/target4:0:0/4:0:0:0]

–wwn , -w
show the WWN for disks in the place of the manufacturer, model and revision

root@ubuntu:~# lsscsi -w
[2:0:0:0]    disk                                    /dev/sda 
[2:0:1:0]    disk                                    /dev/sdb 
[4:0:0:0]    cd/dvd                                  /dev/sr0 
沒有解決問題,試試搜尋本站其他內容

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料