# Cannot eject CD/DVD

## IvanZD

Hi!

I have dbus/hald/ivman for automunting disks in KDE, and I can't eject them.. don't know what is cause of this   :Confused:   Disks gets properly mounted, but when I try to eject them, they refuse - pressing button on drive does nothing, right click on desktop's CD icon and selecting "eject" gives error, and only way to eject them is through eject command from console (but, only with root permissions).

What can I try to do? If you need more info, please ask.

----------

## infoseeker

I presume you are a member of the 'cdrom' group (or 'cdrw' maybe)   :Wink: 

 *Quote:*   

> $ groups
> 
> wheel audio cdrom games users
> 
> 

 

----------

## mmbrothers

Also the drive gets locked when a CD is mounted so that the drive cannot be opened with the button.  This is to prevent the CD from being ejected while Linux is still trying to read from the disk, causing I/O errors.

----------

## IvanZD

 *infoseeker wrote:*   

> I presume you are a member of the 'cdrom' group (or 'cdrw' maybe)  

 

Yes, I am. Shouldn't be?

----------

## IvanZD

 *mmbrothers wrote:*   

> Also the drive gets locked when a CD is mounted so that the drive cannot be opened with the button.  This is to prevent the CD from being ejected while Linux is still trying to read from the disk, causing I/O errors.

 

Of course, but.. If I right click on CD-ROM icon on desktop and select Unmount, still cannot eject it. To be more precise, if I do it immediately after loading, I can, but.. if in meantime start for example k9copy, do something with disk, close k9copy and.. drive get's locked forever:

```
KDE eject - KDialog

Eject /dev/cdrom failed!
```

But it unmounted properly:

```
# umount /dev/cdrom

umount: /dev/cdrom: not mounted
```

Just cannot eject. Only this ejects it:

```
# eject cdrom

eject: unable to eject, last error: Invalid argument
```

Gives that error but still goes out.

 :Confused: 

I would like to not use console to eject disks if possible..

----------

## mmbrothers

After you mount the cdrom, post the output from mount.

----------

## IvanZD

Hi mmbrothers,

disk mount automatically via dbus/hald/ivman, so I don't see output directly, but, I have little strange logs about cdrom drive.. during inserting disk, got this:

```
# tail -f /var/log/everything/current

                - Last output repeated twice -

Jan  5 12:12:10 [su(pam_unix)] session opened for user root by (uid=1000)

Jan  5 12:12:11 [kernel] hdc: packet command error: status=0x51 { DriveReady SeekComplete Error }

                - Last output repeated 194 times -

Jan  5 12:15:26 [su(pam_unix)] session opened for user root by (uid=1000)

Jan  5 12:15:26 [kernel] hdc: packet command error: status=0x51 { DriveReady SeekComplete Error }

Jan  5 12:15:26 [kernel] hdc: packet command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }

Jan  5 12:15:27 [kernel] hdc: packet command error: status=0x51 { DriveReady SeekComplete Error }

                - Last output repeated 3 times -

Jan  5 12:15:34 [kernel] VFS: busy inodes on changed media.

                - Last output repeated 7 times -

Jan  5 12:16:02 [kernel] hdc: packet command error: status=0x51 { DriveReady SeekComplete Error }

                - Last output repeated 3 times -

Jan  5 12:16:02 [kernel] hdc: packet command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }

Jan  5 12:16:02 [kernel] ide: failed opcode was: unknown

Jan  5 12:16:02 [kernel] hdc: packet command error: status=0x51 { DriveReady SeekComplete Error }

```

----------

## rdk

A jesi ga izjeba  :Smile:  si jos bolestan ?

How long doesn't it work...

Eject should unmount media and and eject the cd.. AFAIK.

Eject doesn't eject the media if anything is currently using the drive, are you shure you are not trying to 

eject while the drive is in use ?

----------

## mmbrothers

You could always emerge lsof and use it to see if anything is trying to use the CD before you try to eject the disk.  Remember that the disk is considered in use even if you don't actively have any files open on the disk; if the working directory of a shell or program is on the CD then it considers the CD in use.

----------

## dgaffuri

Same problem here, I don't even mount the CD and it locks. As normal user (in the cdrom and disk group, able to mount and dismount it) I run

```
$ eject -v

eject: using default device `cdrom'

eject: device name is `cdrom'

eject: expanded name is `/dev/cdrom'

eject: `/dev/cdrom' is a link to `/dev/hdc'

eject: `/dev/hdc' is not mounted

eject: `/dev/hdc' is not a mount point

eject: `/dev/hdc' is a multipartition device

eject: trying to eject `/dev/hdc' using CD-ROM eject command

eject: CD-ROM eject command failed

eject: trying to eject `/dev/hdc' using SCSI commands

eject: SCSI eject failed

eject: trying to eject `/dev/hdc' using floppy eject command

eject: floppy eject command failed

eject: trying to eject `/dev/hdc' using tape offline command

eject: tape offline command failed

eject: unable to eject, last error: Invalid argument
```

and nothing happens. As root the output is identical

```
# eject -v

eject: using default device `cdrom'

eject: device name is `cdrom'

eject: expanded name is `/dev/cdrom'

eject: `/dev/cdrom' is a link to `/dev/hdc'

eject: `/dev/hdc' is not mounted

eject: `/dev/hdc' is not a mount point

eject: `/dev/hdc' is a multipartition device

eject: trying to eject `/dev/hdc' using CD-ROM eject command

eject: CD-ROM eject command failed

eject: trying to eject `/dev/hdc' using SCSI commands

eject: SCSI eject failed

eject: trying to eject `/dev/hdc' using floppy eject command

eject: floppy eject command failed

eject: trying to eject `/dev/hdc' using tape offline command

eject: tape offline command failed

eject: unable to eject, last error: Invalid argument
```

but the CD is ejected. I see that the device spins and ejects during the SCSI command (it's not a SCSI device). If I specify SCSI command only I get

```
$ eject -vs

eject: using default device `cdrom'

eject: device name is `cdrom'

eject: expanded name is `/dev/cdrom'

eject: `/dev/cdrom' is a link to `/dev/hdc'

eject: `/dev/hdc' is not mounted

eject: `/dev/hdc' is not a mount point

eject: `/dev/hdc' is a multipartition device

eject: trying to eject `/dev/hdc' using SCSI commands

eject: SCSI eject failed

eject: unable to eject, last error: Operation not permitted

# eject -vs

eject: using default device `cdrom'

eject: device name is `cdrom'

eject: expanded name is `/dev/cdrom'

eject: `/dev/cdrom' is a link to `/dev/hdc'

eject: `/dev/hdc' is not mounted

eject: `/dev/hdc' is not a mount point

eject: `/dev/hdc' is a multipartition device

eject: trying to eject `/dev/hdc' using SCSI commands

eject: SCSI eject failed

eject: unable to eject, last error: Invalid argument
```

Again it works only from root, even if the command fails. As you see the message for the normal user is "Operation not permitted".

I saw this bug and upgraded from sys-apps/eject-2.0.13-r1 to 2.1.0 (keyword masked). This changes the message but not the behaviour.

```
$ eject -vs

eject: using default device `cdrom'

eject: device name is `cdrom'

eject: expanded name is `/dev/cdrom'

eject: `/dev/cdrom' is a link to `/dev/hdc'

eject: `/dev/hdc' is not mounted

eject: `/dev/hdc' is not a mount point

eject: `/dev/hdc' is a multipartition device

eject: trying to eject `/dev/hdc' using SCSI commands

eject: SCSI eject failed

eject: unable to eject, last error: Operation not permitted

# eject -vs

eject: using default device `cdrom'

eject: device name is `cdrom'

eject: expanded name is `/dev/cdrom'

eject: `/dev/cdrom' is a link to `/dev/hdc'

eject: `/dev/hdc' is not mounted

eject: `/dev/hdc' is not a mount point

eject: `/dev/hdc' is a multipartition device

eject: trying to eject `/dev/hdc' using SCSI commands

eject: SCSI eject succeeded
```

Any suggestion is welcome

Edit:

Looking better I found this other bug, with a patch that should solve the problem (I've not tried it yet). The reason for the SCSI command not working seems to be that the device is opened read only, so that the eject command requires root privs (follow the thread in linux kernel mailing list for details).

More strange the CDROM method works with normal user and root if no CD is in the unit, but fails with an I/O error with both users if I have an unmounted disc in.

----------

## amne

Moved from Other Things Gentoo to Kernel & Hardware.

----------

## libretto

 *dgaffuri wrote:*   

> 
> 
> Any suggestion is welcome
> 
> 

 

I'd the same problem on my laptop and I solved that by emerging udev-073 and ivman-0.5_pre3.  The stable release(s) udev-070-r1 and/or ivman-0.5_pre3 seems to have problems.

----------

## greggel

hi! i've the same problem ejecting cds. this is my output:

sys-apps/ivman-0.5_pre2

sys-fs/udev-070-r1

 *Quote:*   

> lsof /dev/hdc
> 
> COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
> 
> ivman   9214 root    7r   BLK   22,0      5946 /dev/hdc
> ...

 

i suggest the trick is not to use ivman with another automountsubsystem like the one in kde.

----------

## dgaffuri

The eject problem has been solved in 2.1.4-r1,look at the bug.

----------

## Joseph_sys

 *dgaffuri wrote:*   

> The eject problem has been solved in 2.1.4-r1,look at the bug.

 

I just installed 2.1.4-r1 on AMD64 but eject still doesn't work.

----------

## dgaffuri

 *Joseph_sys wrote:*   

> I just installed 2.1.4-r1 on AMD64 but eject still doesn't work.

 

It should, does the device have the proper permissions?

```
# ls -l /dev/hdc

brw-rw---- 1 root cdrom 22, 0 Apr 24 21:02 /dev/hdc
```

You've to be in the cdrom group too.

----------

## Joseph_sys

 *dgaffuri wrote:*   

>  *Joseph_sys wrote:*   I just installed 2.1.4-r1 on AMD64 but eject still doesn't work. 
> 
> It should, does the device have the proper permissions?
> 
> ```
> ...

 

That is what I have.

But I'm experiencing a strange behavior lately.  Sometimes when I start booting the DVD tray opens and stays open, it will not close when I push it back or press the button.

The same things is happening after booting, the button is not responding, when I issue a command eject /dev/hdc and the tray opens it stays open and it will not close. 

Is the DVD gone (BenQ) I guess I got what I payed for!

----------

## dgaffuri

Check if eject works with root, the change is to allow normal users with write permission to the device to run a SCSI eject command.

----------

## Joseph_sys

 *dgaffuri wrote:*   

> Check if eject works with root, the change is to allow normal users with write permission to the device to run a SCSI eject command.

 

as root:

# eject -v /dev/hdc

eject: device name is `/dev/hdc'

eject: expanded name is `/dev/hdc'

eject: `/dev/hdc' is not mounted

eject: `/dev/hdc' is not a mount point

eject: `/dev/hdc' is a multipartition device

eject: trying to eject `/dev/hdc' using CD-ROM eject command

eject: CD-ROM eject command failed

eject: trying to eject `/dev/hdc' using SCSI commands

eject: SCSI eject succeeded

It makes me wander if there is somethig wrong with me DVD.  It works correctly on my x86 machine but on AMD64 the DVD open before the kernel boots and it stays open.  It acks kind of strange for some reason.

----------

