Linux

如何將 /dev/sd 設備與它們所代表的硬體相關聯?

  • February 27, 2017

驅動器開始出現故障,我只能通過/dev/sdb設備文件名稱知道該設備。我可以使用哪些方法將該設備文件與實際硬體設備相關聯,以了解要物理替換哪個驅動器?

**獎勵:**如果我在此安裝中沒有/dev/disk/及其子目錄怎麼辦?(遺憾的是,我沒有)

您可以查看/sys/block

-bash-3.2$ ls -ld /sys/block/sd*/device
lrwxrwxrwx 1 root root 0 Jun  8 21:09 /sys/block/sda/device -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0
lrwxrwxrwx 1 root root 0 Jun  8 21:10 /sys/block/sdb/device -> ../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0
lrwxrwxrwx 1 root root 0 Jun  8 21:10 /sys/block/sdc/device -> ../../devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0
lrwxrwxrwx 1 root root 0 Jun  8 21:10 /sys/block/sdd/device -> ../../devices/pci0000:00/0000:00:1f.2/host3/target3:0:0/3:0:0:0

或者如果你沒有/sys,你可以看看/proc/scsi/scsi

-bash-3.2$ cat /proc/scsi/scsi 
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
 Vendor: ATA      Model: ST31000340AS     Rev: SD1A
 Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi1 Channel: 00 Id: 00 Lun: 00
 Vendor: ATA      Model: ST31000340AS     Rev: SD1A
 Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
 Vendor: ATA      Model: ST31000340AS     Rev: SD1A
 Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi3 Channel: 00 Id: 00 Lun: 00
 Vendor: ATA      Model: ST31000340AS     Rev: SD1A
 Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi4 Channel: 00 Id: 00 Lun: 00
 Vendor: PepperC  Model: Virtual Disc 1   Rev: 0.01
 Type:   CD-ROM                           ANSI SCSI revision: 03

引用自:https://unix.stackexchange.com/questions/40351