Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Adding by-path to /dev/disk

Writer Andrew Henderson

I have a script relying on /dev/disk/by-path, but that subdirectory does not exist. When I ls /dev/disk, I get:

by-id by-label by-uuid

How do I get by-path?

(Output of grep -ri 'by-path' /lib/udev/rules.d/60-persistent-storage.rules is:

# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path}
# by-path (parent device path)
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"

)

(Output of sudo udevadm info --root --name=/dev/sdc | grep DEVTYPE is:

E: DEVTYPE=disk

)

13

1 Answer

The path /dev/disk/by-path is automatically created when you add the SD card to your system (not via mount). Responsible for this is udev and the rules in

/lib/udev/rules.d/60-persistent-storage.rules

With a simple command you can see the rules:

% grep -ri 'by-path' /lib/udev/rules.d/60-persistent-storage.rules
# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path}
# by-path (parent device path)
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"

And you should not use ls /dev/disk/by-path to get the values for your variables. Use

for f in /dev/disk/by-path/*; do echo "$f"; done

instead.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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