I have a question about dm-crypt.
Here is my situation. I have an encrypted partition mapped (encrypted in virtual device) using the cryptsetup command in Linux. I am opening the mapped virtual device in a c-program using the open() function.
Can i be sure that when i use the fsync() function all information will be written to the encrypted partition or is there some buffer in the dm-crypt driver?
I could not find much reference on this. Maybe someone can shed more light on this, as I have not grokked the source, but it seems as though a sync
writes to disk.
One point is the questions trim-with-lvm-and-dm-crypt where a sync
changes the disk content reliably, yet the cached content is only updated after a echo 1 > /proc/sys/vm/drop_caches
.
Another is the issue that sync
hangs on a suspended device, which indicates that the sync goes directly to the device.
A third is this Gentoo discussion where luksClose
is possible reliably after a sync
.
A fourth is this UL answer, which says
the rest of the stuff [dm-crypt] is in kernel and pretty heavily used, so it's probably fine
It may still be that all these are wrong, and it can happen that sync
does not write directly to the encrypted disk, but it seems unlikely.