1

I want to create a symlink to a device.When i tried the command

ln -s /dev/sr0 /dev/scd0

it looked everything well.But when i restarted the server,i found /dev/scd0 is disappered. How can i create a permanent link?

  • Kinda duplicate, kinda not, but your answer can be found here: unix.stackexchange.com/a/44627/4358 – Patrick May 23 '18 at 1:35
  • IIRC, /dev, like /proc and /run gets populated on boot and disappears into the aether on shutdown, so any symlinks made there will never stick. I worked around a similar issue (USB automount) by symlinking the automountpoint in /run/media/user/ to /home/user/usbstick. – Mioriin May 23 '18 at 1:44
5

Modern linux distros use udev device manager, so you need to create a udev rule to achieve this.

As a root user create a new file named 99_sr0.rules in /etc/udev/rules.d/ with the following contents

KERNEL=="sr0", SYMLINK+="scd0"

Reboot your PC and you will your symlink

> ls -l /dev/sr0 /dev/scd0
lrwxrwxrwx  1 root root      3 May 22 18:54 /dev/scd0 -> sr0
brw-rw----+ 1 root cdrom 11, 0 May 22 18:54 /dev/sr0
> 
  • … although the question did not actually specify that the symbolic link has to be in /dev. (-: – JdeBP May 23 '18 at 11:46
  • I believe it does. Just read the question again :) – jsalatas May 23 '18 at 21:03

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.