So I decided to migrate my ThinkPad X230 from Ubuntu 18.04 to the newly released Ubuntu 19.04, codenamed “Disco Dingo”. To get Disco (or any recent, SystemD-ladden Ubuntu releases) to play nice with hibernate, you need to plan ahead.
Prepare swap partition. In the installation process, prepare and create a swap partition as large as the system’s RAM. My X230 has 16GB and that would be the size for my swap partition. The easiest way to do this is by creating one when you install your system. On “Installation type” select “something else” to create custom partition configuration.
And create a swap partition the size of the system RAM Or resizing your existing storage to accommodate the swap partition. As a last resort, you can opt to use a swap file
Check whether hibernate is supported. Do
surfer@M5-X230:~$ cat /sys/power/state
freeze mem disk
…If disk is listed, then your system supports hibernate
Update grub to point to the swap partition on resume. Get the location of your swap partition:
surfer@M5-X230:~$ grep swap /etc/fstab
# swap was on /dev/sda1 during installation
UUID=14cee2ec-9d37-4ac0-b594-eae0e55814aa none swap sw 0 0
[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
Configure Lid switch actions. If you want the laptop to automatically enter hibernation when you close the lid, we need to configure them here:
sudo nano /etc/systemd/logind.conf
The file contains several action that can be configured during login process. The one that is relevant for our purposes is:
#HandleLidSwitch=poweroff
Uncomment and modify it to
HandleLidSwitch=hibernate
Additonally, if you own a laptop dock and you would like to be able to use your laptop when it’s connected to an external monitor while the lid is closed, uncomment:
#HandleLidSwitchDocked=ignore
to
HandleLidSwitchDocked=ignore
…and save the file. Restart the systemd logind service
3 thoughts on “Enabling Hibernate on Ubuntu 19.04 Disco Dingo”
This worked for me for one time only and then went back to failing. Is any body ever going to sort hibernate on Ubuntu. The same hardware hibernates successfully on other operating systems and did with Ubuntu up to 16.04.
Would you mind sharing your hardware configuration? Are you using lid action to initiate hibernate and resume? This is working fine so far with my X230
It’s not a laptop. Desktop with two internal drives with different operating systems, using grub to select. Both drives have own swap partition. Correct partition is selected for resume. Usually hard boots after hibernate, but recovered correctly just once after following above procedure. I used to have hibernate option in the settings power screen, but no longer.
This worked for me for one time only and then went back to failing. Is any body ever going to sort hibernate on Ubuntu. The same hardware hibernates successfully on other operating systems and did with Ubuntu up to 16.04.
Would you mind sharing your hardware configuration? Are you using lid action to initiate hibernate and resume? This is working fine so far with my X230
It’s not a laptop. Desktop with two internal drives with different operating systems, using grub to select. Both drives have own swap partition. Correct partition is selected for resume. Usually hard boots after hibernate, but recovered correctly just once after following above procedure. I used to have hibernate option in the settings power screen, but no longer.