How to Enable Hibernate on KDE Neon (Swapfile Method)

KDE Neon Linux Wayland

For hibernate to work, you must have swap disk configured on your computer. The swap disk size should be 2 times the memory (RAM) size installed on your computer. So, if you have 8GB of memory installed on your computer, your swap disk size should be 16GB.

Checking Installed Memory (RAM) and Swap Size

To check the current memory and swap disk size, run the following command:

$ sudo free -h

As you can see, I have 8 GB of memory installed on my computer and the swap disk size is 16GB.

If your computer does not have enough swap disk space, make sure to increase the swap disk size before enabling the hibernate feature.

Finding the Swapfile Path

To find the full path of the swapfile, run the following command:

$ sudo swapon --show

As you can see, the swapfile path is /swapfile.

Find the Swapfile Offset

To find the /swapfile physical disk offset, run the following command:

$ sudo filefrag -v /swapfile | grep " 0:" | awk '{print $4}'

The physical disk offset of the /swapfile is 3031040 in my case. It will be different for you. So, make sure to adjust it in your setup.

Finding the UUID of the root Filesystem

As the /swapfile is created on the root filesystem, you also need to know the UUID of the root filesystem to configure hibernate on you computer.

First, find the partition identifier or partition path of the root filesystem with the following command:

$ sudo df -h /

In my case, the partition path is /dev/nvme0n1p2.

To find the UUID of the root filesystem /dev/nvme0n1p2, run the following commands:

$ sudo blkid /dev/nvme0n1p2

The UUID of the root partition should be displayed. Copy the UUID as you will need it in the next section.

Configuring GRUB for Hibernate

To configure GRUB for hibernate, open the /etc/default/grub file with a text editor:

$ sudo nano /etc/default/grub

Add the following kernel parameters at the end of the GRUB_CMDLINE_LINUX_DEFAULT environment variable and save the file.

resume=UUID=3aXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX1b resume_offset=3031040

Update the GRUB bootloader with the following command:

$ sudo update-grub

For the changes to take effect, reboot your computer with the following command:

$ sudo reboot

Hibernating System from the Command Line

Once hibernate is configured, you can easily hibernate your computer from the command-line with the following command:

$ sudo systemctl hibernate

Enabling Hibernate Power Options in KDE Menu

By default, hibernate power options are disabled by polkit. To enable hibernate power options in the KDE menu, you need to enable them manually.

First, open the polkit configuration file with the following command:

$ sudo nano /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

In the com.ubuntu.desktop.pkla file, make the following changes:

  1. Find the [Disable hibernate by default in upower] section and set ResultActive=yes.
  2. Find the [Disable hibernate by default in logind] section and set ResultActive=yes.

Once you’re done, save the changes by pressing <Ctrl> + X followed by Y and <Enter>.

Reboot the computer for the changes to take effect.

$ sudo reboot

Once your computer boots, you should see the hibernate options in the KDE menu.

Hibernate Issues with UEFI Secure Boot

You may have trouble getting the hibernate feature to work if UEFI secure boot is enabled. In that case, disable UEFI secure boot from the BIOS of your computer and hibernate should work just fine. If I find a workaround getting hibernate to work on UEFI secure boot enabled systems, I will share on my blog.

UPDATE: Some forums says, disabling UEFI secure boot validation will get hibernate to work on UEFI secure boot enabled systems. If you want to try that out, run the following command to disable UEFI secure boot validation

$ sudo mokutil --disable-validation

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *