I have a luks-encrypted ext4 in a file which I use to store sensitive data (let us call this FS "inner"). The file itself is again on another ext4, which resides on a physical SSD. Let us call that FS "outer". The Inner FS is mounted using a loopback device pointing to the file on the Outer FS.
When I invoke sync(1), is it guaranteed that all pending writes of the Inner FS are persisted?
If the sync happens in an unfortunate order, it would be (in my understanding) possible that the following happens:
- Data is written to Inner FS.
- Outer FS cached writes get written to disk.
- Inner FS cached writes get written to the file on Outer FS.
- Writes from Inner FS on Outer FS are still in caches.
- Crash happens.
- Writes to Inner FS are lost despite happening-before a
Does sync guarantee that this does not happen, or do I have to invoke sync as many times as I have nested layers of file systems to be sure?
I am asking for Linux, but if POSIX has word on this, I’d be interested in that, too.
The Debian manpage on
sync(2) unfortunately does not have information on this case.