Cannot resume after hibernate

19,052

Solution 1

Thank you all for your answers. The problem was solved in Kernel 4.15. I just tried it now and it works. Apparently the HWE kernel fixed it (linux-generic-hwe-16.04 package).

If you are using Ubuntu 16.04, you just need to install the latest updates to upgrade the kernel. You can read more details about that here.

My current kernel version is 4.15.0-33-generic.

Solution 2

I had the same issues. There is a bug in the most recent kernel in 16.04. Here are the explicit steps I have done. Do the first one and, if it solves the problem for you, stop there. If not, go on.

1. Set the computer to boot with the previous kernel

Start with:

uname -r

Mine says 4.13... Then do:

grep -i "menuentry '" /boot/grub/grub.cfg

You will see the different menu entries in grub. In my case, together with "Ubuntu, with Linux 4.13..." there was a menu option to boot with the previous kernel. It said Ubuntu, with Linux 4.10.0-28-generic. In the same line you have something like 'gnulinux-4.10.0-28-generic-advanced...(a bunch of caracters here)' Copy that text, and then we have to tell grub2 to boot with that kernel by default:

sudo cp /etc/default/grub /etc/default/grub.back

sudo gedit /etc/default/grub

Then I inserted this line:

GRUB_DEFAULT="gnulinux-advanced-4a50e1e8-56d9-413e-9954-55648888a31d>gnulinux-4.10.0-28-generic-advanced-4a50e1e8-56d9-413e-9954-55648888a31d"

Please do not copy this line literally, but use the output of the previous grep command as said. Then save and,

sudo update-grub

Then re-boot and check that the output of "uname -r" is the older kernel (4.10... in my case). You may be able to hibernate now, or not. If not, proceed to the next step.

2. Install different stuff to hibernate than the default one:

In my case, using the older kernel got rid of the black screen of death and allowed me to resume after hibernation, but the contents of the disk image were going wiped out, i.e. it was identical to a reboot, not hibernation. So I installed some shit that hibernates differently:

sudo apt-get install uswsusp

Then close the terminal, open it again and type:

sudo s2disk

This is supposed to hibernate the computer. If, after resuming, everything is as you left it, then you have solved the issue. But you still need to proceed to step 4 in order to tell Ubuntu that you want to use the new stuff by default and also that you want to have options to hibernate in the applications.

3. Tell grub 2 where the swap partition is:

It still didn't worked for me, so I had to tell grub where the swap partition is:

cat /etc/fstab

I could read there "# swap was on /dev/sda2 during installation", so I edited grub again:

sudo gedit /etc/default/grub

And added:

GRUB_CMDLINE_LINUX_DEFAULT="intel_pstate=disable resume=/dev/sda2"

The important part is "resume=/dev/sda2" but the previous thing (intel blablabla) is there because of other reasons. Well, the next step is:

sudo update-grub

Re-boot and try again to hibernate with some stuff going on (e.g. open a movie with vlc) with:

sudo s2disk

If the stuff is still there after you resume, you have solved the issue.

4. Telling Ubuntu to use the new hibernation stuff you have installed instead of the default:

You have now to tell Ubuntu to use s2disk to hibernate instead of the stuff that comes by default:

sudo gedit /etc/pm/config.d/00sleep_module

And insert there:

SLEEP_MODULE="uswsusp"

Save and close the file. Then:

sudo gedit /etc/polkit-1/localauthority/50-local.d/enable-hibernate.pkla

And insert 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

Reboot and try again.

5. If after running Step 4, you can't hibernate using sudo systemctl hibernate then do the following

Step 4 is not enough to make the switch to uswsusp in Ubuntu 18.10.

Edit the hibernation service

sudo systemctl edit systemd-hibernate.service

And add the following

[Service]
ExecStart=
ExecStartPre=-/bin/run-parts -v -a pre /usr/lib/systemd/system-sleep
ExecStart=/usr/sbin/s2disk
ExecStartPost=-/bin/run-parts -v --reverse -a post /usr/lib/systemd/system-sleep

Update systemd

sudo systemctl daemon-reload

Test the setup by running the following

sudo systemctl hibernate

Solution 3

@karim I had the same problem here is how fixed it:

Use the swap partition's UUID instead of it's mounting point in the RESUME parameter resume=UUID=# in both /etc/default/grub and /etc/initramfs-tools/conf.d/resume

Create an entry for the swap partition in /etc/fstab without a mounting point something like this

# Entry for Swap : 
UUID=# none  swap    sw              0       0

In /etc/default/grub I've used a separate entry for resuming hibernation

# FOR HIBERNATION 
GRUB_CMDLINE_LINUX="resume=UUID=..."

Create a policykit in local authority (pkla) as explained by @Mephisto

Update initramfs and GRUB

sudo update-initramfs -u -k all
sudo update-grub

Reboot , open some apps and use systemctl hibernate (without sudo) to see if it works

Solution 4

I was also having this problem plague me ... and a fix after many attempts was to re-install Ubuntu 18.04, and now it is working perfectly. I am also using Nvidia's "tested" Driver, as Nvidia was the culprit before.

Perhaps it was the sudo add-apt-repository ppa:graphics-drivers ppa which installed "Extra" Stuff and/or the 396 driver which screwed up my laptop's hibernating ability. Either way it works flawlessly at this time of writing with the NVidia's 390 tested driver. Before switching to the Nouveau driver worked.

Share:
19,052

Related videos on Youtube

Karim Sonbol
Author by

Karim Sonbol

Updated on September 18, 2022

Comments

  • Karim Sonbol
    Karim Sonbol over 1 year

    I have been using hibernate with Ubuntu 16.04 without a problem but suddenly it stopped working correctly. Whether I hibernate from the power menu or using sudo pm-hibernate, it turns the computer off but when I turn it on again and choose Ubuntu from the grub menu, it just gives a black screen. I tried some solutions (listed below) but none worked.

    I am really disappointed that with every Ubuntu release I use, I usually have similar problems with hibernate (with different laptops).

    PS: I have dual boot with Windows 10, but hibernate was working perfectly with it for a long time.

    Didn't work:

    • Vanessa Deagan
      Vanessa Deagan over 6 years
      I have the same problem with a laptop of mine - when I return from hibernate - black screen. For me, it was never working. The "workaround" for my laptop is to press ALT+CTRL+F1, then wait a few seconds, then press ALT+CTRL+F7. That brings it back to life (on my laptop).
    • Karim Sonbol
      Karim Sonbol over 6 years
      Thanks for the suggestion, didn't work for me though.
    • Vanessa Deagan
      Vanessa Deagan over 6 years
      How about just closing your lid and opening it again? (worth a try!)
    • Karim Sonbol
      Karim Sonbol over 6 years
      Thanks again @VanessaDeagan, but still nothing happened.
    • Steve
      Steve over 6 years
      If you haven’t seen it yet: bugs.launchpad.net/bugs/1743094
    • Mephisto
      Mephisto over 6 years
      @KarimSonbol Please see that I edited my answer with a more detailed solution to the problem, at least one that has worked for me.
  • Karim Sonbol
    Karim Sonbol over 6 years
    Thanks, I chose the old kernel from the boot menu and hibernate works with it. I will check the other update grub steps later, but I hope they fix the current kernel soon.
  • Karim Sonbol
    Karim Sonbol over 6 years
    Actually, I chose the old kernel once from the grub menu and then hibernated. When I open it again and choose the normal "Ubuntu" option without advanced options, it kind of remembers my choice and uses the old kernel, and luckily all my open apps are in place.
  • lrkwz
    lrkwz almost 6 years
    is there any special reason not to simply uninstall the new kernel and stick to the old one?
  • Zamicol
    Zamicol over 5 years
    I had everything set up, except 'sudo update-initramfs -u -k all' seemed to fix my issue. Thank you.