umount and data is lost?

umount and data is lost?

Nadav Har'El nyh at math.technion.ac.il
Sun Nov 6 19:04:48 IST 2011


On Sat, Nov 05, 2011, Diego wrote about "umount and data is lost?":
> overcome otherwise). Before the reboot, I "umount" the proper partition and 
> then "sync".

I believe it is rather pointless to sync(1) after umount(1) as umount(1)
already writes all the buffered data for that filesystem before it
succeeds. You can see this behavior in action if you mount a slow USB
flash drive, write a lot of data to it, and immediately umount - the
umount often can take many seconds to finish, until all the data is
actually written to the drive.

> For some reason, on one machine we see that the data is not updated and the 
> original data is kept in the file. I konw empirically that if I add a 
> "sleep(5)" after the umount, and before the "reboot" the data is written to 
> the disk.

The only thing I can think of is that the actual hard disk hardware has
a write cache, and it is telling Linux it finished writing, while still
having a few sectors cached - and the physical poweroff is causing it to
loose its data.

Does "hdparm -F" perhaps help? (after the umount, before the reboot)

>  * again  the workaround is a "sleep(5)"

Is sleep(5) the minimum that works?

Nadav.

-- 
Nadav Har'El                        |                     Sunday, Nov 6 2011, 
nyh at math.technion.ac.il             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |If Barbie is so popular, why do you have
http://nadav.harel.org.il           |to buy her friends?



More information about the Linux-il mailing list