I wonder is it possible to capture the state of the machine without actually hibernating? The goal would be to make a "backup state", so if the system crashes, one could boot directly to a session with all the windows opened, all the tabs in the browser restored etc.
I think it might not be doable -- saving a snapshot of the memory, then changing the data on the hard drive, and then again restoring the snapshot would result in broken file descriptors etc. For example, a process opened a file before the snapshot was taken, and when the snapshot was restored, the file is no longer existing.
But maybe there is an ingenious way of solving that?
If you're willing to keep all of the mounted block filesystems completely untouched (that is, mounted only in read-only mode, as an ext4 journal will be modified even without any changes for example), and unmount others (eg NFS) before freezing, then yes.
You can use the kernel parameters
noresume
andresume=
to specify whether you want to reboot into your frozen state or not.The sequence would be:
To snapshot, suspend to disk, boot your system without resuming (
noresume
) or another system altogether (like a livecd), copy the swap partition elsewhere, then reboot with the correctresume=
and use your system.To go back to the frozen state, boot again with
noresume
or from another system, copy the swap partition back, then reboot with the correctresume=
again.I wouldn't recommend this though. Virtualization offers a much safer and tested way to achieve your results with fewer caveats.