[udev] Disks are not unmounted when physical eject button is used

Bug #1168742 reported by Christopher Rogers on 2013-04-13
This bug affects 9 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Martin Pitt

Bug Description

In 13.04, disks (DVDs, CDS) are not unmounted when ejected via the hardware button on the drive. After ejecting disks via the hardware button, an entry for the disk still shows up in the file manager, and shows when I run df. If I do a soft eject (ie from the right click menu from the icon on the launcher), however, everything works properly.

Just as a note, as per https://wiki.ubuntu.com/Bugs/FindRightPackage#Hardware_Malfunctions, I attempted to report this using ubuntu-bug storage, however there is not an option dealing with unmounting devices, and clicking other tells you that you should run ubuntu-bug again with a specific package name. In an attempt to get this to a semi-relevant audience, I ended up just saying that a disk wasn't auto-mounted, clicking through the next few popups, and ended up here. If this isn't the right place to report this bug, I apologize.

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: linux-image-3.8.0-17-generic 3.8.0-17.27
ProcVersionSignature: Ubuntu 3.8.0-17.27-generic 3.8.6
Uname: Linux 3.8.0-17-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 2.9.2-0ubuntu8
Architecture: amd64
 /dev/snd/controlC1: chris 1590 F.... pulseaudio
 /dev/snd/controlC0: chris 1590 F.... pulseaudio
Date: Sat Apr 13 12:54:33 2013
GvfsMonitorLog: Monitoring events. Press Ctrl+C to quit.
HibernationDevice: RESUME=UUID=bd2c881c-7bf8-4996-8b05-7efbd9852333


InstallationDate: Installed on 2013-03-26 (18 days ago)
InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Alpha amd64 (20130325)
MarkForUpload: True
 PATH=(custom, no user)

ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-3.8.0-17-generic root=UUID=f44b6481-8a06-4cf1-a494-0e4c233720c8 ro quiet splash
 linux-restricted-modules-3.8.0-17-generic N/A
 linux-backports-modules-3.8.0-17-generic N/A
 linux-firmware 1.105
SourcePackage: linux
Symptom: storage
 monitor will print the received events for:
 UDEV - the event which udev sends out after rule processing
 Monitoring the udisks daemon. Press Ctrl+C to exit.
 12:54:42.343: The udisks-daemon is running (name-owner :1.39).
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 04/05/2012
dmi.bios.vendor: American Megatrends Inc.
dmi.bios.version: G55VW.206
dmi.board.asset.tag: ATN12345678901234567
dmi.board.name: G55VW
dmi.board.vendor: ASUSTeK COMPUTER INC.
dmi.board.version: 1.0
dmi.chassis.asset.tag: No Asset Tag
dmi.chassis.type: 10
dmi.chassis.vendor: ASUSTeK COMPUTER INC.
dmi.chassis.version: 1.0
dmi.modalias: dmi:bvnAmericanMegatrendsInc.:bvrG55VW.206:bd04/05/2012:svnASUSTeKCOMPUTERINC.:pnG55VW:pvr1.0:rvnASUSTeKCOMPUTERINC.:rnG55VW:rvr1.0:cvnASUSTeKCOMPUTERINC.:ct10:cvr1.0:
dmi.product.name: G55VW
dmi.product.version: 1.0
dmi.sys.vendor: ASUSTeK COMPUTER INC.

description: updated

This change was made by a bot.

Changed in linux (Ubuntu):
status: New → Confirmed

Would it be possible for you to test the latest upstream kernel? Refer to https://wiki.ubuntu.com/KernelMainlineBuilds . Please test the latest v3.9 kernel[0]. You will need to install both the linux-image and linux-image-extra .deb packages.

If this bug is fixed in the mainline kernel, please add the following tag 'kernel-fixed-upstream'.

If the mainline kernel does not fix this bug, please add the tag: 'kernel-bug-exists-upstream'.

If you are unable to test the mainline kernel, for example it will not boot, please add the tag: 'kernel-unable-to-test-upstream'.
Once testing of the upstream kernel is complete, please mark this bug as "Confirmed".

Thanks in advance.

[0] http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.9-rc7-raring/

Changed in linux (Ubuntu):
importance: Undecided → Medium
status: Confirmed → Incomplete

Tested it with the daily build of the 3.9 kernel, and the bug still exists. I've added the kernel-bug-exists-upstream tag and changed the status.

tags: added: kernel-bug-exists-upstream
Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Phillip Susi (psusi) on 2013-04-22
affects: linux (Ubuntu) → udisks2 (Ubuntu)
Changed in udisks2 (Ubuntu):
status: Confirmed → New
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in udisks2 (Ubuntu):
status: New → Confirmed

I confirm this problem

andrew (ham-m) wrote :

Confirmed on Ubuntu Gnome 13.04 64-bit (3.8.0-32-generic)

It causes all kinds of DVD playback problems see


SergeiS (sergei-redleafsoft) wrote :

Confirmed on Ubuntu 13.04 64bit (3.8.0-33-generic).

What a PITA bug, I was backing up my family video dvds using dd command and noticed that the size of the images is always the same. I eventually tried playing and iso file and of course some of the chapters weren't playing.

No workaround yet other than using "eject" button in Nautilus?

I have a problem with some media types: DVD+R DL, DVD-R, DVD+RW and CD-R. Only audio CD works fine. I will explain...

audio cd (I think this is the correct behavior):
Insert the media in optical drive
the media is mounted and read without any problem
Press the optical device button to eject the audio cd
Nautilus automatically goes to home folder and the optical device icon disappears from nautilus left side and gnome-shell tray
insert other media type
the media is mounted and read without any problem again

DVD+R DL, DVD-R, DVD+RW and CD-R (annoying behavior)
insert the media
the media is mounted and read without any problem
press optical device button to eject the media
nautilus keeps showing the media content (???) and device icon on nautilus left side changes to "CD/DVD Drive"
insert other media immediately (except audio cd)
the system recognize the media because device icon name on nautilus changes to the media label (on gnome-shell tray is still "CD/DVD Drive"), but nautilus shows no file (???)
if I eject and reinsert the media using the optical device button I have the same result
I need eject the media using nautilus or gnome-shell icon to access the new media files

After eject problematic media I run below command

mount|grep sr0

My system says that the media is still mounted.
I insert other media and run the command again and it says that the previous media is mounted.
My system is not umount/mount media correctly.

My optical device: BenQ DW1640 (IDE) with latest firmware (BSRB)

Created attachment 92238
[PATCH] Check if cdrom drive has media on cleanup

When cleanup is run, it is supposed to remove lingering mounts.
That probably works fine for card readers etc. since there's
a partition exposed for the drive but fails for optical media.
As a result, when mounted and user presses the drive eject
button, tray is ejected but mounts lives on.

This patch adds a special check for CDROM drives and looks for
active media.


The test is highly cdrom-specific and should not break anything else. On the other hand, not sure if there are e.g. card readers not exposing the "partition" device type, only presenting itself as a "disk". Haven't tested that, my concern was a flash medium having no partition table, used directly. Or, a ZIP drive (ATAPI vs. floppy mode) and such...

Hmm, I'm not sure this is the right fix so please don't commit it. I'll try to reproduce this...

(In reply to comment #2)
> Hmm, I'm not sure this is the right fix so please don't commit it. I'll try
> to reproduce this...

Reproducing this is easy:
1. Insert CD/DVD media
2. Let Gnome/gvfs automount it (clean system, defaults)
3. Press the eject button on the drive
4. Watch the mount staying alive

Note that udisks cleanup routine properly registers the event, it's all about matching the cleanup conditions.

I have the same problem. Can you solve please? Thanks.

Phil Wright (jozubiso) wrote :

This bug is still present in Ubuntu 14.04 3.13.0-32-generic (both 32bit and 64bit).

This makes Ubuntu and derivatives problematic for newbie users who expect cd/dvd ejection to just work as it does in Windows. Having to manually unmount the drive before inserting another disc is a poor solution.

Phil Wright (jozubiso) wrote :

After trawling the internet for possible solutions, I have put together a kludgey script workaround to automatically unmount a dvd when it's ejected via the dvd drive eject button.

This kludge assumes the dvd drive is /dev/sr0 and the shell script uses /bin/sh; customise according to your system configuration. It uses the utility 'dvd+rw-mediainfo'.

1. Create a udev rules file '/etc/udev/rules.d/61-sr0-change.rules' and add the line:

KERNEL=="sr0", ACTION=="change", RUN+="/usr/local/bin/sr0_change.sh"

and save the file.

2. Create a shell script '/usr/local/bin/sr0_change.sh'. Add the following lines:

dvd+rw-mediainfo /dev/sr0 > /dev/null
if [ "$n" -ne '0' ];then eject /dev/sr0;fi

3. Save the shell script file and change the file permissions to make it executable.

That's it. It's ugly, but it works on my system. I hope it helps.

Phil Wright (jozubiso) wrote :

Further to my #10 comment, I forgot to point out that the utility 'dvd+rw-mediainfo' is in the package 'dvd+rw-tools' in the Ubuntu repositories.

Phil Wright (jozubiso) wrote :

Further again to my #10 comment:

My apologies, the shell script '/usr/local/bin/sr0_change.sh' above posted only works for dvd media.

The following should (?) work for other media (eg. audio CDs) as well:

dvd+rw-mediainfo /dev/sr0 > /dev/null
if [ "$n" -eq '251' ];then eject /dev/sr0;fi

*** Bug 84374 has been marked as a duplicate of this bug. ***

(In reply to Tomas Bzatek from comment #3)
> (In reply to comment #2)
> > Hmm, I'm not sure this is the right fix so please don't commit it. I'll try
> > to reproduce this...
> Reproducing this is easy:
> 1. Insert CD/DVD media
> 2. Let Gnome/gvfs automount it (clean system, defaults)
> 3. Press the eject button on the drive
> 4. Watch the mount staying alive
> Note that udisks cleanup routine properly registers the event, it's all
> about matching the cleanup conditions.

Thomas: can you not commit your patch? This is a much needed fix, and, even if your fix is not perfect, there has been no movement towards improvement in over 6 months.

rogue-spectre (rogue-spectre) wrote :

Update to Phil Wright solution, for a more general context

1 - Create a udev rules file '/etc/udev/rules.d/61-sr-change.rules' and add the line :

KERNEL=="sr*", ACTION=="change", RUN+="/usr/local/bin/sr_change.sh %n"

2 - And create the script '/usr/local/bin/sr_change.sh' :


if [ $# -eq 1 ]

dvd+rw-mediainfo $source > /dev/null

 if [ "$n" -eq '251' ] then
        umount $source
exit 0

tags: added: trusty
Martin Pitt (pitti) wrote :

There is no robust way how udisks could do this, but on the upstream systemd list we discussed how to do this cleanup under systemd. For udev under upstart there is a hack to call "eject" instead of "cdrom_id --eject" in the udev rule for the eject request, but this relies on udev not running under an unshared mount namespace (i. e. a patch we have in Debian/Ubuntu). I'll look into fixing this the proper way.

affects: udisks2 (Ubuntu) → systemd (Ubuntu)
Changed in systemd (Ubuntu):
status: Confirmed → Triaged
summary: - Disks are not unmounted when physical eject button is used
+ [udev] Disks are not unmounted when physical eject button is used

This was discussed recently on the systemd (udev) mailing list:


After a lot of back and forth, it was decided that the most robust fix under systemd is


For the record, for distros without systemd it is easiest to adjust /lib/udev/rules.d/60-cdrom_id.rules like this:

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

Changed in systemd (Ubuntu):
assignee: nobody → Martin Pitt (pitti)
status: Triaged → In Progress
Changed in systemd:
importance: Unknown → Medium
status: Unknown → Confirmed
Changed in systemd:
status: Confirmed → Fix Released
Launchpad Janitor (janitor) wrote :
Download full text (7.6 KiB)

This bug was fixed in the package systemd - 218-10ubuntu1

systemd (218-10ubuntu1) vivid; urgency=medium

  [ Martin Pitt ]
  * Merge with Debian unstable. Remaining Ubuntu changes:
    - Hack to support system-image read-only /etc, and modify files in
      /etc/writable/ instead.
    - Keep our much simpler udev maintainer scripts (all platforms must
      support udev, no debconf).
    - initramfs init-top: Drop $ROOTDELAY, we do that in a more sensible way
      with wait-for-root. Will get applicable to Debian once Debian gets
      wait-for-root in initramfs-tools.
    - initramfs init-bottom: If LVM is installed, settle udev,
      otherwise we get missing LV symlinks. Workaround for LP #1185394.
    - Add debian/udev.lvm2.init: Dummy SysV init script to satisfy insserv
      dependencies to "lvm2" which is handled with udev rules in Ubuntu.
    - Provide shutdown fallback for upstart. (LP: #1370329)
    - debian/extra/ifup@.service: Additionally run for "auto" class. We don't
      really support "allow-hotplug" in Ubuntu at the moment, so we need to
      deal with "auto" devices appearing after "/etc/init.d/networking start"
      already ran. (LP: #1374521) Also, check if devices are actually defined
      in /etc/network/interfaces as we don't use Debian's net.agent.
    - ifup@.service: Drop dependency on networking.service (i. e.
      /etc/init.d/networking), and merely ensure that /run/network exists.
      This avoids unnecessary dependencies/waiting during boot and dependency
      cycles if hooks wait for other interfaces to come up (like ifenslave
      with bonding interfaces). (LP: #1414544)
    - Add Get-RTC-is-in-local-time-setting-from-etc-default-rc.patch: In
      Ubuntu we currently keep the setting whether the RTC is in local or UTC
      time in /etc/default/rcS "UTC=yes|no", instead of /etc/adjtime.
      (LP: #1377258)
    - Put session scopes into all cgroup controllers. This makes unprivileged
      user LXC containers work under systemd. (LP: #1346734)
    - Lower Breaks: to plymouth version which has the udev inotify fix in
    - Lower libappamor1 dep to the Ubuntu version where it moved to /lib.
    - Make failure of boot-and-services NSpawn.test_boot non-fatal for now.
      This currently fails when being triggered by Jenkins, but is totally
      unreproducible when running this manually on the exact same machine.

    Upgrade fixes, keep until 16.04 LTS release:
    - systemd Conflicts/Replaces/Provides systemd-services.
    - Remove obsolete systemd-logind upstart job.
    - Clean up obsolete /etc/udev/rules.d/README.

  * ifup@.service: Fix syntax error. (LP: #1421556, #1420601)

  [ Didier Roche ]
  * Add systemd-fsckd multiplexer and feed its output to plymouth. This
    provides an aggregate progress report of running file system checks and
    also allows cancelling them with ^C.
    (LP: #1316796; Closes: #775093, #758902)

systemd (218-10) experimental; urgency=medium

  * Pull latest keymaps from upstream git. (LP: #1334968, #1409721)
  * rules: Fix by-path of mmc RPMB partitions and don't blkid them. Avoids
    kernel buffer I/O errors and timeouts. (LP: #1333140...


Changed in systemd (Ubuntu):
status: Fix Committed → Fix Released

This problem is back in Fedora 23 64 bits.

This problem is back in Arch linux with systemd 229 too.

Changed in systemd:
status: Fix Released → Confirmed
Phil Wright (jozubiso) wrote :

The bug is still present in a new install of Xubuntu 16.04 (and presumably all the other *buntus using systemd 229), and this workaround still works:

sudo apt-get install dvd+rw-tools
echo 'KERNEL=="sr0", ACTION=="change", RUN+="/usr/local/bin/sr0_change.sh"' | sudo tee /etc/udev/rules.d/61-sr0-change.rules
cat << 'EOF' | sudo tee /usr/local/bin/sr0_change.sh
dvd+rw-mediainfo /dev/sr0 > /dev/null
if [ "$n" -ne '0' ];then eject /dev/sr0;fi

sudo chmod +x /usr/local/bin/sr0_change.sh
sudo reboot

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.