Linux lsscsi 查看所有SCSI/SATA硬盘和CD/DVD驱动器

时间:2019-11-20 08:53:11  来源:igfitidea点击:

在Debian或Ubuntu Linux中,如何查看硬盘信息?
在Unix中,如何扫描所有的SCSI硬盘和SATA盘?

安装lsscsi

Debian/Ubuntu Linux用户执行以下apt-get命令来安装lsscsi:

# apt-get install lsscsi

RHEL/CentOS Linux用户执行以下yum命令:

# yum install lsscsi

如何使用lsscsi命令?

执行以下命令:

$ lsscsi

输出示例:

[0:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda 
[2:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0 

lsscsi命令示例

查看隐藏在RAID阵列后面的通用设备节点名称

$ lsscsi -d

查看磁盘大小:

$ lsscsi -s

使用-l选项查看设备详细信息:

$ lsscsi -l

输出示例:

[0:0:0:0]    disk    ATA      TOSHIBA MK5061GS MF00  /dev/sda
  state=running queue_depth=31 scsi_level=6 type=0 device_blocked=0 timeout=30
[1:0:0:0]    cd/dvd  MATSHITA BD-RE UJ232A     1.10  /dev/sr0
  state=running queue_depth=1 scsi_level=6 type=5 device_blocked=0 timeout=30
[2:0:0:0]    disk    ATA      ST9500420ASG     0004  /dev/sdb
  state=running queue_depth=31 scsi_level=6 type=0 device_blocked=0 timeout=30

lsscsi命令选项

下面是lsscsi命令支持的所有选项:

--classic|-c    alternate output similar to 'cat /proc/scsi/scsi'
    --device|-d     show device node's major + minor numbers
    --generic|-g    show scsi generic device name
    --help|-h       this usage information
    --hosts|-H      lists scsi hosts rather than scsi devices
    --kname|-k      show kernel name instead of device node name
    --list|-L       additional information output one
                    attribute=value per line
    --long|-l       additional information output
    --transport|-t  transport information for target or, if '--hosts'
                    given, for initiator
    --verbose|-v    output path names where data is found
    --version|-V    output version string and exit
           filter output list (def: '- - - -' (all))

关于/proc/scsi/scsi的说明

如果不想安装lsscsi命令,
可以尝试读取文件/proc/scsi/scsi

$ cat /proc/scsi/scsi

输出示例:

Attached devices:
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: Slimtype Model: COMBO SSC-2485K  Rev: 5K06
  Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi4 Channel: 00 Id: 00 Lun: 00
  Vendor: Adaptec  Model: raid1-a          Rev: V1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi4 Channel: 01 Id: 00 Lun: 00
  Vendor: FUJITSU  Model: MAX3073RC        Rev: 0104
  Type:   Direct-Access                    ANSI  SCSI revision: 03
Host: scsi4 Channel: 01 Id: 01 Lun: 00
  Vendor: FUJITSU  Model: MAX3073RC        Rev: 0104
  Type:   Direct-Access                    ANSI  SCSI revision: 03