HOWTO: Enable Hibernation in Kubuntu 20.04

One of the little annoyances of the Buntus is they don’t have hibernation enabled by default; you have to set it up yourself. This entails a few extra steps, fortunately these are fairly straightforward.

  1. Find the UUID of the swap partition with this command:
    blkid
  2. edit the grub settings files /etc/default/grub and find the following line:
    GRUB_CMDLINE_LINUX_DEFAULT
    on the end of that line add the following text
    resume=UUID=<UUID>
    where <UUID> is from the result of the command in step 1
  3. run update-grub to update the grub configuration with the new setting
  4. In a root shell type nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla and enter all the text below

[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

After you reboot, hibernation should work correctly.

There is an interesting possibility implicit that a specific partition can be set aside just for the hibernation. So far I haven’t tried this, but it would look attractive in cases where the swap space is all used up by applications, as the system will not hibernate in these instances.