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
    – phemmer
    May 23, 2018 at 1:35
  • 1
    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.
    – Mio Rin
    May 23, 2018 at 1:44

2 Answers 2


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 or run

sudo udevadm control --reload-rules; sudo udevadm trigger

to re-run your udev rules and you will see 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, 2018 at 11:46
  • 1
    I believe it does. Just read the question again :)
    – jsalatas
    May 23, 2018 at 21:03
  • This should be the accepted answer. I wanted a symlink to /dev/ttyS2 as /dev/ttyS0, so created using this line in /etc/udev/rules.d/10-tty.rules: KERNEL=="ttyS2", SYMLINK+="ttyS0" Works great!
    – Ken H
    Sep 28, 2022 at 21:58

I just came across a solution described in proxmox wiki

If you have a good number of disks keep organized by using aliases. Edit /etc/zfs/vdev_id.conf to prepare aliases for disk devices found in /dev/disk/by-id/ : run 'udevadm trigger' after updating this file

alias a0        scsi-36848f690e856b10018cdf39854055206
alias b0        scsi-36848f690e856b10018cdf3ce573fdeb6
alias a1        scsi-36848f690e856b10018cdf40f5b277cbc
alias b1        scsi-36848f690e856b10018cdf43a5db1b99b
alias a2        scsi-36848f690e856b10018cdf4575f652ad0
alias b2        scsi-36848f690e856b10018cdf47761587cec

Seems it can solve OP's problem quite elegantly, I also think using /dev/disk/by-id/wwn-xxx is more appropriate, since is guaranteed not to changed even if the disk is moved to another system.

  • /dev/disk/by-id/xxxxxxxxxxxxxxxxxxxx avoids any user created aliases. Aug 14, 2021 at 16:35

You must log in to answer this question.

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