PDA

View Full Version : eject: unable to find or open device for: `cdrom'



input
6th November 2011, 05:33 PM
When I type eject in a terminal I get this error:eject: unable to find or open device for: `cdrom'

But in Gnome it works fine.

How can I solve this problem.

Thanks

scott32746
6th November 2011, 06:40 PM
Hello,

Could try something like
# eject /dev/sr0

My dvd-rom is /dev/sd0

input
6th November 2011, 07:02 PM
Thanks for the reply.

eject /dev/sr0 works fine

Thanks

jpollard
6th November 2011, 08:02 PM
What you have is a missing symbolic link "cdrom->sr0" in /dev.

input
7th November 2011, 11:57 AM
What you have is a missing symbolic link "cdrom->sr0" in /dev.

Thanks for the reply.

But how can I make a symbolic link.

Thanks

jpollard
7th November 2011, 01:34 PM
"man ln"

A better reference is provided by "info ln".

The reference documentation will tell you about it. The short form is to use a root login command line and the sequence:

cd /dev
ln -s sr0 cdrom

The first command puts the working directory in /dev, the second creates the symbolic link.

This must be done as root as only root can create files in /dev.

Using a hard link would work, but sometimes updates to the system will change the file name for the cdrom - a hard link is tied directly to original file and will not refer to the current "sr0" (the cdrom hardware name), so a symbolic reference (which is evaluated while opening the file) will continue to reference the correct device.

input
7th November 2011, 02:31 PM
Thank you for explaning this.
It works :)

---------- Post added at 02:31 PM ---------- Previous post was at 02:01 PM ----------

I still have the same problem with a reboot.
The message is: eject: tried to use `/media/cdrom' as device name but it is no block device
eject: unable to find or open device for: `cdrom

jpollard
7th November 2011, 03:11 PM
Are you using Fedora 15 or 16?

If so, report it as a bug. (F15 has /dev being a memory resident filesystem managed by udev.

And that makes the simple solutions impossible. Somewhere there is a directive missing from the udev configuration to have this recreated on each boot.

for instance, - on my test F15 installation (in a VM) the udev rules in /etc/udev/rules.d/70-persistent-cd.rules I have:


# This file was automatically generated by the /lib/udev/write_cd_rules
# program, run by the cd-aliases-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and set the $GENERATED variable.

# QEMU_DVD-ROM (pci-0000:00:01.1-scsi-1:0:0:0)
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-1:0:0:0", SYMLINK+="cdrom", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-1:0:0:0", SYMLINK+="dvd", ENV{GENERATED}="1"


Note the line starting with SUBSYSTEM=="block", ENV{ID_CDROM}...

Pain in the ass.

I bet yours doesn't have that line (may not have the dvd line either). It is even possible that the file doesn't exist.

You can save this file (if it exists) and then try running the /lib/udev/write_cd_rules manually, and see if it recreates it properly.

If it looks something like what I have, then the symbolic links should be recreated on following boots.

DBelton
7th November 2011, 03:16 PM
It also seems to cause this error if you have a SATA CDROM/DVD drive, and it's set to IDE mode in the BIOS.

input
7th November 2011, 04:07 PM
Are you using Fedora 15 or 16?

If so, report it as a bug. (F15 has /dev being a memory resident filesystem managed by udev.

And that makes the simple solutions impossible. Somewhere there is a directive missing from the udev configuration to have this recreated on each boot.

for instance, - on my test F15 installation (in a VM) the udev rules in /etc/udev/rules.d/70-persistent-cd.rules I have:


# This file was automatically generated by the /lib/udev/write_cd_rules
# program, run by the cd-aliases-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and set the $GENERATED variable.

# QEMU_DVD-ROM (pci-0000:00:01.1-scsi-1:0:0:0)
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-1:0:0:0", SYMLINK+="cdrom", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:00:01.1-scsi-1:0:0:0", SYMLINK+="dvd", ENV{GENERATED}="1"


Note the line starting with SUBSYSTEM=="block", ENV{ID_CDROM}...

Pain in the ass.

I bet yours doesn't have that line (may not have the dvd line either). It is even possible that the file doesn't exist.

You can save this file (if it exists) and then try running the /lib/udev/write_cd_rules manually, and see if it recreates it properly.

If it looks something like what I have, then the symbolic links should be recreated on following boots.

Thanks

I am using Fedora 14

jpollard
7th November 2011, 04:40 PM
Must have sneaked in... I find it there too, though /dev is not a mounted filesystem (I've been upgrading since F11).

If the file /etc/udev/rules.d70-persistent-cd.rules does not exist try running
/lib/udev/write_cd_rules and see if it creates it.

I have a multi-function CD/DVD/CDRW/DVDRW, so mine has four entries just for the CD/DVD that creates all four entries.

input
7th November 2011, 05:20 PM
When I do that iget this message:
[root@localhost ~]# /lib/udev/write_cd_rules
Missing $DEVPATH

jpollard
7th November 2011, 07:22 PM
hm... well...

The following is odd, but I was able to figure out what the rules should be, but not all the variations that can get there.

if you look in ( ls -l ) the directory /dev/disk/by-path, there should be
a file that points to sr0. It should look something like:



# ls -l
total 0
lrwxrwxrwx. 1 root root 9 Sep 27 19:59 pci-0000:00:1f.2-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx. 1 root root 10 Aug 25 02:33 pci-0000:00:1f.2-scsi-0:0:0:0-part1 -> ../../sda1
lrwxrwxrwx. 1 root root 10 Aug 25 02:33 pci-0000:00:1f.2-scsi-0:0:0:0-part2 -> ../../sda2
lrwxrwxrwx. 1 root root 10 Aug 25 02:33 pci-0000:00:1f.2-scsi-0:0:0:0-part3 -> ../../sda3
lrwxrwxrwx. 1 root root 10 Aug 25 02:33 pci-0000:00:1f.2-scsi-0:0:0:0-part4 -> ../../sda4
lrwxrwxrwx. 1 root root 10 Aug 25 02:33 pci-0000:00:1f.2-scsi-0:0:0:0-part5 -> ../../sda5
lrwxrwxrwx. 1 root root 9 Aug 25 02:33 pci-0000:00:1f.2-scsi-0:0:1:0 -> ../../sdb
lrwxrwxrwx. 1 root root 10 Aug 25 02:33 pci-0000:00:1f.2-scsi-0:0:1:0-part1 -> ../../sdb1
lrwxrwxrwx. 1 root root 10 Aug 25 02:33 pci-0000:00:1f.2-scsi-0:0:1:0-part2 -> ../../sdb2
lrwxrwxrwx. 1 root root 9 Aug 25 02:33 pci-0000:00:1f.2-scsi-1:0:0:0 -> ../../sdc
lrwxrwxrwx. 1 root root 10 Aug 25 02:33 pci-0000:00:1f.2-scsi-1:0:0:0-part1 -> ../../sdc1
lrwxrwxrwx. 1 root root 9 Aug 25 02:33 pci-0000:08:05.0-scsi-0:0:0:0 -> ../../sdd
lrwxrwxrwx. 1 root root 10 Aug 25 02:33 pci-0000:08:05.0-scsi-0:0:0:0-part1 -> ../../sdd1
lrwxrwxrwx. 1 root root 9 Nov 7 12:50 pci-0000:08:05.0-scsi-0:0:1:0 -> ../../sr0


The part needed for the udev rule is (in my case above) the "pci-0000:08:05.0-scsi-0:0:1:0". And the resulting rule that is in my /etc/udev/rules.d/70-persistent-cd.rules is:



SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:08:05.0-scsi-0:0:1:0", SYMLINK+="cdrom", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:08:05.0-scsi-0:0:1:0", SYMLINK+="cdrw", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:08:05.0-scsi-0:0:1:0", SYMLINK+="dvd", ENV{GENERATED}="1"
SUBSYSTEM=="block", ENV{ID_CDROM}=="?*", ENV{ID_PATH}=="pci-0000:08:05.0-scsi-0:0:1:0", SYMLINK+="dvdrw", ENV{GENERATED}="1"


Note, each rule is one line. for /dev/cdrom, you only need the first line, and replace the "pci-0000:08:05.0-scsi-0:0:1:0" by what is the association with your /dev/sr0 from the directory /dev/disk/by-id.

This identification is used, I believe, to prevent renumbering devices in the future - the "by-id" entry should be the physical interconnections and won't change (unless you do some rewiring).

If you have additional names/capabilities (such as "dvd", "dvd+" and such") you can duplicate the entry and put the desired name in place of the "cdrom" entry.

SOMEWHERE, there should be documented how these rules are supposed to be created. But it seems to be missing. The closest I could find was a 2008 entry for Linux from Scratch, which pointed me to the /dev/device/by-id directory, and comparing my udev file showed the same string used for the cdrom/dvd/... names.

I don't know what created them originally - though way back, I used to do it manually (once), and unless I wiped the system and reinstalled, I never had to create them since. Where the rules came from must have been some upgrade pass when udev took over the /dev directory.

I'm sure somebody should have better directions.