GNOME Bugzilla – Bug 599448
Safely removing a Sandisk Cruzer USB stick results in an error
Last modified: 2009-10-27 10:13:05 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")
Created attachment 146136 [details] After sefely removing the drive
Created attachment 146137 [details] screenshot before safely remove
Created attachment 146138 [details] screenshot after safely remove
Thanks for all the information. In the future please attach each file separately so it's easier to view in a browser.
(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.
Filed as https://bugs.freedesktop.org/show_bug.cgi?id=24708
> 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.
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)
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.