Certain programs look for /dev/dvd
by default to find DVDs. When I first boot my computer without a DVD inserted, /dev/dvd
exists and points to the correct place (/dev/sr0
). However, when I insert a DVD, /dev/dvd
disappears. I'd like it to stick around so I don't have to navigate to /dev/sr0
in programs that are looking for DVDs. How do I ensure that the /dev/dvd
symlink exists and points to the right place?
It looks like I can add something to /etc/udev/rules.d/70-persistent-cd.rules
. This site gives a couple of examples, but the 70-persistent-cd.rules
file says "add the ENV{GENERATED}=1 flag to your own rules", which isn't part of the examples. The man 7 udev
page is impenetrable to me, and I'm not convinced the linked page gives 100% of the information I need.
So, what can I do on a modern, Ubuntu 12.04 (or later) system to make /dev/dvd
always exist and point to the right device?
EDIT: Is it as simple as adding ENV{GENERATED}=1
to the rules in the linked page, something like this:
SUBSYSTEM=="block", KERNEL=="sr0", SYMLINK+="dvd", GROUP="cdrom", ENV{GENERATED}=1
Is that the right information for modern Ubuntu? What is ENV{GENERATED}
doing there, when it wasn't generated, but hand-written?
Best Answer
This tutorial explain very nice how to do what you want:
According to it, there are two approaches to creating symlinks. The first one is to use the model name and the serial number:
This way, the symlink will stay correct even if you move the drive to different positions on the IDE bus, but the
/dev/dvd
symlink won't be created if you replace the drive.The second one is based on the location of the device on the bus:
This way, the symlink will stay correct even if you replace drives with different models, but place them to the same positions on the IDE bus. The
ENV{ID_TYPE}
key makes sure that the symlink disappears if you put something other than a DVD in that position on the bus.You can find the values for
ID_MODEL
,ID_SERIAL
,ID_TYPE
andID_PATH
using the following command (theudevtest
command as in tutorial doesn't work - anymore ? - in Ubuntu):The
SUBSYSTEM=="block"
key is needed in order to avoid matching SCSI generic devices. Without it, in the case with SCSI DVD, the symlink will sometimes point to the correct/dev/sr0
devices, and sometimes to/dev/sg0
, which is wrong.The
ENV{GENERATED}="1"
key is needed to prevent the udev75-cd-aliases-generator.rules
file from overriding your custom rules.