Fixing My CD/DVD Drive on Kubuntu 12.04

December 12, 2012 by
Filed under: HowTo, linux, Ubuntu 

I've been having problems with my optical drive on my Kubuntu 12.04 machine. Certain applications couldn't find the CD/DVD drive because they look for specific device names in /dev. My SATA optical drive would show up as /dev/sr0, however the normal symlinks to cdrom, cdrw, dvd, dvdrw were not there. I would go to the terminal and manually create the symlink and things would work fine, but after a reboot my symlinks would be gone! I found the fix in an old bug report on LaunchPad.

The problem turned out to be caused by an essentially empty udev rule for the CD ROM. I was able to rename/remove that rule file and after rebooting, the expected symlinks are in /dev.

To fix the problem I just did:

sudo mv /etc/udev/rules.d/70-persistent-cd.rules /etc/udev/rules.d/70-persistent-cd.rules.bak

I then rebooted the machine and now in /dev I see my expected symlinks for the optical drive:

Affiliate Link
lrwxrwxrwx 1 root root 3 Dec 11 23:52 cdrom -> sr0
lrwxrwxrwx 1 root root 3 Dec 11 23:52 cdrw -> sr0
lrwxrwxrwx 1 root root 3 Dec 11 23:52 dvd -> sr0
lrwxrwxrwx 1 root root 3 Dec 11 23:52 dvdrw -> sr0
brw-rw----+ 1 root cdrom 11, 0 Dec 11 23:52 sr0

Edit: 15-Dec-12
It turns out that didn't totally fix my problem. Once I opened the CD tray my symlinks disappeared!

I then found a default udev file in /lib/udev/rules.d to use. I copied the file to /etc/udev/rules.d.

sudo cp /lib/udev/rules.d/75-cd-aliases-generator.rules /etc/udev/rules.d

I thought that would fix my problem, but it didn't. Then I found a post on the Arch Linux forums that suggested removing the ACTION=="add" portion of the rule for the internal CD drive and now my system is working as expected. This generator file has also created a new udev rule for a persistent cd drive.

Here's the content of my /etc/udev/rules.d/75-cd-aliases-generator.rules

# these rules generate rules for the /dev/{cdrom,dvd,...} symlinks

# the "path" of usb/ieee1394 devices changes frequently, use "id"
ACTION=="add", SUBSYSTEM=="block", SUBSYSTEMS=="usb|ieee1394", ENV{ID_CDROM}=="?*", ENV{GENERATED}!="?*", \
  PROGRAM="write_cd_rules by-id", SYMLINK+="%c", GOTO="persistent_cd_end"

#ACTION=="add", SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{GENERATED}!="?*", PROGRAM="write_cd_rules", SYMLINK+="%c"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{GENERATED}!="?*", PROGRAM="write_cd_rules", SYMLINK+="%c"

LABEL="persistent_cd_end"

As you can see, I commented out the original line for the built-in CD ROM and then created a modified version of that line with the ACTION=="add" portion removed from the beginning. If you have a USB or Firewire CD drive, you may need to do the same thing to the earlier line for "usb/ieee1394" devices.

Here's the content of my new, automatically generated /etc/udev/rules.d/70-persistent-cd.rules

# LITE-ON_DVDRW_LH-20A1L (pci-0000:00:1f.2-scsi-3:0:0:0)
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:1f.2-scsi-3:0:0:0", SYMLINK+="cdrom", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:1f.2-scsi-3:0:0:0", SYMLINK+="cdrw", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:1f.2-scsi-3:0:0:0", SYMLINK+="dvd", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:1f.2-scsi-3:0:0:0", SYMLINK+="dvdrw", ENV{GENERATED}="1"

Your file will most likely be a little bit different.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>