Hibernation (aka 'suspend to disk')

modulename: hibernate.ko

and/or

cpu.ko

and/or

swsusp.ko

and/or

swsusp_booke.ko

configname: CONFIG_HIBERNATION

Linux Kernel Configuration
└─>Power management and ACPI options
└─>Hibernation (aka 'suspend to disk')
In linux kernel since version 3.10 (release Date: 2013-06-30)  
Enable the suspend to disk (STD) functionality, which is usually
called "hibernation" in user interfaces. STD checkpoints the
system and powers it off; and restores that checkpoint on reboot.

You can suspend your machine with 'echo disk > /sys/power/state'
after placing resume=/dev/swappartition on the kernel command line
in your bootloader's configuration file.

Alternatively, you can use the additional userland tools available
from <http://suspend.sf.net>.

In principle it does not require ACPI or APM, although for example
ACPI will be used for the final steps when it is available. One
of the reasons to use software suspend is that the firmware hooks
for suspend states like suspend-to-RAM (STR) often don't work very
well with Linux.

It creates an image which is saved in your active swap. Upon the next
boot, pass the 'resume=/dev/swappartition' argument to the kernel to
have it detect the saved image, restore memory state from it, and
continue to run as before. If you do not want the previous state to
be reloaded, then use the 'noresume' kernel command line argument.
Note, however, that fsck will be run on your filesystems and you will
need to run mkswap against the swap partition used for the suspend.

It also works with swap files to a limited extent (for details see
<file:Documentation/power/swsusp-and-swap-files.rst>).

Right now you may boot without resuming and resume later but in the
meantime you cannot use the swap partition(s)/file(s) involved in
suspending. Also in this case you must not use the filesystems
that were mounted before the suspend. In particular, you MUST NOT
MOUNT any journaled filesystems mounted before the suspend or they
will get corrupted in a nasty way.

For more information take a look at <file:Documentation/power/swsusp.rst>.

source code: