Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Joe Beanfish Newsgroups: comp.os.linux.development.apps Subject: Re: Question about umount and sync Date: Tue, 19 Aug 2014 13:29:05 +0000 (UTC) Organization: A noiseless patient Spider Lines: 35 Message-ID: References: <11bbe6f7-4eb8-4ae2-999f-9a7244b99d3e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 19 Aug 2014 13:29:05 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="81ed0dc13fb27562fd00684208ab89c6"; logging-data="14006"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+R9yKFaaHmi+TzTKM0+eAj4dedMcYFCuY=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:g3iLm7m2j5sT204BzuYMzTP14yc= Xref: csiph.com comp.os.linux.development.apps:748 On Mon, 18 Aug 2014 12:58:35 -0700, ameliusje wrote: > On Friday, June 29, 2012 9:47:23 PM UTC+2, Joe Beanfish wrote: >> On 06/29/2012 12:44 PM, Jan Panteltje wrote: >> > Question about umount and sync >> > >> > In the long ago past you could type 'sync' 3 times to make sure a >> > disk >> > was umounted.. >> > Then later I used umount, and it returned when all data was written. >> > >> > But I notice on my new 16GB USB sticks that the busy light just keeps >> > flashing >> > for up to a minute after umount and sync have long returned. >> > So what is a reliable way to umount these things from for exmaple a >> > script, >> > and be sure before allowing the user to unplug such an USB stick? >> >> umount has always been and still is the way to unmount. It will call >> sync then detach the filesystem from the OS in a safe way so there's >> no lost data. Sync just flushes the buffers. No amount of syncing does >> or ever did properly detach a filesystem from the OS. Pure luck kept >> you out of trouble using that technique. >> >> The ongoing activity is probably the USB bus probing etc. Don't worry >> about that. Umount is definitive. > > But this raises the question: what good is sync if it does not properly > flush filesystem-related data too? > What's the use for sync then? It does sync the data. But until unmounted the filesystem is still in use and may have more data and meta data written at any time. So depending on the filesystem type and timing you may get away with sync-and-yank but it's highly inappropriate. "Sync 3 times" was never appropriate even if some people did it before because they were too lazy to umount correctly.