Périphériques bloc

Mise à jour Debian : 10.9 / Buster

Abréviations :

Sommaire

1 - Présentation

$ sudo dmesg -t |tail -1
sd 3:0:0:0: [sdb] Attached SCSI disk
$ udevadm monitor -k -s block
monitor will print the received events for:
KERNEL - the kernel uevent

KERNEL[2567.529266] add /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host3/target3:0:0/3:0:0:0/block/sdb (block)
KERNEL[2567.529358] add /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host3/target3:0:0/3:0:0:0/block/sdb/sdb1 (block)

2 - Propriétés

2.1 - lsblk

$ lsblk -d
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 447,1G 0 disk
sdb 8:16 0 232,9G 0 disk
mmcblk0 179:0 0 15G 0 disk
nvme0n1 259:0 0 931,5G 0 disk
$ lsblk -d -P -O /dev/nvme0n1
NAME="nvme0n1" KNAME="nvme0n1" PATH="/dev/nvme0n1" MAJ:MIN="259:0" FSAVAIL="" FSSIZE="" FSTYPE="" FSUSED="" FSUSE%="" \
MOUNTPOINT="" LABEL="" UUID="" PTUUID="0fce722d-c992-4e4d-990a-ca32c3344407" PTTYPE="gpt" PARTTYPE="" PARTLABEL="" PARTUUID="" PARTFLAGS="" \
RA="128" RO="0" RM="0" HOTPLUG="0" MODEL="Samsung SSD 980 1TB" SERIAL="S649NJ0R206964F" SIZE="931,5G" STATE="live" \
OWNER="" GROUP="" MODE="brw-rw----" ALIGNMENT="0" MIN-IO="512" OPT-IO="0" PHY-SEC="512" LOG-SEC="512" ROTA="0" SCHED="none" \
RQ-SIZE="1023" TYPE="disk" DISC-ALN="0" DISC-GRAN="512B" DISC-MAX="2T" DISC-ZERO="0" WSAME="0B" WWN="eui.002538d211401be9" RAND="0" PKNAME="" HCTL="" \
TRAN="nvme" SUBSYSTEMS="block:nvme:pci" REV="" VENDOR="" ZONED="none
$ lsblk -d -o name,model,serial,size,tran 
NAME MODEL SERIAL SIZE TRAN
sda KINGSTON_SHSS37A480G 50026B767A012C69 447,1G sata
sdb RTL9210_NVME 012345678902 232,9G usb
sdc Storage_Device 121220160204 29,7G usb
mmcblk0 0x12800008 15G
nvme0n1 Samsung SSD 980 1TB S649NJ0R206964F 931,5G nvme

2.2 - lssci

List SCSI devices or hosts, followed by NVMe namespaces or controllers.
Many storage devices (e.g. SATA disks and USB attached storage) use SCSI
command sets and hence are also listed by this utility.
$ sudo aptitude install lssci
$ lsscsi -s
[2:0:0:0] disk ATA KINGSTON SHSS37A 02.H /dev/sda 480GB
[3:0:0:0] disk Generic MassStorageClass 0904 /dev/sdb -
[4:0:0:0] disk USB Flash Disk 1100 /dev/sdc 2.00GB
[5:0:0:0] disk KINGSTON SHSS37A240G 0 /dev/sdd 240GB
[6:0:0:0] disk WDC WD75 00BPKX-00HPJT0 /dev/sde 750GB
[N:0:4:1] disk Samsung SSD 970 EVO 250GB__1 /dev/nvme0n1 250GB

3 - Adresse sur le bus pci

Plusieurs méthodes permettent de déterminer l'adresse du périphérique (en fait de son contrôleur) sur le bus pci. Les adresses sur le bus pci sont de la forme bus:slot.fonction

3.1 - A partir de l'identifiant (nom) de périphérique

$ ls -log /sys/class/block/nvme0n1
lrwxrwxrwx 1 0 juin 6 15:40 nvme0n1 -> ../../devices/pci0000:00/0000:00:1d.0/0000:01:00.0/nvme/nvme0/nvme0n1
$ ls -log /sys/class/block/nvme0n1 |sed -e 's/^.*0000://' -e  's/\/.*$//'
01:00.0

3.2 - A partir de l'identifiant scsi

Connaissant l'identifiant scsi d'un périphérique, l'option -v de lsscsi affiche son adresse sur le bus pci. Dans l'exemple ci-dessous, on recherche l'adresse du périphérique /dev/nvme0n1

$ lsscsi |grep nvme0n1
[N:0:5:1] disk Samsung SSD 980 1TB__1 /dev/nvme0n1
$ lsscsi -v N
[N:0:5:1] dsk/nvm Samsung SSD 980 1TB__1 /dev/nvme0n1
dir: /sys/class/nvme/nvme0/nvme0n1 [/sys/devices/pci0000:00/0000:00:1d.0/0000:01:00.0/nvme/nvme0/nvme0n1]

4 - Contrôleur pci et pilote

$ lsblk -d -o name,model,tran
NAME MODEL TRAN
sda KINGSTON_SHSS37A480G sata
sdb RTL9210_NVME usb
mmcblk0
nvme0n1 Samsung SSD 980 1TB nvme
$ lsscsi -t
[2:0:0:0] disk sata:50026b767a012c69 /dev/sda
[3:0:0:0] disk usb:2-2:1.0 /dev/sdb
[N:0:5:1] disk pcie 0x144d:0xa801 /dev/nvme0n1
$ ADRESSE=$(ls -log /sys/class/block/nvme0n1 |sed -e 's/^.*0000://' -e  's/\/.*$//')
$ lspci -k -s $(ADRESSE)
01:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd Device a809
Subsystem: Samsung Electronics Co Ltd Device a801
Kernel driver in use: nvme
Kernel modules: nvme
$ lspci -k -s $(ls -log /sys/class/block/sda |sed -e 's/^.*0000://' -e  's/\/.*$//')
00:17.0 SATA controller: Intel Corporation Cannon Point-LP SATA Controller [AHCI Mode] (rev 30)
Subsystem: Intel Corporation Cannon Point-LP SATA Controller [AHCI Mode]
Kernel driver in use: ahci
Kernel modules: ahci
00:14.0 USB controller: Intel Corporation Cannon Point-LP USB 3.1 xHCI Controller (rev 30)
Subsystem: Intel Corporation Cannon Point-LP USB 3.1 xHCI Controller
Kernel driver in use: xhci_hcd
Kernel modules: xhci_pci
$ lspci -k -s $(ls -log /sys/class/block/mmcblk0 |sed -e 's/^.*0000://' -e  's/\/.*$//')
02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS522A PCI Express Card Reader (rev 01)
Subsystem: Intel Corporation RTS522A PCI Express Card Reader
Kernel driver in use: rtsx_pci
Kernel modules: rtsx_pci