Hibernation doesn't work on 18.04 beta 2

Asked by Matheus on 2018-04-11

Hi. I'm trying to make hibernation works on 18.04 beta 2 final. First of all it worked on previous Ubuntu releases including 17.10. I have 16 GB of RAM and a sad. I was first trying to hibernate just with the default swap, without a separate partition and of course it failed.

Then I added a 17gb partition swap and added it to swap, it booted normally and o checked the swap on htop. I installed the packages pm-utils and hibernate and both pm-hibernate and hibernate shows the s2disk trying to snapshot the system but then it fails with the message failed to hibernate due to low swap space. I updated my kernel to 4.16.1 and still exactly the same problem.

How can I get this solved and why isn't hibernation something standart on Ubuntu and on Ubuntu based distros? I use this feature a lot since with this I can change to my secondary OS without loosing my sessions on ubuntu, but this isn't something you find on the DE menus and anywhere.

Thanks!

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
2018-05-13
Last reply:
2018-08-18
daniel CURTIS (anoda) said : #1

Hello Matheus.

Yoy have written, that you updated Linux kernel to v4.16.1. You also used 18.04 beta Release, right? So, in both cases there are pretty new kernels. Anyway, it seems, that kASLR feature was enabled by default in Linux v4.12. kASLR is about randomizing the location of the kernel code in RAM at boot time and it improve system security etc. However, enabling kASLR will disable the ability to enter hibernation mode.

So, my advice is to check if you're using such a feature (based on your own experience: 18.04 beta Release and update Linux kernel to v4.16.1). To do this, You can edit '/etc/default/grub' file and check "GRUB_CMDLINE_LINUX_DEFAULT=" for 'kasrl' option. There should be also 'quiet splash' etc. If there is not such an option, You can try to disable it and reboot system.

To do this, please edit via sudo(8) command '/etc/default/grub' file and add 'nokaslr' (or if there is already 'kaslr' option, You can simply remove it) to the "GRUB_CMDLINE_LINUX_DEFAULT=" option, next save file and update grub using this command:

sudo update-grub

And reboot computer. After login, check if hibernation is working etc. I think, that it can be an answer, because Ubuntu 18.04 will have Linux kernel v4.15 and 'kaslr' was introduced in Ubuntu 14.04 (but disabled by default) and Linux 4.12.

One more thing; You can also check if there is a 'kaslr' option in use by running this command:

cat /proc/cmdline |grep kaslr

I hope, that it will help You somehow. Best regards.

I suggest you report a bug. Bionic is not ready and not stable

Matheus (mattfly) said : #3

Hello daniel. Thanks for the detailed description, I am conscious about how the meltdown patches made a downgrade on some linux functionalities.

 First of all by running:
cat /proc/cmdline |grep kaslr

I get no output. My grub file had now kaslr option and I added the nokaslr after quiet splash as this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nokaslr

Now I have:

# cat /proc/cmdline |grep kaslr
BOOT_IMAGE=/boot/vmlinuz-4.15.0-13-generic.efi.signed root=UUID=a2d1acfd-e314-4c08-b86e-806ff1563422 ro quiet splash nokaslr
vt.handoff=1

Hibernation still doesn't work. Interesting problem is that if I run:
hibernate-disk -v2
hibernate-disk:Warning: Tuxonice binary signature file not found.
hibernate-disk: Trying method in ususpend-disk.conf...
hibernate-disk: [01] Executing CheckLastResume ...
hibernate-disk: [01] Executing CheckRunlevel ...
hibernate-disk: [01] Executing LockFileGet ...
hibernate-disk: [01] Executing NewKernelFileCheck ...
hibernate-disk: [10] Executing EnsureUSuspendCapable ...
hibernate-disk: [11] Executing XHacksSuspendHook1 ...
hibernate-disk: [59] Executing RemountXFSBootRO ...
hibernate-disk: [89] Executing SaveKernelModprobe ...
hibernate-disk: [91] Executing ModulesUnloadBlacklist ...
Unloading blacklisted modules listed /etc/hibernate/blacklisted-modules
Unloading blacklisted module uvcvideo (and dependencies)
hibernate-disk: [95] Executing XHacksSuspendHook2 ...
hibernate-disk: [98] Executing CheckRunlevel ...
hibernate-disk: [99] Executing DoUSuspend ...
hibernate-disk: Running /usr/sbin/s2disk ...
s2disk: Could not use the resume device (try swapon -a). Reason: No such device
hibernate-disk: [90] Executing ModulesLoad ...
Loading module uvcvideo (from auto)...
hibernate-disk: [89] Executing RestoreKernelModprobe ...
hibernate-disk: [85] Executing XHacksResumeHook2 ...
hibernate-disk: [70] Executing ClockRestore ...
hibernate-disk: [59] Executing RemountXFSBootRW ...
hibernate-disk: [11] Executing XHacksResumeHook1 ...
hibernate-disk: [01] Executing NoteLastResume ...
hibernate-disk: [01] Executing LockFilePut ...

Pay attention to the " s2disk: Could not use the resume device (try swapon -a). Reason: No such device "

Even though:

# swapon -s
Filename Type Size Used Priority
/dev/sda8 partition 16131068 0 -2

and

#free -m
              total used free shared buff/cache available
Mem: 15906 3174 8235 174 4496 12450
Swap: 15752 0 15752

My fstab is:

UUID=a2d1acfd-e314-4c08-b86e-806ff1563422 / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
UUID=3E27-4EB0 /boot/efi vfat umask=0077 0 1
# /home was on /dev/sdb3 during installation
UUID=009ca07e-2a20-4608-be74-0b3915fa40ee /home ext4 defaults 0 2
#/swapfile none swap sw 0 0
UUID=d7d8cc36-388e-47b3-9766-1f3cc0e745ca none swap sw 0 0

I haven't reported the bug yet because I am not sure if it is a problem with bionic or something is wrong with my swap. And as you might have seen I am back to the original bionic kernel.

Matheus (mattfly) said : #4

I made a ram filling test and realized that My swap isnt being used even though its activated. So what can be making my swap unusable or unwritable (I don't know what is the right word for this)?

Matheus (mattfly) said : #5

Okay weird results. I have 15.5 gb of ram according to htop and was open a lot of youtube videos and rendering things on blender to test if my swap would get ever used. Even though I have:

# cat /proc/sys/vm/swappiness
60

It only started getting used when I had 14.5gb of ram used. Well now I closed some applications, but it is writable:
# free -m
              total used free shared buff/cache available
Mem: 15906 9006 3925 232 2974 6586
Swap: 15752 21 15731

But I still have the:

s2disk: Could not use the resume device (try swapon -a). Reason: No such device

When trying to hibernate. So s2disk has a problem I guess?

daniel CURTIS (anoda) said : #6

Hello Matheus.

I have to apologize You, but I'm so busy right now, but please check/read:

* https://wiki.archlinux.org/index.php/S2disk (here are informations about `s2disk` etc.)
* https://wiki.archlinux.org/index.php/Swap (pay attention for "swap file"; You don't have swap partition, right?)
* https://forums.opensuse.org/showthread.php/473087-Hibernation-doesn-t-do-anything-but-just-lock-screen
* https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04
* https://forums.gentoo.org/viewtopic-t-958324-start-0.html

By the way; what about `swapon -a`? Have You tried to run this command? I don't see any results. Here is a bug report (https://bugs.launchpad.net/ubuntu/+bug/689234). You can write a comment, because of Expired status and so on. By the way: did You update GRUB (vide `sudo upfate-grub` command) and reboot system after adding "nokaslr" option to the /etc/default/grub' file?

One more thing: please search for any informations about change swapfile to swap partition, because I think, that using swapfile breaks hibernation. However, You can try this tutorial: https://ubuntuforums.org/showthread.php?t=1042946

Okay, that's all for now. I hope, that You will manage to solve this issue.

Best regards.

daniel CURTIS (anoda) said : #7

Geez, one more thing: please check https://askubuntu.com/questions/6769/hibernate-and-resume-from-a-swap-file (especially "Hibernate with Swap file using uswusp").

Thanks.

Matheus (mattfly) said : #8

No daniel. Please watch out for what i posted when you have more time, I have a swap partition and yes i have tried swapon -a, as i said my swap works and swapon -s or free -m shows it.

Anyway thanks for the links, I will be trying more and i will post when i have more information.

Matheus (mattfly) said : #9

I have followed Cas steps as described here: https://askubuntu.com/questions/6769/hibernate-and-resume-from-a-swap-file except I am using a swap partition instead of file.

I just basically edited the vim /etc/uswsusp.conf file adding the right resume partition to it. Now s2disk gets stuck while trying to snapshot the system and i can only force turn off my computer to overcome that.

Matheus (mattfly) said : #10

I have reported a bug: https://bugs.launchpad.net/ubuntu/+source/uswsusp/+bug/1770491

Ive figured out the exact issue im having, hanging on s2disk, only happens if i install nvidia-384.

Lei Yu (yuleihit) said : #11

I searched over the internet and found this post. I had the same issue on 18.04 in Augst. The problem is still there. Another bug report
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1774950 may be related.

Can you help with this problem?

Provide an answer of your own, or ask Matheus for more information if necessary.

To post a message you must log in.