POP OS! Hibernate enable step by step Complete tutorial and references.

POP OS! enable hibernate

*************** Debian / Ubuntu /Linux Mint ******************************
You can watch my video to enable Hibernate in Grub bootloader.
https://www.youtube.com/watch?v=NzUmsi9sgmg
https://drive.google.com/file/d/1OP5DZOMq3U76Ur7FRXrjRd-0i2NWOP6-/view

****************************************************************************

************ install GRUB in POP OS! ***************************************
refer
https://www.youtube.com/watch?v=wLOZfT0732Y

***************************************************************************

Prerequisites — do you have enough space?
To hibernate, you need to (simplification here) save your entire RAM to your hard drive. So, you need to set aside enough space to do so. If you don’t, this will fail and you won’t hibernate.

1. free -m will tell you how much memory you have, use and how much is in your swap.
2. df -h will tell you how much disk space you have on each mount point and how much is used, free, etc. This is important since you may want to later specify where your swap file will be located, or which partition to “trim” to have enough space for your swap.
3. cat fstab should give you information if you have a swap partition or file. According to Ubuntu Hibernation FAQ swapfile may not always work with some combinations of hardware/drivers.

If you don’t have enough space, follow Ubuntu swap FAQ. It tells you how to increase swap file, add another, check if it’s used etc. With commands and explanations. Really nice resource.(help — https://help.ubuntu.com/community/SwapFaq)

Prerequisites — does your kernel support suspend-to-disk?

Kernel supports whatever is listed in /sys/power/state, so:

cat /sys/power/state

Allowed (to my knowledge) entries there include: mem, standby, freeze, disk. Explanation:

mem — has several meanings, which one exactly on your system you’ll find out via cat /sys/power/mem_sleep. I have: s2idle [deep]
standby — Power-On Suspend (if supported)
freeze — Suspend To Idle (STI)
disk — Suspend To Disk (STD), hibernation. This — you want.

********************POP OS! *****************************************
When POP OS is installed swap partition is encryted. In order to hibernate to work first we need to remove encryption(help — https://www.logilab.org/blogentry/29155)
The idea is to turn off swap, remove the ecryptfs layer, reformat your partition with normal swap and enable it. We use sda5 as an example for the swap partition, please use your own (fdisk -l will tell you which swap partition you are using — or in /etc/crypttab)
**** please note that you should act on your systems particular swap partition here we are using dev/sda5 *****

sudo swapoff -a
sudo cryptsetup remove /dev/mapper/cryptswap
sudo vim /etc/crypttab
*remove the /dev/sda5 line* or comment the line #
install gparted and delete and reformat the appropriate partition to swap
sudo /sbin/mkswap /dev/sda5
sudo swapon /dev/sda5

sudo vim /etc/fstab
*replace /dev/mapper/cryptswap with /dev/sda5* or with UUID=some-text
OR (get the swap partion uuid from gnome-disk-utility (help — https://doc.ubuntu-fr.org/gnome-disk-utility) if using debian based system — sudo apt install gnome-disk-utility)

it line should look like this

UUID=9eef9d8e-2994–4d1d-bae7–91edbe353cb2 none swap defaults 0 0

If your using EFI installation ( check /boot do you see efi folder) then you have efi installation

POP OS! Does not use Grub2 in POP OS! 20.04
POP OS! uses system-boot and kernelstab to manage kernel boot option.
To add the resume parameter in kernelstab
UUID=your-swap-partiton-uuid

sudo kernelstub -a “resume=UUID=25fe928e-8214–4177–9d79–5fad2edefc11”

Also edit /etc/initramfs-tools/conf.d/resume to add the same line
sudo gedit /etc/initramfs-tools/conf.d/resume
add the below line.
RESUME=UUID=25fe928e-8214–4177–9d79–5fad2edefc11

then after type in terminal

sudo update-initramfs -u

Problems:
if you get multiple Kernel Boot Option:(like resume=UUID=25fe928e-8214–4177–9d79–5fad2edefc11 resume=UUID=434dsfsf-2233–4177–9d79–5fad2edddfe1) then you have to delete the non working UUID with sudo kernelstab -o “resume=UUID=434dsfsf-2233–4177–9d79–5fad2edddfe1”
it deletes the entry only valid entry should be present in Kernel Boot Option

then
sudo update-initramfs -u

Now you can see only one entry in Kernel boot option.

***Reboot check ***
after reboot you can check
sudo cryptsetup remove cryptswap
you should get
Device cryptswap is not active.
**********************************

check hiberate works using this command
sudo systemctl hibernate

Edit logind.conf to enable suspend-then-hibernate on lid closed. (uncomment the line)
sudo gedit /etc/systemd/logind.conf
HandleLidSwitch=suspend-then-hibernate
HandleLidSwitchExternalPower=suspend-then-hibernate

To add the delay after how many sec /min the hibernate should happen after suspend.( for min add the value.min eg. 30min, for seconds add the value 30) (help: https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html)
sudo gedit /etc/systemd/sleep.conf
HibernateDelaySec=30min

Enable hibernate in power Menu Gnome, working on Gnome 3.36
https://github.com/arelange/gnome-shell-extension-hibernate-status

install the extension Hibernate Status Button
https://extensions.gnome.org/extension/755/hibernate-status-button/