This question is a more specific "subquestion" of the one about side effects when two distros share a swap partition.

What will actually happen if I install two Linux distributions on my machine with shared swap partition, hibernate in one, and boot into the other? Will the other figure out that the swap data is invalid, or will it try to use it (probably with unpredictable consequences)?


It will use the swap partition, (especially) if it has an fstab entry for it.

However your problem is not only with the swap partition, but also with all other filesystem partitions. You're not allowed to mount any of them as long as they're still mounted by the hibernated system.

Only one OS is allowed to mount a filesystem at a time, and with Hibernation, the system is "still running". If you Hibernate, then boot in another OS, change filesystems, then reboot and resume the Hibernated OS that still remembers the old state of those modified filesystem... it all goes ka-boom.

* If you touch anything on disk between suspend and resume... 
*               ...kiss your data goodbye.

Source: https://www.kernel.org/doc/Documentation/power/swsusp.txt

If you cannot guarantee that the disks won't be touched, best to avoid Hibernation altogether.

  • 1
    Does this mean that even if i have separate swap partitions, if i want to enable hibernation, i should avoid having partitions writable by both operating systems?
    – Alexey
    Jun 5 '16 at 12:08
  • Yes, exactly that.
    – mattdm
    Jun 5 '16 at 13:03
  • 2
    @Alexey Not just that, but beware of mounting a partition that is used by a hibernating system, even if you're mounting read-only. For example, doing a read-only mount of an ext4 filesystem that wasn't cleanly unmounted (which is the case if it's in use by a hibernated system) replays the journal and writes to the disk, which breaks the hibernated system. Call mount -o ro,noload to mount a hibernated ext4 filesystem. Jun 5 '16 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.