One of many issues with umount -l
is that there's way to know when it has completed.
Is there a way to:
- Know all writing processes have finished and all data has been written to disk.
- Prevent future writes
One of many issues with umount -l
is that there's way to know when it has completed.
Is there a way to:
Mount the filesystem's device again at a new location, say /mnt
:
mount /dev/device /mnt
Then use:
mount -o remount,ro /mnt
This will attempt to remount the filesystem on the device read-only.
If this succeeds, there is no more data being written to the disk because mount -o remount,ro
is guaranteed to fail if there are files open for writing.
If the remount,ro
fails, then use:
lsof +f -- /dev/<devicename> | awk 'NR==1 || $4~/[0-9]+[uw -]/'
to list processes which are blocking the remount.
If you are paranioid and want to prevent any future remount read-write, you can:
blockdev --setro /dev/device
Note: It seems that even mounting the device ro
the first time may be sufficient. I get mount: /tmp/mountpoint: /dev/loop0 already mounted or mount point busy.
if there are processes writing.