4

Question: What does /dev/disk/by-pathdescribe? And where is this documented?

Going through the meaning of what is displayed in the folders /dev/disk/by- I've got that far, and I wonder is this correct?

  • by-id → based upon the serial number of the hardware devices
  • by-label → Whatever name was set manually for this disk
  • by-path?!
  • by-uuidUniversal Unique Identifier: a uniquely created string to identify the disk [done so through the system]


[Note: I work on GNU/Linux Debian 7, Crunchbang, if this matters…]

  • 3
    First result in google: access.redhat.com/site/documentation/en-US/… – forcefsck Aug 14 '13 at 19:55
  • 1
    On my system (x86_64 Arch linux, installed within the last 3 months) all of the /dev/disk/by-*/ entries comprise symbolic links to /dev/sd[ab][1234567] block device files. Of what use are these various naming schemes? – Bruce Ediger Aug 14 '13 at 19:55
10

Mountpoint /dev is devtmpfs filesystem and managed by udev completely. So for details we have to go to udev configuration.

2 udev rules are handling this typically

$ 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 mentions

# 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"

Finally ID_PATH is a unique identificator for a device based on it's physical HW location / connection (eg. something like ID_PATH=pci-0000:02:04.0-scsi-0:0:0:0).

ID_PATH comes from builtin udev program called path_id (eg. for /sys/block/sdc)

$ 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

We can relate it to

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/

Ultimately, if anybody is interested in details consult the source code

  • so, e.g. pci-0000:02:04.0-scsi-0:0:0:0 describes that the device is connected from PCI bus to SCSI adapter and thus describing hardware connections? Is this right? – erch Aug 15 '13 at 0:08
  • 1
    Right. I've updated the answer above for some details where does the ID_PATH actually come from. – Miroslav Koškár Aug 15 '13 at 1:27
4

by-path is access disk way. For Local disk, by-path is pci path of disk device. For iSCSI disk, by-path is iSCSI path of remote disk device.

System can use by-path to location disk device!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.