Save the machine state before shutdown and load it back on boot

bootrestoresession-restoreshutdown

Is there a way, on windows 10 and on Linux distributions, to save the machine state before shutting down and load it back up on boot?

I.e. I would like the same feature as in VirtualBox when I use the "save state" to exit a running VM. Which means that when I open back that VM by loading the state, I still have everything just as I left it, and it doesn't take longer than a classical boot.

Is that possible for an OS (not virtualized)?

UPDATE: Of course I would like a real shutdown (does hibernation really shutdown the computer?) to be able to switch OS when booting back up. Use case is: I have a game running on windows, a browser, a bunch of stuff, I shutdown to do some dev on Linux. When I boot I choose Linux instead of Windows, it boots and loads its previous state back (my terminals, with tabs, docker containers still running, my IDE still running etc.). When I'm done with Linux, I shutdown (which saves the state etc.) and reboot under windows which loads back my game, browser etc.

On VirtualBox shutting down is really quick (<10s) and loading the state back up is fairly quick too (~20-40s). This is for a VM using 8GB of RAM. Is there a way to do that with native dual boot OSes and if so, is the speed ok?

Thanks.

Best Answer

Yes that’s what hibernation is. Possible on all major desktop operating systems (Windows, Linux, macOS).

Depending on how much physical memory was in use when shutting down, fully restoring the state might take a lot longer than a regular boot.

You must not change the state of a hibernated system in any way or you’ll cause data corruption, undefined behavior or outright crashes. That generally means no dual booting.

If you really want to, you can of course boot another OS, but it must not touch anything but its own partitions.

To be very clear: Operating systems must use a mutually exclusive set of partitions. There is only one exception: Read-only mounting partitions does not modify them, hence preserving the state the hibernating OS expects.