Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
I ran into the same problem on a Dell Inspiron 660s. Wish there was a better answer for this problem. –  Cerin Jan 21 '13 at 1:04
add comment

2 Answers

up vote 6 down vote accepted
+50

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:

SUBSYSTEM=="block", ENV{ID_MODEL}=="...", ENV{ID_SERIAL}=="...", ENV{GENERATED}="1", SYMLINK+="dvd"

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:

SUBSYSTEM=="block", ENV{ID_TYPE}=="...", ENV{ID_PATH}=="pci-...", ENV{GENERATED}="1", SYMLINK+="dvd"

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 and ID_PATH using the following command (the udevtest command as in tutorial doesn't work - anymore ? - in Ubuntu):

udevadm info --query=all --name=sr0

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 udev 75-cd-aliases-generator.rules file from overriding your custom rules.

share|improve this answer
    
Thanks for all the info. I went to try out some of these rules, but found that my /dev/dvd symlink magically fixed itself sometime in the last few months. I also read in this bug that /dev/dvd's days are numbered. Oh well. For now, your answer seems to give all the info necessary to fix this problem. –  chazomaticus Nov 9 '13 at 23:18
add comment

I found this on a fedora forum may helps:

Create a shell script file In that file, put:

#!/bin/bash
ln -s /dev/sr0 /dev/dvd

Make sure the file is execlutable:

sudo chmod +x /etc/rc.d/rc.local

If you're going to use the rc.local route, you also need to do this, as root:

systemctl enable rc-local.service

because it's not enabled by default

source:http://forums.fedoraforum.org/showthread.php?t=295048

---------The preferred way these days would be a UDev rule--------------

Based on /lib/udev/rules.d/60-cdrom_id.rules, which creates the /dev/cdrom symbolic link, try adding a file /etc/udev/rules.d/60-dvd.rules containing:

KERNEL=="sr0", SYMLINK+="dvd", OPTIONS+="link_priority=-100"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.