15

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…]

2
  • 3
    First result in google: access.redhat.com/site/documentation/en-US/…
    – forcefsck
    Commented Aug 14, 2013 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?
    – user732
    Commented Aug 14, 2013 at 19:55

3 Answers 3

17

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

2
  • 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
    Commented Aug 15, 2013 at 0:08
  • 1
    Right. I've updated the answer above for some details where does the ID_PATH actually come from. Commented Aug 15, 2013 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!

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.
1
  • 1
    This should be the accepted answer
    – crypdick
    Commented Jul 16, 2023 at 14:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .