You are not logged in.

#1 2008-03-10 19:48:32

Benedict_White
Member
From: Sussex, UK
Registered: 2004-05-27
Posts: 331
Website

Flushing a USB memory stick

I am trying to do things with a USB memory stick. One purpose is to boot from it and use utilities on it to do various things on a machine.

So far I have got a bootable USB drive, by installing Arch to it.

However I am running into problems.

I have taken the drive out and mounted it in another Arch Linux box to put on some files, but now when I try and umount it I get "device is busy" and the drive will not dismount. I am concerned that the device is still being written too and do not want to leave corrupted files about.

Is there a way to ensure that all files that should have been written to the USB stick have been. Is there a way to make sure no files are cached?


Kind regards

Benedict White

Offline

#2 2008-03-10 20:03:02

valnour
Member
From: Cleveland, TN, USA
Registered: 2008-02-17
Posts: 84
Website

Re: Flushing a USB memory stick

Have you tried running "sync" and then unmounting?

Offline

#3 2008-03-10 21:12:57

Benedict_White
Member
From: Sussex, UK
Registered: 2004-05-27
Posts: 331
Website

Re: Flushing a USB memory stick

I have now, many thanks for the suggestion!

Alas, it did not work sad

It still reports device busy when I try to umount.


Kind regards

Benedict White

Offline

#4 2008-03-10 21:22:41

lilsirecho
Veteran
Registered: 2003-10-24
Posts: 5,000

Re: Flushing a USB memory stick

If you have booted on a USB drive, you cannot unmount it because it is "busy" as the boot device.


Prediction...This year will be a very odd year!
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit!     X-ray confirms Iam spineless!

Offline

#5 2008-03-10 21:33:00

Benedict_White
Member
From: Sussex, UK
Registered: 2004-05-27
Posts: 331
Website

Re: Flushing a USB memory stick

lilsirecho wrote:

If you have booted on a USB drive, you cannot unmount it because it is "busy" as the boot device.

Yes, I know, in this case it is not the boot device.

That said I do need to make sure any writes are committed before halting the system when it is the boot device.


Kind regards

Benedict White

Offline

#6 2008-03-10 21:34:05

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: Flushing a USB memory stick

lazy and/or forced unmounting (umount -l -f) gets rid of/overrides those warnings, and won't give any more access to it, but if something needs to be written to, too bad for the program.

If it's busy, you can check what's using it with lsof. If you've booted from it, though, lots of critical stuff is going to need access (which won't be happy or stable when you remove access).

edit:

sync

is enough to ensure that all write caches are flushed (so you don't loose written data).

Last edited by vogt (2008-03-10 21:35:18)

Offline

#7 2008-03-10 22:02:27

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,131

Re: Flushing a USB memory stick

... and be aware that every open shell that is in the mounted dir or a subdirectory of it keeps the device busy. This is also the case if you're in a "su" environment  and the user which is logged in in that shell is still in that dir. Sometimes it's that easy.


Haven't been here in a while. Still rocking Arch. smile

Offline

#8 2008-03-10 22:02:52

czar
Member
Registered: 2008-03-08
Posts: 115

Re: Flushing a USB memory stick

stupid solution but make sure you're not trying to umount while your still accessing it (cd out of /media/usb/ or whatever)

Offline

#9 2008-03-10 22:07:14

Benedict_White
Member
From: Sussex, UK
Registered: 2004-05-27
Posts: 331
Website

Re: Flushing a USB memory stick

vogt, Many thanks for the lsof tip.

I get the Doh! award, I was in a directory on the stick! sad smile


Kind regards

Benedict White

Offline

#10 2008-03-10 22:08:08

Benedict_White
Member
From: Sussex, UK
Registered: 2004-05-27
Posts: 331
Website

Re: Flushing a USB memory stick

Sigi and czar. I was in a directory on the stick!


Kind regards

Benedict White

Offline

Board footer

Powered by FluxBB