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. ?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
No, you don't need to run
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
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