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
surfer@M5-X230:~$ sudo nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=14cee2ec-9d37-4ac0-b594-eae0e55814aa"
Save, and update the grub config
surfer@M5-X230:~$ sudo update-grub
Configure the initramfs
sudo nano /etc/initramfs-tools/conf.d/resume
- Re-enable Hibernate menu. Update the policy kit
sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
Copy paste the following value and save the file
[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:
Uncomment and modify it to
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:
…and save the file. Restart the systemd logind service
surfer@M5-X230:~$ sudo systemctl restart systemd-logind.service
- Test out hibernating. You can try hibernate your machine by doing
surfer@M5-X230:~$ sudo systemctl hibernate
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.