I can hibernate my laptop via pm-hibernate command without any problems. I want to achieve the same results manually. For this to work,
I need to take a snapshot and dump the contents of RAM+swap into a file (or
/dev/myswap2), like:dd if=/dev/fmem of=path/to/memory.imgResume from that file on the next boot, possibly by setting
resume=path/to/memory.imgoption within GRUB.
How can I take a snapshot of RAM and Swap in order to dump them into a file (or block device) for hibernation purposes?
Intention
I can
- take a snapshot of my whole filesystem while the system is running
- send the snapshots to a target disk
- replace necessary files (like
/etc/fstab,/etc/crypttab,/boot/grub/grub.cfgetc.) to make the target bootable
So, when I unplug my USB disk, it's ready to boot my (or similar) computer, which cuts the MTTR down to ~10 minutes in case of a disk failure. (~1 minute to boot and ~9 minutes to reopen my applications, rearrange the windows, etc. after login.)
My intention is that if I could take a snapshot of my RAM in the same way the pm-hibernate does and write it to the target disk's swap area, then I could boot into the exact same state of backup moment (as if my target disk is hibernated) in such a disk failure scenario.
/sys/power/statewill trigger an actual hibernate, is that correct? If so, I don't want to hibernate my computer during a backup operation, I only want to "simulate" it. – ceremcem Jan 05 '21 at 14:07