You are not logged in.

#1 2011-04-10 20:57:08

jlindgren
Member
Registered: 2011-02-27
Posts: 260

Unmount DVD when pressing eject button on drive?

I'm running XFCE 4.8 and wondering if there's a way to have the system unmount a DVD and eject it when I press the physical button on the drive.  I seem to remember this working in 4.6 when Thunar's volume manager was running.  It is particularly annoying when I pop in a video DVD, play it in Totem (which mounts it), and then have to open a Thunar window to eject it.

Offline

#2 2011-04-11 04:36:50

msx
Member
From: solar.system/earth/ar/bue/mdp
Registered: 2010-08-08
Posts: 184
Website

Re: Unmount DVD when pressing eject button on drive?

Mmm... I don't use Xfce so I can tell very much but you can use the eject command to eject the CD/DVD tray:

To open the CD/DVD tray:
$ eject

To close it:
$ eject -t


Enjoying i3wm w/ lifebar + j4-dmenu-desktop + tab_windows / fish shell / Emacs / tmux / Konsole / KDE apps
Arch + Linux-libre kernel: ParabolaGNULinux.org

Offline

#3 2011-04-11 04:42:43

voidux
Member
Registered: 2010-02-03
Posts: 31

Re: Unmount DVD when pressing eject button on drive?

you should to unmount it first, and after that it will ejects by pressing the button on the drive.

Offline

#4 2011-04-11 06:41:03

swanson
Member
From: Sweden
Registered: 2011-02-05
Posts: 759

Re: Unmount DVD when pressing eject button on drive?

Eject -T toggles cdtray.

Offline

#5 2011-04-11 07:15:03

Korrode
Member
From: Australia
Registered: 2009-11-02
Posts: 110

Re: Unmount DVD when pressing eject button on drive?

The only thing that comes to mind is loading the cdrom kernel driver/module with the lockdoor=0 parameter.

How to do it is in this thread:
https://bbs.archlinux.org/viewtopic.php?pid=700549

...but AFAIK this doesn't "auto-unmount", it simply allows you to eject the media while it's still mounted, which could have negative ramifications. TBH I don't know how Linux/Arch will handle that being done, because I've never tried it. Maybe it will still unmount the filesystem in some kind of clean fashion despite the media being no longer present.


xfce | compiz | gmrun | urxvt | chromium | geany | aqualung | vlc | geeqie

Offline

#6 2011-04-11 14:52:48

jlindgren
Member
Registered: 2011-02-27
Posts: 260

Re: Unmount DVD when pressing eject button on drive?

Thanks for the replies, but none seem to be addressing the question.  I know how to unmount and eject the disk; what I'm trying to figure out is if there's a way to make this happen when I press the button on the drive.  Given that this used to work, I suppose the button must emit some kind of a signal, so I want to bind this to a command that will unmount and eject the disk.

Edit: I went and tried this on a system that still has XFCE 4.6, and it didn't work as I remembered, so I guess I just imagined that it used to work ...

Last edited by jlindgren (2011-04-11 15:06:44)

Offline

#7 2011-06-11 05:55:26

samsagax
Member
Registered: 2011-03-18
Posts: 34

Re: Unmount DVD when pressing eject button on drive?

Tried that solution:
added "cdrom.lockdoor=0" on grub.cfg
The eject button works now the way it should (ejecting the disk no matter what) and brought up an inconsistency wich is already acknowledge: Since the button does not unmount the drive... the files still show on a folder. That can lead to a lock or a lot of errors. GNOME 3 knows that and if there are no files it just "unmount" and deletes the directories without locking up, and pretends that nothing happened.
I think that the option to  lock up the cdrom tray is a way to prevent that inconsistency lock up some other desktop environment that don't handle it that way (not sure, just guessing).
I've only tested that on GNOME but hopefully a fix is comming our way in a kernel level as seen here: https://bugs.freedesktop.org/show_bug.cgi?id=34710

Offline

#8 2014-09-22 20:11:14

light0
Member
Registered: 2014-09-22
Posts: 2

Re: Unmount DVD when pressing eject button on drive?

I am surprised that this has not been fixed yet. This is actually a very annoying issue. On #archlinux on Freenode the point is met with apathy, with responses such as: "this is not how to use a computer". Well I disagree. Aside form having a wife who complains that DVDs 'do not always work properly', I myself would like hitting the eject button on the drive to be automatically followed by an unmount operation. To me this seems like ordinary functionality, not the exception from the norm. Why should I have to open a window and click an eject button or open a terminal and type eject when I want to put in the next DVD of a series? 

Symptoms to reproduce:

- enter DVD
- eject using DVD drive eject button
- enter new DVD
- $mount |grep sr0

You see old drive still mounted.

Worse, you get DVD read errors such as:

[ 2348.391264] end_request: I/O error, dev sr0, sector 12134268
[ 2348.391267] Buffer I/O error on device sr0, logical block 3033567

This bug is being addressed in Ubuntu. Someone wrote a kludge script to fix it, see:

https://bugs.launchpad.net/ubuntu/+sour … ug/1168742

The playback errors are examined here:

https://bugs.launchpad.net/ubuntu/+sour … mments=all

Offline

#9 2014-09-25 10:08:04

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: Unmount DVD when pressing eject button on drive?

light0 wrote:

Someone wrote a kludge script to fix it

I am not sure the script solves the issue; the command 'eject /dev/sr0', in the script called by the udev rule, doesn't work for me if the device was busy before the eject button was pushed. Because the umount command called by eject will not operates in this case and the mount point stays there.

I think this is a bug in the default udev rule '/usr/lib/udev/rules.d/60-cdrom_id.rules' which ejects the CD/DVD when the button is pressed even when a file system on it is mounted and even if it is busy! This rule should be changed (or the cdrom_id binary) to not act in these cases.
Presently I think the only way to work around this, is to comment out the line:

ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdrom_end"

To do that:

# cp /usr/lib/udev/rules.d/60-cdrom_id.rules /etc/udev/rules.d
# cd /etc/udev/rules.d
# vim 60-cdrom_id.rules
# diff 60-cdrom_id.rules /usr/lib/udev/rules.d/60-cdrom_id.rules
12c12
< #ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdrom_end"
---
> ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdrom_end"
# udevadm control --reload

The rule in /etc/udev will take precedence over the one in /usr/lib/udev and will not be overwritten by an systemd update.

Edit: In fact this is not the solution either; see next post.

Last edited by berbae (2014-09-26 12:58:28)

Offline

#10 2014-09-26 12:57:37

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: Unmount DVD when pressing eject button on drive?

Commenting out the line in the 60-cdrom_id.rules file is not working as expected, and so this is not a good way either to work around the forced ejection of CD/DVD by the eject button, even if the disk is mounted and busy.

With the commented line in the rule, the CD/DVD is not physically ejected BUT it is still considered not present by the system or udisks, as if it was effectively ejected.
So the disk stays in place but nothing can be done with it: udisks cannot mount or unmount it any longer; only the physical ejection is possible then, using the system 'eject' command or using 'udisksctl eject /dev/sr0'.

Curiouly when the line is uncommented, the disk is forced ejected by the button, but its file system interface is not removed and continues to be seen by the system or udisks. This is pretty buggy.

So I reverted the udev rule to its original state.

Presently I have no satisfying workaround to cope with this bug.

Offline

Board footer

Powered by FluxBB