Hibernate / Resume from hibernation - Ubuntu (MATE) 18.04

Hibernate / Resume from hibernation - Ubuntu (MATE) 18.04

Hibernate / Resume from Hibernation did work as expected in Ubuntu MATE 16.10, 17.04, 17.10 (at least on my PCs, not on my notebooks).

Issue: Hibernate / Resume from Hibernation do not work as expected after new installation / upgrading to Ubuntu (MATE) 18.04.

This short guide assumes you have a swap partition on your Ubuntu (MATE) 18.04 PC.

  1. Open MATE Terminal
  2. sudo blkid | grep swap
  3. Copy the UUID (it looks like this XXX-XXX-XXX-XXX-XXX)
  4. sudo pluma /etc/default/grub
  5. Search for GRUB_CMDLINE_LINUX_DEFAULT => it looks like this GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
  6. Add the resume=UUID=XXX-XXX-XXX-XXX-XXX parameter => GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=XXX-XXX-XXX-XXX-XXX"
  7. Save the file and close pluma
  8. Save your work (open files) and reboot
  9. Log into Ubuntu (MATE) and open some applications
  10. Check if Hibernate works on your computer by entering
    sudo systemctl hibernate
    => your PC will enter Hibernate (hopefully)
  11. If your PC successfully entered Hibernate, resume from hibernation (press the Power button, move your mouse or press a key... depending on your PC)
  12. If the PC successfully resumed from Hibernate, all the applications you've opened in step 9 show up correctly and you can continue work, Hibernate / Resume from Hibernation works as expected.
  13. Open MATE Terminal
  14. sudo pluma /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
  15. Add following (if not already there):

[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
16. Save the file and close pluma
17. Hibernate button should be available via click on the Power button -> Shutdown (or Menu -> Quit)
18. Test Hibernate and Resume from hibernation

This was the solution for my 3 PCs (not notebooks!) running Ubuntu MATE 18.04 now.

Notes

  1. If step 10 / 11 / 12 did not work for you, you should not continue. I am sorry, but I have no alternative solution (yet?). My notebooks DO NOT "support" Hibernate / Resume from hibernation with Ubuntu (but with Windows 7, 8.x, 10.x).
  2. Hibernate / Resume from hibernation should work with a swapfile, too. I use swap partitions on my PCs. You may want to search the Internet for a solution.

Hope this helps :slight_smile:

2 Likes

After modifying /etc/default/grub you need to run update-grub
Add this as one of the steps.

Hello,

For people using LVM, and SWAP on LVM as me I would like to add this:

There is a bug using UUID causing initramfs boot delay.
No need to modify grub config file.
You will need to:

0- List your LVM VG to get ubuntu VG name:
for the example named ubuntu.vg

$ sudo vgs

1- List your LVM LV to get swap LV name:
for the example named swap.lv

$ sudo lvs

2- Modify /etc/initramfs-tools/conf.d/resume file replacing ubuntu--vg-swap_1 in the command line bellow with the name of your Swap LV (or simply edit resume file using nano):
This will give a name like <Ubuntu VG Name>-<Swap LV name>
in my example ubuntu.vg-swap.lv so path will be /dev/mapper/ubuntu.vg-swap.lv
You can confirm the name using ls /dev/mapper/
or using findmnt --fstab -t swap

$ sudo su -c 'echo RESUME=/dev/mapper/ubuntu--vg-swap_1 > /etc/initramfs-tools/conf.d/resume'

3 -Update initramfs

$ sudo update-initramfs -u

4- Modify/Add polkit policy file following @radax05 explanations

5- Finaly reboot

Sources:
Launchpad bug 1581801 report

https://www.hiroom2.com/2016/05/14/solution-for-bood-delay-problem-of-ubuntu-16-04-with-lvm/

Kr

1 Like

Hallo radax05

I have always had problems (particularly network problems) with “hibernate” back in the days before I came to GNU/Linux. I have my own simple solution. I never use it. Ever. As GNU/Linux systems boot so quickly I personally have no need to “hibernate” the system.

The only piece of information I’ve picked up on my travels is that for hibernate to work the “swap” partition must be => the computers “ram”. I can’t say if this is correct, but it might be worth adding to the beggining of your explanation as a “warning”, before users set of to follow your instructions. :slight_smile:

@moocan & @alpinejohn: Thank you for the suggested improvements :slight_smile:

  1. running sudo update-grub from a Terminal after modifying /etc/default/grub (even if I cannot recall doing this)

and

  1. creation of a SWAP partition with a size at least the size of the RAM (to be on the safe side, even if according to some web sites it should work even with less) before starting setting up Hiberation

Unfortunately, I cannot edit the original post.

@alpinejohn: Hiberation does not work on any of the 3 notebooks I’ve tried :frowning: But it works flawlessly, after applying the changes described here, on all 3 PCs I’ve tried to set it up. The PCs “wake up from hibernation” by pressing a key or moving the mouse (for the PCs with an ASUS mainboard - configurable via BIOS) or by pressing the Power button (for the ACER PC).

hibernate does not work with /swapfile as is. there is a workaround, but using a swap partition is easier.