# Unmounting USB pendrive but no sync before

## lorim

hi all, i've got this strange behavior of my system when i try to umount a pendrive via the dbus/hal/kde backend. i press "safely remove" and it unmounts immediatly, even if it is still syncing the content, while it should wait for the sync to complete before telling that it is unmounted.

this start happening after some packages upgrade, but i'm not able to tell what package brings the problem

i'm using kde-3.5.5 with sys-apps/dbus-0.62-r2, sys-apps/hal-0.5.7-r3, sys-apps/pmount-0.9.9

in /etc/fstab i cleared the line regarding the usb-device, because it seems to conflict with hal (i got "wrong fs, bad superblock...." error). without it i can access the device, write on it, even umount (after doing a sync via console)

thanks && sorry for my english   :Embarassed:   :Laughing: 

----------

## kEiNsTeiN

AFAIK  umount only umounts devices that are synched, and if they aren't, mount synchs them....

Or do you mean that KDE signalizes you can unplug your usbkey, and do so, but it wasn't really finished?

----------

## lorim

 *kEiNsTeiN wrote:*   

> AFAIK  umount only umounts devices that are synched, and if they aren't, mount synchs them....
> 
> Or do you mean that KDE signalizes you can unplug your usbkey, and do so, but it wasn't really finished?

 

yes... maybe i didn't explain well.

kde tell me i can unplug the device, but the data transfer is still in progress. while before that i-don't-know-what-package-upgrade, kde created a window with the transfer progress bar and only after the transfer's end it would tell me i can unplug the device.

----------

## kEiNsTeiN

If a little less performace doesn't kill you, I would mount the stich in synchronous mode, so your status-bar will always be correct and you can unplug the stick without unmounting it (you probably still shouldn't but who cares...), because the drive cache is deactivated. The cons are a lower lifetime and performace, because the FAT has to be updated for every file you _write_.

You can archieve sync mode by right-clicking the device in "media:/", properties, tab "mounting", activate button "synchronous", OK. done.

or in fstab the option "sync".

----------

## lorim

yes, i know the synchronous transfer mode, but i don't like it so much and i'm not going to use it...

still searching for a working solution with asynchronous transfer mode

anyway, thanks for the replies  :Very Happy: 

----------

## tjjalava

I have exactly the same problem here, "safely remove" unmounts my usb-devices immediately without waiting for the data to be actually synched to the disk. This started to happen after I upgraded KDE from version 3.5.2 to 3.5.5 and dbus from 0.61-r1 to 0.62-r2. Before, "safely remove" brought up a progress dialog to wait while the device was synched.

Asynchronous mode is not an option, updating my mp3-player would take forever..

I could maybe try to downgrade the kde to see if it's causing the problem.

----------

## tjjalava

Ok, found the reason for this. The problem is in kio_media_mounthelper. Somwhere between kde-3.5.3 and kde-3.5.4 the developers of kde decided to change the behaviour. Before, when called with -s option (as the "Safely remove"-menuitem does), kio_media_mounthelper first unmounted the drive and then ejected it. They dropped the unmount-part, so now it only does the ejecting. (The unmounting-part seems to be recently put back to the code, but it hasn't been merged into kde-ebuild yet)

So, simple solution for now is to edit the file "/usr/kde/3.5/share/apps/konqueror/servicemenus/media_safelyremove.desktop" and replace the line 

```

Exec=kio_media_mounthelper -s %u

```

with

```

Exec=kio_media_mounthelper -u %u && kio_media_mounthelper -e %u

```

Actually, the latter part of the command may not be necessary, but it won't harm either.

----------

## lorim

your workaround doesn't work on my machine.

when i try to "safely remove" the media, i got a "kio_media_mounthelper: no reply within specified time" error

----------

## Matteo Azzali

Hum, is one of the 2 solution (copy before and copy during unmount) capable of letting me choose

in which order to put the files in the device? I need more control on the order the files are written in

the device.....   :Confused:  (I could be fine with alphabetic order, for example, but random won't do....)

----------

## tjjalava

 *lorim wrote:*   

> your workaround doesn't work on my machine.
> 
> when i try to "safely remove" the media, i got a "kio_media_mounthelper: no reply within specified time" error

 

That's propably because unmounting your device is taking too long. In kde 3.5.2, kio_mounthelper opened a dialog when unmounting and this signaled kde that the application started ok. Now, mounthelper just does the unmounting in the background without signaling anything to the system. So, if the unmount operation takes too long, the application start timeout (which is something like 30 secs, I believe) exceeds and you'll get an error message. At least that's what I think is happening, maybe someone who really knows can correct me, if I'm wrong.

Anyway, current mounthelper sucks really bad, hopefully 3.5.6 will work better.

----------

## lorim

 *tjjalava wrote:*   

> [...]
> 
> Anyway, current mounthelper sucks really bad, hopefully 3.5.6 will work better.

 

let's wait...   :Wink: 

----------

## Scen

It seems to be fixed!

See here: http://websvn.kde.org/branches/KDE/3.5/kdebase/kioslave/media/mounthelper/kio_media_mounthelper.cpp?rev=601028&view=rev

----------

## tmazzoni

Well... not for me. I have KDE 3.5.6 but when I try to safely unmount my Memory Stick from the reader, now a message appears:

 *Quote:*   

> Unfortunately, the device system:/media/sdb1 (/dev/sdb1) named '2.0G Removable Media' and currently mounted at /media/sdb1 could not be unmounted. Unmounting failed due to the following error:
> 
> Volume mounted by uid UNKNOWN cannot be unmounted by uid 1000.

 

Before the upgrade to 3.5.6 it just didn't work... Is this a better behaviour?

----------

## Aysen

 *tmazzoni wrote:*   

> Well... not for me. I have KDE 3.5.6 but when I try to safely unmount my Memory Stick from the reader, now a message appears:

 Do you have sys-apps/pmount installed? For me, umounting in KDE is all messed up without it (although it's not a dependency... I don't know why).

----------

## 300zx

 *tjjalava wrote:*   

> Ok, found the reason for this. The problem is in kio_media_mounthelper. Somwhere between kde-3.5.3 and kde-3.5.4 the developers of kde decided to change the behaviour. Before, when called with -s option (as the "Safely remove"-menuitem does), kio_media_mounthelper first unmounted the drive and then ejected it. They dropped the unmount-part, so now it only does the ejecting. (The unmounting-part seems to be recently put back to the code, but it hasn't been merged into kde-ebuild yet)
> 
> So, simple solution for now is to edit the file "/usr/kde/3.5/share/apps/konqueror/servicemenus/media_safelyremove.desktop" and replace the line 
> 
> ```
> ...

 

I used

```

Exec=kio_media_mounthelper -u %u

```

I don't know why the eject option is needed, works great on my system without it.  I don't have pmount or ivman installed.

----------

## Aysen

 *Scen wrote:*   

> It seems to be fixed!

 I confirm. And the fixed version is already in Portage.

I've unmerged pmount, didn't change anything in /usr/kde/3.5/share/apps/konqueror/servicemenus/media_safelyremove.desktop and (u)mounting removable devices works fine in KDE now.

----------

## Matteo Azzali

 *tmazzoni wrote:*   

> Well... not for me. I have KDE 3.5.6 but when I try to safely unmount my Memory Stick from the reader, now a message appears:
> 
>  *Quote:*   Unfortunately, the device system:/media/sdb1 (/dev/sdb1) named '2.0G Removable Media' and currently mounted at /media/sdb1 could not be unmounted. Unmounting failed due to the following error:
> 
> Volume mounted by uid UNKNOWN cannot be unmounted by uid 1000. 
> ...

 

You need to change the uid in fstab to reflect the name of the user who's accessing usb, for example in my system

the name of the user is "pino", then in fstab:

 *Quote:*   

> 
> 
> /dev/sdb1               /mnt/rm         vfat    noauto,noexec,umask=000,uid=pino,gid=users,noatime,users,rw   0 0
> 
> 

 

note uid=pino and umask=000, those two mean permissions for everyone....

----------

## Antti Alien

 *Matteo Azzali wrote:*   

>  *tmazzoni wrote:*   Well... not for me. I have KDE 3.5.6 but when I try to safely unmount my Memory Stick from the reader, now a message appears:
> 
>  *Quote:*   Unfortunately, the device system:/media/sdb1 (/dev/sdb1) named '2.0G Removable Media' and currently mounted at /media/sdb1 could not be unmounted. Unmounting failed due to the following error:
> 
> Volume mounted by uid UNKNOWN cannot be unmounted by uid 1000. 
> ...

 

That's not it for me at least. Mount says that usb stick in /dev/sda1 is mounted to /media/sda1 with uid 1000, which is correct for the current user. Still KDE gives me that same error. The stick is unmounted just fine, but an error every time I'm using an usb stick is still annoying.

----------

