Can no longer eject media with eject
#172 Henry, Wednesday, 25 July 2012 7:11 AM (Category: Linux)
(Tags: linux eject)

I have a lot of scripts that rip cds and dvds, and at the end I use the eject command to get the cd or dvd out. It used to work just fine. After the latest Slackware upgrade, this no longer works. I get the error:

eject: unable to eject, last error: Inappropriate ioctl for device

But it works if I am root. I assume a permissions problem.

I tested it with both CDs and DVDs and it behaves the same with both. It won't eject the media, and it gives that error.

There is one potential reason and that is if something has it open. Because root can eject it and a user cannot, I did not think this was the problem, but it's still best to check it just in case. It's a cdrom so you don't mount it. It is not mounted. But just in case something is using it, as root I did "fuser /dev/cdrom" and "fuser /dev/sr0" and it showed nothing was accessing it. That eliminated that potential solution.

I could take the easy way out and set up an alias making "eject" = "sudo eject", but that's cheating. I would really like to know why. I used "eject -v" for verbose mode and got this result:

eject: using default device `cdrom'
eject: device name is `cdrom'
eject: expanded name is `/dev/cdrom'
eject: `/dev/cdrom' is a link to `/dev/sr0'
eject: `/dev/sr0' is not mounted
eject: `/dev/sr0' is not a mount point
eject: `/dev/sr0' is not a multipartition device
eject: trying to eject `/dev/sr0' using CD-ROM eject command
eject: CD-ROM eject command failed
eject: trying to eject `/dev/sr0' using SCSI commands
eject: SCSI eject failed
eject: trying to eject `/dev/sr0' using floppy eject command
eject: floppy eject command failed
eject: trying to eject `/dev/sr0' using tape offline command
eject: tape offline command failed
eject: unable to eject, last error: Inappropriate ioctl for device

It tries to eject it as a CDROM, and it fails. Then it tries some other methods, fails on each of them, and then reports only the last error result which is for treating it as a tape drive. No wonder it says "Inappropriate ioctl for device". So that's pretty useless. I tried it as "eject -rv" for verbose and treat it only as a CDROM, and got this:

eject: using default device `cdrom'
eject: device name is `cdrom'
eject: expanded name is `/dev/cdrom'
eject: `/dev/cdrom' is a link to `/dev/sr0'
eject: `/dev/sr0' is not mounted
eject: `/dev/sr0' is not a mount point
eject: `/dev/sr0' is not a multipartition device
eject: trying to eject `/dev/sr0' using CD-ROM eject command
eject: CD-ROM eject command failed
eject: unable to eject, last error: Input/output error

and now finally we see what the cdrom eject reason is - input/output error. Great. So useful. However, I have seen this sort of error many times before, and it's often associated with permissions problems. So I really do think it is a permissions problem.

I tried adding my user name to various groups in /etc/group and then trying to eject, but that didn't work. I think I know the reason why, but I have more tests to make.

0 comments