2004-11-24 09:27:26

by Raj

[permalink] [raw]
Subject: Delay in unmounting a USB pen drive

SuSE kernel 2.6.5:

My USB pen drive has a vfat FS. When i transfer some files & try to
unmount the drive ( umount /mnt ) , the command appears hung. CTRL+C also
does not work. Only later did i realise that it was actually taking a
longer time ( 10 - 15 sec )
to unmount.

My questions are:
- Why is it taking a long time to unmount ?
- Is it safe to remove the pen drive from it's slot when the umount is still in
progress ?? ( I tried this the first time & maybe lucky me, the
files copied were fine )

TIA
--
######
raj
######


2004-11-24 09:34:31

by Anton Altaparmakov

[permalink] [raw]
Subject: Re: Delay in unmounting a USB pen drive

On Wed, 2004-11-24 at 14:55 +0530, Raj wrote:
> SuSE kernel 2.6.5:
>
> My USB pen drive has a vfat FS. When i transfer some files & try to
> unmount the drive ( umount /mnt ) , the command appears hung. CTRL+C also
> does not work. Only later did i realise that it was actually taking a
> longer time ( 10 - 15 sec )
> to unmount.
>
> My questions are:
> - Why is it taking a long time to unmount ?
> - Is it safe to remove the pen drive from it's slot when the umount is still in
> progress ?? ( I tried this the first time & maybe lucky me, the
> files copied were fine )

You are mounting with async flag (or this is the default) which means
that all the unwritten data is synced when you do umount. You can
verify this by typing "sync" waiting for that to complete and then the
umount should be immediate.

You can change this by using the "sync" option to mount which will cause
data to be written synchronously and the umount will be instantaneous.
Note that this will cause device write to be _much_ slower!

One thing is certain, do NOT unplug before the umount completes or you
will corrupt your fs on the stick for sure.

Best regards,

Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/

2004-11-24 09:39:52

by Colin Leroy

[permalink] [raw]
Subject: Re: Delay in unmounting a USB pen drive

On 24 Nov 2004 at 14h11, Raj wrote:

Hi,

> - Why is it taking a long time to unmount ?

It's syncing last writes

> - Is it safe to remove the pen drive from it's slot when the umount is still in
> progress ?? ( I tried this the first time & maybe lucky me, the
> files copied were fine )

Lucky you :) If your key is fat or vfat, you could try these two patches
and mount your USB key with -o sync option, your feedback interests me.
It should make the copies to key slower, but the umount immediate.

--
Colin


Attachments:
(No filename) (519.00 B)
fat_sync.patch (2.32 kB)
vfat_sync.patch (2.35 kB)
Download all attachments

2004-11-24 09:51:06

by Raj

[permalink] [raw]
Subject: Re: Delay in unmounting a USB pen drive

> You can change this by using the "sync" option to mount which will cause
> data to be written synchronously and the umount will be instantaneous.
> Note that this will cause device write to be _much_ slower!
>

Tried 'mount -o sync /dev/sda /mnt' . After a 57MB file copy, i unmount. Still
it takes a lot of time.

> One thing is certain, do NOT unplug before the umount completes or you
> will corrupt your fs on the stick for sure.

I shall remember this !. Thx very much.

--
######
raj
######

2004-11-24 09:59:50

by Raj

[permalink] [raw]
Subject: Re: Delay in unmounting a USB pen drive

> Lucky you :) If your key is fat or vfat, you could try these two patches
> and mount your USB key with -o sync option, your feedback interests me.
> It should make the copies to key slower, but the umount immediate.

Yes, my key is vfat. I shall try out the vfat patch & post the
results. It might
take some time, coz i am building a 2.9 gnome right now. Will keep the list
posted with the results.

Thx

--
######
raj
######

2004-11-24 10:07:00

by Colin Leroy

[permalink] [raw]
Subject: Re: Delay in unmounting a USB pen drive

On 24 Nov 2004 at 15h11, Raj wrote:

Hi,

> > Lucky you :) If your key is fat or vfat, you could try these two patches
> > and mount your USB key with -o sync option, your feedback interests me.
> > It should make the copies to key slower, but the umount immediate.
>
> Yes, my key is vfat. I shall try out the vfat patch & post the
> results. It might take some time, coz i am building a 2.9 gnome right
> now. Will keep the list posted with the results.

Apply also the fat patch, vfat uses fat.

--
Colin

2004-11-24 12:23:12

by bert hubert

[permalink] [raw]
Subject: Re: Delay in unmounting a USB pen drive

On Wed, Nov 24, 2004 at 02:55:57PM +0530, Raj wrote:
> SuSE kernel 2.6.5:
>
> My USB pen drive has a vfat FS. When i transfer some files & try to
> unmount the drive ( umount /mnt ) , the command appears hung. CTRL+C also
> does not work. Only later did i realise that it was actually taking a
> longer time ( 10 - 15 sec )
> to unmount.

The data is only actually being written to the pen drive when you unmount.
To make unmounting fast, either mount with -o sync, or run 'sync' before
umounting.


> - Is it safe to remove the pen drive from it's slot when the umount is still in
> progress ?? ( I tried this the first time & maybe lucky me, the
> files copied were fine )

Try reading them - you will find emtpiness.

--
http://www.PowerDNS.com Open source, database driven DNS Software
http://lartc.org Linux Advanced Routing & Traffic Control HOWTO