2

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

)

Jeff K
  • 43
  • What's your goal? – A.B. Sep 23 '15 at 13:22
  • After an Android build, a script loads an SD card with the image. In the script, a 'ls /dev/disk/by-path' output is used to populate variables. End goal is to load the Android image, but immediate goal is to satisfy the script by creating /dev/disk/by-path. – Jeff K Sep 23 '15 at 13:27
  • Mount the SD Card and you have /dev/disk/by-path. – A.B. Sep 23 '15 at 13:38
  • Mounting the SD card doesn't create it for my system. – Jeff K Sep 24 '15 at 14:08
  • But you can see the SD card in your filemanager? – A.B. Sep 24 '15 at 14:09
  • Yes, it shows in the filemanager under Devices. Sidenote: I noticed if I mount it on the command line, it no longer appears in the filemanager, unmount, shows again. – Jeff K Sep 24 '15 at 14:22
  • [Edit] your question and add the output of grep -ri 'by-path' /lib/udev/rules.d/60-persistent-storage.rules – A.B. Sep 27 '15 at 13:28
  • @JeffK, Could you mention your release? – user.dz Sep 27 '15 at 13:41
  • Insert your SD card, [Edit] your question and add the output of sudo udevadm info --root --name=/dev/sdc | grep DEVTYPE. Replace /dev/sdc with your drive. – A.B. Sep 28 '15 at 17:55
  • And give me a ping in the comments via @A.B. – A.B. Sep 28 '15 at 17:59
  • The DEVTYPE is ok, you should have a disk/by-path if you plug the stick. – A.B. Sep 28 '15 at 19:10
  • And the output of sudo udevadm info --root --name=/dev/sdc | grep ID_PATH=, i hope /dev/sdc is the correct device. – A.B. Sep 28 '15 at 19:12
  • @JeffK , please add output of sudo udevadm test --name=/dev/sdc this is for debuging – user.dz Sep 28 '15 at 22:07

1 Answers1

1

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.

A.B.
  • 90,397
  • Oddly enough, it doesn't create by-path automatically for my system, whether mounted on the command line or by the GUI file explorer window. I'm guessing my system has a quirk that is making it different, but I'm unsure how to track it down. Open to other ideas. – Jeff K Sep 24 '15 at 13:17