We have BBB based custom board with kernel 3.12 running on it.
I have doubt regarding umount and & sync.
Lets say a script is umounting a partition, Does it require to run sync
command before umount
to complete pending writes. ?
We have BBB based custom board with kernel 3.12 running on it.
I have doubt regarding umount and & sync.
Lets say a script is umounting a partition, Does it require to run sync
command before umount
to complete pending writes. ?
No, you don't need to run sync
before umount
. umount
will complete all pending writes before it actually unmounts the filesystem. It will also refuse to unmount if some process is still using the filesystem, e.g. as current working directory.
Edit: Unmounting is mostly handled in fs/namespace.c
. You won't find any explicit call to sync
there, but you'll see comments along the line of "mark this mountpoint for unmount, refuse any further operations on it, and if all operations are done, unmount". You can also see explicit in-use checks.
You can easily test yourself that umount
really does finish all pending operations: Mount some slow USB stick, copy a large file to it, and directly call umount
after cp
. It will take several seconds before you see a new prompt, and if you run dstat
etc. in another window, you'll see the write operations that are still going on. That's exactly the same behaviour as if you've typed sync
.
sync
then you would have to block processes from writing first, or else it may not besync
ed by the time you got to theunmount
(a race condition). – ctrl-alt-delor Feb 18 '17 at 11:57umount -l
will let the command complete if something is still using the filesystem and wait in the background for the process to finish, then quietly unmount it. – Mio Rin Feb 18 '17 at 13:30