Editor’s Note: This article is part of the Tales of A Linux Switcher series.
As part of my on-going switch to Ubuntu 12.04 from Mac OS X, I ran into an issue where my cdrom device was not being mapped properly in the OS.
Everything works as desired except for one little thing: the eject key on the Apple Aluminum USB keyboard was not triggering the eject sequence of the built-in slot loading SuperDrive.
I assumed that there would be a device mapped to the actual drive using a link to /dev/cdrom. This didn’t turn out to be the case. When using the eject command from a terminal I received the following:
$ eject eject: unable to find or open device for: `cdrom'
When I did a directory list to find any applicable cdrom device entries in the udev root (/dev) I got the following:
$ udevadm info --root /dev root@foreandy-iMac:~# ls -l /dev/*cd* ls: cannot access /dev/*cd*: No such file or directory
In order to determine exactly which device was being used for the optical drive, I looked at the output from system’s cdrom device entry:
$ cat /proc/sys/dev/cdrom/info CD-ROM information, Id: cdrom.c 3.20 2003/12/17 drive name: sr0 drive speed: 24 drive # of slots: 1 Can close tray: 1 Can open tray: 1 Can lock tray: 1 Can change speed: 1 Can select disk: 0 Can read multisession: 1 Can read MCN: 1 Reports media changed: 1 Can play audio: 1 Can write CD-R: 1 Can write CD-RW: 1 Can read DVD: 1 Can write DVD-R: 1 Can write DVD-RAM: 0 Can read MRW: 0 Can write MRW: 0 Can write RAM: 1
The next step was to create the symbolic link in the device root to map cdrom to the appropriate device as listed in the above output:
$ sudo ln -s /dev/sr0 /dev/cdrom $ ls -l /dev/*cd* lrwxrwxrwx 1 root root 8 Jul 30 09:58 /dev/cdrom -> /dev/sr0
Now I can use both command line utilities to work with the optical drive as well as the built-in eject key on my keyboard.
If you want a lot more detail on this issue check out this bug comment. While not specifically dealing with a Mac, the issues and solution are the same.