I've successfully hibernated and resumed from swap partition in Linux. As far as I know, nothing was since swapped, nor has been the swap partition otherwise modified. That makes me think, that the hibernated image of previous state is still present and functional, only with modified header or something like that.

If that is true, how can I resume from such image? Tangent question is then whether it is advisable to try such thing, and what are some things it could break.

Obvious possibility to get this working is to recreate the process of hibernation but not actually save the image. After misguided fiddling with /sys/power/resume I came across this segment from https://www.kernel.org/doc/Documentation/power/swsusp.txt:

The resume process checks for the presence of the resume device,
if found, it then checks the contents for the hibernation image signature.
If both are found, it resumes the hibernation image.

From this I get the feeling, that this signature is what is written at hibernation to signify, that the device needs to be resumed and is wiped afterwards to prevent recurrent resuming. Even if that is true, I'm not skilled enough to get information about the signature from kernel code and hex-dump of swap partition is surprisingly sparse and full of structures I don't understand.

  • Hint for your tangential question: At the top of the link you provided, it says, BIG FAT WARNING: If you touch anything on disk between suspend and resume … kiss your data goodbye. – Deltik Aug 20 '19 at 23:05
  • I assumed, that statement is about the data in memory, but now I see I'm just retarded. Apparently data isn't even synced or flushed by default before hibernating. But the first question stands: If it is possible to get at least somewhat working system (even if it corrupts data on disk), how can it be done. – veprolet Aug 20 '19 at 23:21

I once made the mistake of doing something similar:

  1. Ran Windows as host OS, and a real installation of Linux as a guest OS in VirtualBox (via raw VMDK-mapped virtual device). I do this on a daily basis without issue, switching back and forth between the same Linux install running virtually on top of Windows, and actually on the bare metal, every few days.
  2. For some reason, Windows hibernated without my knowledge - which I pretty much never do manually, or allow to do (in order to avoid the following potential problems).
  3. I didn't use the machine for a while and forgot what state it was in previously. When firing back up, I just assumed it had all been shut down properly (VM cleanly shut down, then host OS cleanly shut down).
  4. I booted straight into Linux natively. Since this was essentially rebooting Linux after a hard crash, everything was more or less fine. Since I didn't even remember at the time that any of the previous had happened, I didn't notice anything unusual at all.
  5. I rebooted into Windows, thinking freshly, not noticing that it was restoring from hibernation.
    • This included loading back into memory, the VM running off the real Linux SSD.

The result? The Linux VM immediately crashed, and everything Linux was completely hosed, hopelessly beyond repair or recovery.

Even repairing and then accessing the ext4 filesystem by booting into a recovery CD first, resulted in an unbootable system with numerous randomly corrupted system and user data files that left me with no confidence in the integrity of anything.

The only sane thing to do from there, was reinstall Linux from scratch and restore data from backups.

For similar reasons, this is almost certainly what would happen if you booted to a previously stored hibernation file. (Though I'm not even sure how a properly functioning system would "let" you do that?)

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.