multi boot - Hibernating and booting into another System or Distribution: will my filesystems be corrupted? (superuser.com)
from HaraldvonBlauzahn@feddit.org to linux@lemmy.ml on 02 Aug 07:45
https://feddit.org/post/16707709

Short answer is: yes, as soon as more than one OS mounts a file system in read-write mode.

The kernel of a modern OS (I am generously including Windows here) caches file system data structures in memory. When you hibernate the computer, the content of that memory is written into a large file because that speeds-up a later restart.

Now, if you boot up another OS, and modify these partitions (without mounting them read-only), you alter the file systems data structures. That happens already when you view folders because this modifies access times stored in the inodes.

When you now shut down the second OS, and resume the first OS, the restarted kernel will have and use cached file system metadata which id loaded from the image into the kernel, that does not match that of the files on disk. And this causes file system corruption by definition.

#linux

threaded - newest

HaraldvonBlauzahn@feddit.org on 02 Aug 08:00 next collapse

And, this is another reason to use virtual machines, like GNOME Boxes or virt-manager. Put your sweet little Windows sleeping beauty in a VM so that it wakes up without scratches.

HaraldvonBlauzahn@feddit.org on 02 Aug 08:30 collapse

The other solution is to mount the shared, or borrowed file systems read-only. That works and is safe, but it could suck after a while for being impractical.

RoadTrain@lemdro.id on 02 Aug 10:00 next collapse

So, in fact, the short answer is no.

The answer is only yes if the question is “Hibernating and booting into another OS and modifying the same partition externally: will my filesystems be corrupted?”.

HaraldvonBlauzahn@feddit.org on 02 Aug 10:45 collapse

As I wrote above, for any safe access the file systems need to be mounted read-only (which is not the default). Otherwise, listing or viewing a file or directory already changes its metadata.

Cyber@feddit.uk on 02 Aug 18:59 collapse

noatime would help here

BCsven@lemmy.ca on 02 Aug 14:41 collapse

When you say hibernate do you mean sleep, because my understanding was proper hibernate writes the image to disk of the memory, and reads that back in on next boot. PC is totally off during proper hibernate

HaraldvonBlauzahn@feddit.org on 02 Aug 14:51 collapse

No, I mean hibernate, with the PC turned off. In sleep state, you return to the running kernel/OS, so no possibility to boot into another distro, therefore no risk of filesystem damage.

The crucial thing is that file systems need to be unmounted before they can be accessed by another distribution or OS.

see

askubuntu.com/…/dual-boot-and-sleep-hibernate-iss…