Hibernation in Kubuntu 20.04
This is what worked for me with Kubuntu 20.04 and a swap partition of the same size of the available RAM. It's somewhat a simplification of other answers seen here and on the other answer for Ubuntu 20.04.
First of all: no need to install either pm-utils
, uswsusp
or hibernate
: I don't have them in my system, however hibernation works with both sudo systemctl hibernate
and with the hibernation button in KDE menu.
So, the whole procedure:
-
find the name and UUID of the swap partition
sudo swapon --show=NAME,UUID
(in my case it's
/dev/dm-2
- it must start with /dev, otherwise you're using a swap file) -
edit
/etc/default/grub
and change the value forGRUB_CMDLINE_LINUX_DEFAULT
by adding the following at the end of the line (within"
):resume=UUID=<UUID>
(replace
<UUID>
with the UUID found previously) -
Run
update-grub
to update the actual grub config based on/etc/default/grub
-
write the following command:
cat << "EOF" > /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[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
EOF
- logout and login
Now you can hibernate with either sudo systemctl hibernate
or with the hibernation button in KDE menu.
I have created a swap file in /home
partition.
-
Install pm-utils and uswsusp.
sudo apt install pm-utils uswsusp
-
Create swapfile and give necessary permissions:
fallocate -l 8G /home/swapfile && chmod 600 /home/swapfile && \ mkswap /home/swapfile && swapon /home/swapfile
-
Edit
/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
:cat << "EOF" > /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla [Re-enable hibernate by default in upower] Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes [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 EOF
-
Get swap offset:
swap-offset /home/swapfile
-
Get UUID of /home/swapfile:
findmnt -no SOURCE,UUID -T /home/swapfile
-
Edit
/etc/default/grub
and addGRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=861920c2-557d-4910-9b3e-b8a7be8f4fae resume_offset=12900352"
-
Edit service systemd-logind.service:
systemct edit systemd-logind.service
and add
[Service] ProtectHome=read-only
Update the GRUB using
update-grub
- Reboot