There is an extension that will show your hibernate button. That doesn't necessarily means it will work. So a few steps have to be taken:
Check if hibernate works: Open a terminal and execute systemctl hibernate
. IF this does not work, you'll have to look into the Ubuntu handbook on how to define your swap partition/file
Enter terminal as root (sudo will not work). Open (or create) a file with:
nano /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
Add the text below at the end of the file:
##NEW entry since Ubuntu 18:
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
##NEW entry since Ubuntu 18:
[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes
- Clean up hook (Error - recordfail after resume from hibernate). That error occurs after resume (Ubuntu really doesn't want you to hibernate):
sudo nano /etc/systemd/system/use-10_grub_common.service
Enter:
[Unit]
Description=Execute the /etc/pm/sleep.d/10_grub_common script after hibernation.
After=hibernate.target
[Service]
Type=oneshot
ExecStart=/etc/pm/sleep.d/10_grub-common thaw
[Install]
WantedBy=hibernate.target
This script will remove an error flag from grub, preventing it showing an error the next time you boot. Since it is a service you need to enable it:
sudo systemctl enable use-10_grub_common
What I did not cover is the definition of your swap (either partition or file) - see the link at point 1.
There are two places where "Resume" has to be defined:
Grub: Resume=UUID=xxxx (when you have a swap partion and xxx is the uid of that) and an entry in /etc/initramfs-tools/conf.d/resume
(Resume=UUID=xxxx)
Since I do not know your configuration and have never tried hibernation with swap files I will not elaborate (now)