Linux Disk Module

Loading

Linux 下要如何知道這一顆硬碟使用什麼模組 Module,有下面幾種方式來確認.

測試環境為 Ubuntu 16.04 x86_64 虛擬機.

lspci

root@ubuntu:~# lspci -v
...
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
...
root@ubuntu:~# lspci -s 00:10.0 -v
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
	Subsystem: VMware LSI Logic Parallel SCSI Controller
	Flags: bus master, medium devsel, latency 64, IRQ 17
	I/O ports at 1400 [size=256]
	Memory at feba0000 (64-bit, non-prefetchable) [size=128K]
	Memory at febc0000 (64-bit, non-prefetchable) [size=128K]
	[virtual] Expansion ROM at c0008000 [disabled] [size=16K]
	Capabilities: [f8] PCI Advanced Features
	Kernel driver in use: mptspi
	Kernel modules: mptspi

透過指令 # lspci -v 就可以查出 SCSI storage controller 的 Kernel driver 是 mptspi ,但是還是不能很直覺的查出哪一顆硬碟對應哪一個模組.

lshw

root@ubuntu:~# apt install lshw
root@ubuntu:~# lshw -class storage
  *-scsi
       description: SCSI storage controller
       product: 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI
       vendor: LSI Logic / Symbios Logic
       physical id: 10
       bus info: pci@0000:00:10.0
       logical name: scsi2
       version: 01
       width: 64 bits
       clock: 33MHz
       capabilities: scsi bus_master cap_list rom scsi-host
       configuration: driver=mptspi latency=64 maxlatency=255 mingnt=6
       resources: irq:17 ioport:1400(size=256) memory:feba0000-febbffff memory:febc0000-febdffff memory:c0008000-c000bfff

透過指令 # lshw -class storage 就可以查出 SCSI storage controller 的 configuration: driver 是 mptspi ,但是還是不能很直覺的查出哪一顆硬碟對應哪一個模組.

hwinfo

root@ubuntu:~# apt install hwinfo
root@ubuntu:~# hwinfo --block
55: SCSI 200.0: 10600 Disk                                      
  [Created at block.245]
  Unique ID: R7kM.nTPZhtpisM9
  Parent ID: 37TO.741NuwlerHD
  SysFS ID: /class/block/sda
  SysFS BusID: 2:0:0:0
  SysFS Device Link: /devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0
  Hardware Class: disk
  Model: "VMware Virtual S"
  Vendor: "VMware,"
  Device: "VMware Virtual S"
  Revision: "1.0"
  Driver: "mptspi", "sd"
  Driver Modules: "mptspi"
  Device File: /dev/sda (/dev/sg0)
  Device Files: /dev/sda, /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0
  Device Number: block 8:0-8:15 (char 21:0)
  BIOS id: 0x80
  Geometry (Logical): CHS 2610/255/63
  Size: 41943040 sectors a 512 bytes
  Capacity: 20 GB (21474836480 bytes)
  Config Status: cfg=new, avail=yes, need=no, active=unknown
  Attached to: #14 (SCSI storage controller)

透過指令 # hwinfo –block 就可以查出 SCSI 200.0: 10600 Disk 的 Driver Modules: 是 mptspi ,而且在 SysFS ID 與 Device File 有顯示這是哪一顆硬碟.

udevadm

root@ubuntu:~# udevadm info -a -n /dev/sda

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0/block/sda':
    KERNEL=="sda"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{alignment_offset}=="0"
    ATTR{capability}=="50"
    ATTR{discard_alignment}=="0"
    ATTR{events}==""
    ATTR{events_async}==""
    ATTR{events_poll_msecs}=="-1"
    ATTR{ext_range}=="256"
    ATTR{inflight}=="       0        0"
    ATTR{range}=="16"
    ATTR{removable}=="0"
    ATTR{ro}=="0"
    ATTR{size}=="41943040"
    ATTR{stat}=="   93942       57  2077938    64760     5006    14944   770728    84672        0    37372   149132"

  looking at parent device '/devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0':
    KERNELS=="2:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{device_blocked}=="0"
    ATTRS{device_busy}=="0"
    ATTRS{dh_state}=="detached"
    ATTRS{eh_timeout}=="10"
    ATTRS{evt_capacity_change_reported}=="0"
    ATTRS{evt_inquiry_change_reported}=="0"
    ATTRS{evt_lun_change_reported}=="0"
    ATTRS{evt_media_change}=="0"
    ATTRS{evt_mode_parameter_change_reported}=="0"
    ATTRS{evt_soft_threshold_reached}=="0"
    ATTRS{inquiry}==""
    ATTRS{iocounterbits}=="32"
    ATTRS{iodone_cnt}=="0x182e7"
    ATTRS{ioerr_cnt}=="0x6"
    ATTRS{iorequest_cnt}=="0x182e7"
    ATTRS{model}=="VMware Virtual S"
    ATTRS{queue_depth}=="32"
    ATTRS{queue_ramp_up_period}=="120000"
    ATTRS{queue_type}=="simple"
    ATTRS{rev}=="1.0 "
    ATTRS{scsi_level}=="3"
    ATTRS{state}=="running"
    ATTRS{timeout}=="30"
    ATTRS{type}=="0"
    ATTRS{vendor}=="VMware, "

  looking at parent device '/devices/pci0000:00/0000:00:10.0/host2/target2:0:0':
    KERNELS=="target2:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:10.0/host2':
    KERNELS=="host2"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:10.0':
    KERNELS=="0000:00:10.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="mptspi"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x010000"
    ATTRS{config}==""
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{d3cold_allowed}=="0"
    ATTRS{device}=="0x0030"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="17"
    ATTRS{local_cpulist}=="0"
    ATTRS{local_cpus}=="00000000,00000000,00000000,00000001"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{subsystem_device}=="0x1976"
    ATTRS{subsystem_vendor}=="0x15ad"
    ATTRS{vendor}=="0x1000"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

#udevadm 的使用更直覺,可以直接指定硬碟,在 DRIVERS 顯示為 mptspi.

/sys

如果你的環境都沒有上述的工具,透過檢視 /sys 也可以查出硬碟使用了什麼模組 Module.

root@ubuntu:~# ll /sys/block/sda
lrwxrwxrwx 1 root root 0 Jan 15 22:57 /sys/block/sda -> ../devices/pci0000:00/0000:00:10.0/host2/target2:0:0/2:0:0:0/block/sda/
root@ubuntu:~# find /sys|grep -i drivers|grep 0000:00:10.0
/sys/bus/pci/drivers/mptspi/0000:00:10.0

關於 /sys 目錄 (從 2.6 核心開始硬體的系統資訊以更階層式目錄的架構來存放)可以參考 https://benjr.tw/20857

沒有解決問題,試試搜尋本站其他內容

發佈留言

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

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