我有一块 U.2 SSD,在 lsblk 中显示为 nvme1n1:
root@eris:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 3.6T 0 disk
├─nvme0n1p1 259:1 0 476M 0 part /boot/efi
├─nvme0n1p2 259:2 0 38.1G 0 part /
└─nvme0n1p3 259:3 0 3.6T 0 part /data
nvme1n1 259:4 0 3.5T 0 disk
查看 dmesg,我可以看到:
root@eris:~# dmesg | grep -i nvme
[ 0.997417] nvme nvme0: pci function 0000:01:00.0
[ 0.997448] nvme nvme1: pci function 0000:04:00.0
...
这匹配:
root@eris:~# ll /sys/bus/pci/drivers/nvme | grep 04:00.0
lrwxrwxrwx 1 root root 0 Jul 4 14:41 0000:04:00.0 -> ../../../../devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:02.0/0000:04:00.0
这是我稍后需要知道的事情。
我的问题是,有没有更简单的方法从/dev/nvme1n1
到/sys/bus/pci/drivers/nvme/0000:04:00.0
?
答案1
是的,
ls -la /dev/disk/by-path
# or
cd /sys/block
for i in nvme*; do
echo "$i is `cat $i/device/address`"
done