# Make CD eject button unmount

## scubed

I have my parents using Gentoo.  They are confused that the

eject button on the CD drive does not eject because the

CD is mounted.  Is there a simple way that I can set the

eject button to do:

```
#!/bin/sh

umount /mnt/cdrom

sleep 1

eject

```

or something like that?

That way, it will eject it if it is safe for it to.

----------

## superczar

what desktop environment are they using... 

could you just create a script much like that and place it on the desktop for them to double click?

they'll remember to click it as soon as the cdrom doesnt eject.

----------

## bfkeats

Use the ivman automounter.

http://gentoo-wiki.com/HOWTO_ivman

It will mount the cd when you insert it, and unmount it when you eject it. If you use KDE, a CD icon will appear on you desktop when the CD is inserted.

----------

## scubed

I already have put icons on my parents desktop for all sorts of different tasks,

such as "Download pictures from digital camera" and "Write pictures to CD".

It would be preferable to just be able to catch the eject button and do

something else.  Where does the eject button signal go to?

I would prefer not to use something that is desktop manager dependent.

I don't think that my parents need an automounter and it seems like overkill.

----------

## bfkeats

ivman is not dependent on KDE, but KDE has nice support for ivman.

----------

## halfgaar

On a sidenote, I noticed that my zipdrive's eject button doesn't work when mounted. Is it simply because it's an RW medium, which can't be synced before eject, by pressing the eject button?

----------

## dsd

 *Quote:*   

> Where does the eject button signal go to? 

 

there is no eject signal - that's the fun of it. the cdrom drive doesn't tell the host that a cd has been inserted, and does not tell the host when a cd is ejected.

the only way that automounting can be implemented is by repeatedly polling the device, several times every second. HAL/ivman/etc do exactly this.

as for the eject button being non-operational, this is because the operating system can tell the cdrom drive to "lock". when you mount the cd, linux locks the drive. when you unmount it, it unlocks it.

the locking behaviour can be customised. ivman explicitly disables the locking and (during the polling cycle) unmounts the drive soon after it detects that the media has been ejected.

----------

## halfgaar

Ah, since there are no events for eject, I guess that explains why the zip drive (which is RW, and therefore can have data in the cache) must still be locked, while RO media can safely be ejected and unmounted after the eject event.

----------

