问题: 描述什么/dev/disk/by-path
?这在哪里记录?
/dev/disk/by-
浏览到目前为止我所了解的文件夹中显示的内容的含义,我想知道它是否正确?
by-id
→ 基于硬件设备的序列号by-label
→ 为该磁盘手动设置的任何名称by-path
→?!by-uuid
→ 通用唯一标识符:一个唯一创建的字符串来标识磁盘[通过系统完成]
[注:我在 GNU/Linux Debian 7、Crunchbang 上工作,如果这很重要……]
答案1
Mountpoint/dev
是devtmpfs
文件系统并由其udev
完全管理。所以对于细节我们必须去udev
配置。
2 个 udev 规则通常处理这个问题
$ grep -ri '/dev/disk' /usr/lib/udev/rules.d/
/usr/lib/udev/rules.d/60-persistent-storage.rules:# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path}
/usr/lib/udev/rules.d/13-dm-disk.rules:# These rules create symlinks in /dev/disk directory.
60-persistent-storage.rules
提及
# by-path (parent device path)
ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id"
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
最后ID_PATH
是基于物理硬件位置/连接的设备的唯一标识符(例如 ID_PATH=pci-0000:02:04.0-scsi-0:0:0:0)。
ID_PATH
来自名为path_id
(例如 for /sys/block/sdc
)的内置 udev 程序
$ udevadm test-builtin path_id /sys/block/sdc
calling: test-builtin
=== trie on-disk ===
tool version: 204
file size: 5632867 bytes
header size 80 bytes
strings 1260755 bytes
nodes 4372032 bytes
load module index
ID_PATH=pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0
ID_PATH_TAG=pci-0000_00_14_0-usb-0_1_1_0-scsi-0_0_0_0
我们可以将其与
drwxr-xr-x 6 root root 0 Aug 15 02:30 /sys/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/
最后,如果有人对细节感兴趣,请查阅源代码
答案2
by-path
是访问磁盘的方式。对于本地磁盘,by-path
是磁盘设备的 pci 路径。对于 iSCSI 磁盘,by-path
是远程磁盘设备的 iSCSI 路径。
系统可以用来by-path
定位磁盘设备!
答案3
by-id - creates a unique name depending on the hardware serial number.
by-label - almost every file system type can have a label.
All your volumes that have one are listed in the /dev/disk/by-label directory.
by-path - creates a unique name depending on the shortest physical path to the device
by-uuid - is a mechanism to give each filesystem a unique identifier.
These identifiers are generated by the mkfs utilities.