After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 599448 - Safely removing a Sandisk Cruzer USB stick results in an error
Safely removing a Sandisk Cruzer USB stick results in an error
Status: RESOLVED NOTGNOME
Product: gvfs
Classification: Core
Component: [obsolete] gdu volume monitor
1.4.x
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2009-10-23 21:18 UTC by Alexander Gitter
Modified: 2009-10-27 10:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Outputs just after plugging in the usb stick (4.10 KB, application/x-gzip)
2009-10-23 21:18 UTC, Alexander Gitter
Details
After sefely removing the drive (3.39 KB, application/x-gzip)
2009-10-23 21:20 UTC, Alexander Gitter
Details
screenshot before safely remove (39.57 KB, image/png)
2009-10-23 21:21 UTC, Alexander Gitter
Details
screenshot after safely remove (46.94 KB, image/png)
2009-10-23 21:21 UTC, Alexander Gitter
Details

Description Alexander Gitter 2009-10-23 21:18:43 UTC
Created attachment 146135 [details]
Outputs just after plugging in the usb stick

I'm using a Sandisk Cruzer with "U3 Smart Technology". Those USB sticks come
with two partitions - one gets mounted as a "normal" USB stick, whereas the
other partition is mounted as CD-Rom.
When I select "Safely Remove Drive" from nautilus' context menu for the USB
stick, the device gets unmounted and powered down. However, the CD-Rom icon is
still present in nautlis with only the "Unmount" option given. Trying to
"Unmount" will raise the error message: "umount: /media/cdrom2 mount disagrees
with the fstab".

Find attached the output of following commands:
- cat /etc/fstab
- cat /proc/mounts
- cat /etc/mtab
- devkit-disks --dump
- tree /dev/disk
- gvfs-mount -li

(before_remove.tgz is just after the stick was plugged in; after_remove.tgz
contains the outputs after I chose "Safely Remove Drive")
Comment 1 Alexander Gitter 2009-10-23 21:20:14 UTC
Created attachment 146136 [details]
After sefely removing the drive
Comment 2 Alexander Gitter 2009-10-23 21:21:20 UTC
Created attachment 146137 [details]
screenshot before safely remove
Comment 3 Alexander Gitter 2009-10-23 21:21:46 UTC
Created attachment 146138 [details]
screenshot after safely remove
Comment 4 David Zeuthen (not reading bugmail) 2009-10-23 21:37:09 UTC
Thanks for all the information. In the future please attach each file separately so it's easier to view in a browser.
Comment 5 David Zeuthen (not reading bugmail) 2009-10-23 21:53:05 UTC
(Adding Martin Pitt to the Cc since he looks after these bits in Ubuntu)

The reason that the cdrom sticks around is because of this line in /etc/fstab

 /dev/scd1 /media/cdrom2 udf,iso9660 user,noauto,exec,utf8 0 0

This line is really wrong - first of all, it uses the device '/dev/scd1' which actually just means "the second optical drive detected". Who added this line? If your distribution (typically the OS installer) did, you need to tell them this makes no sense. Further, it is unnecessary with modern desktops like GNOME and KDE that will create mountpoints as needed.

Anyway, what happens is this

 - The device has two LUNs (what you call two partitions)

 - The first LUN is a mass-storage device (sd*), the second is an optical
   drive (sr*). When you plug it /dev/sdb and /dev/scd1 is created (the
   kernel just picks the first available letter/number)

 - The desktop automounter (e.g. Nautilus) automounts both /dev/sdb1 and
   /dev/scd1. Since /dev/scd1 appears in /etc/fstab DeviceKit-disks will
   call mount(8) as the calling user.

 - Detaching (e.g. safely removing) a single LUN (the non-CD one) has the 
   side-effect that both LUNs become disconnected.

 - Since you detach /dev/sdb drive the desktop bits are careful to unmount
   all partitions from /dev/sdb (e.g. /dev/sdb1). However it doesn't know
   that /dev/scd1 will also go away (it can't know this unfortunately).

 - so /dev/sdb1 is properly unmounted

 - the power is removed and both LUNs disappear

 - if /dev/scd1 wasn't mounted via /etc/fstab (e.g. mounted by DKD with
   DKD maintaining the mount point) then DKD would have force/lazy-
   unmount /dev/scd1. But since it is mounted via /etc/fstab we refuse
   to be so clever

   (the philosophy is that if the user went through the trouble of
    specifying the device in /etc/fstab we shouldn't do policy like
    autounmounting and other "policy things")

So that's why it's still mounted. If you simply remove the bad line in /etc/fstab this problem will go away. If your OS added this line for you, you should probably make them aware that this is a problem (Martin?).

We could make DeviceKit-disks lazy/force-unmount things mounted via /etc/fstab if, and only if, it is mounted through DeviceKit-disks - such as in this example. I will open a bug against DKD for this feature and post the bug number here. Thanks.
Comment 6 David Zeuthen (not reading bugmail) 2009-10-23 21:55:43 UTC
Filed as https://bugs.freedesktop.org/show_bug.cgi?id=24708
Comment 7 David Zeuthen (not reading bugmail) 2009-10-23 21:58:06 UTC
> Trying to "Unmount" will raise the error message: "umount: /media/cdrom2
> mount disagrees with the fstab".

And this, btw, is a bug in umount(8) as far as I can tell.
Comment 8 Alexander Gitter 2009-10-23 22:22:15 UTC
Thanks, your explanation sure helped.

> If your OS added this line for you, you should probably make them aware that this is a problem

Indeed, this seems to be an issue with the Ubuntu installer.
(https://bugs.launchpad.net/ubuntu/+source/partman-target/+bug/150872)
Comment 9 Martin Pitt 2009-10-27 10:13:05 UTC
David, thanks for pointing out. We still add CD-ROMs to fstab because of some legacy issues, but we already planned not to do that any more in the next Ubuntu release (10.04) since we now have a better solution for apt CD-ROM sources.