8

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:

  • 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). – Vanessa Deagan Jan 25 '18 at 9:22
  • Thanks for the suggestion, didn't work for me though. – Karim Sonbol Jan 25 '18 at 11:13
  • How about just closing your lid and opening it again? (worth a try!) – Vanessa Deagan Jan 25 '18 at 15:05
  • Thanks again @VanessaDeagan, but still nothing happened. – Karim Sonbol Jan 26 '18 at 12:11
  • 1
    If you haven’t seen it yet: bugs.launchpad.net/bugs/1743094 – Steve Jan 30 '18 at 5:58
7

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

  • 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 Feb 5 '18 at 20:56
  • 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. – Karim Sonbol Feb 7 '18 at 4:07
  • is there any special reason not to simply uninstall the new kernel and stick to the old one? – lrkwz Jun 23 '18 at 16:44
2

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.

2

@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

  • I had everything set up, except 'sudo update-initramfs -u -k all' seemed to fix my issue. Thank you. – Zamicol Dec 2 '18 at 22:41
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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.