12

Actually my question can appear identical to this one in this forum (and also this one elsewhere); indeed the question is the same, but I'm asking it anyway because I can give more informations and because I tried some solution found on the web (possibly getting things worse).

I used to hibernate Ubuntu 15.10 (closing the lid). Now that I've updated it to 16.04 (I thought it was a good thing, since this version is LTS, unlike the 15.10), I cannot use hibernation (nor suspension!) anymore: if I try to use it, Ubuntu doesn't shut down, just the screen goes black, the power led is on, and I cannot do anything else than shutting it down manually (long press of the power button). When I power it on again, I see the following lines

enter image description here

then Ubuntu boots up.

From here I tried with

sudo -s
echo shutdown > /sys/power/disk
echo disk > /sys/power/state

and

sudo -s
echo platform > /sys/power/disk
echo disk > /sys/power/state

Only the first partially worked and only once: by partially I mean that after the brutal shut down the session was recovered.

Then I tried to follow this suggestion. I didn't understand the comments written after the commands, so I literally entered the commands as they are (thinking that some error like "this command/folder doesn't exist" would have been occurred if there was something to substitute in the commands):

EDIT

cat /proc/meminfo
sudo swapoff -a
sudo dd if=/dev/zero of=/swapfile bs=1024 count=8M
sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile
sudo -b gedit /etc/fstab
free -m
swapon

mount | grep " / "
sudo blkid -g
sudo blkid
sudo filefrag -v /swapfile | grep "First block:"
sudo filefrag -v /swapfile
echo "resume=UUID=cdXX--X18 resume_offset=66050" | sudo tee /etc/initramfs-tools/conf.d/resume
sudo -b gedit /boot/grub/menu.lst
sudo -b gedit /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="... resume=UUID=cdXX--X18 resume_offset=66050"
sudo update-grub -y
sudo update-initramfs -u

Maybe this has been a terrible idea, since now I get this.

IMG:

In the end I found the question linked above and I went here, but I don't know what to do.

EDIT 2 At the moment if I enter

...$ sudo swapon -s

I obtain absolutely nothing

...$
  • Maybe it's because of the BIOS. In my BIOS, I go to Power Management and there should be an option on what to do when suspend. Normally mine is S1 but S3 is the thing. – dat tutbrus May 13 '16 at 16:42
  • Stab in the dark here but you should investigate your BIOS settings and go over them. Get out your manual and check through it. I've had countless issues in the past that have had a BIOS switch as the solution. – Jonathan May 15 '16 at 16:31
  • 1
    Undo the very bad idea. This was a proof-of-concept how to get Ubuntu to use the swap space for hibernation. As root with sudo, remove the added last line from /etc/initramfs-tools/conf.d/resumeand the added two resume stanzas from etc/default/grub, run the last two lines to update grub and the initrd. Delete /swapfile. Run sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target. Try any of these targets with sudo systemctl suspend. What happens? – emk2203 May 16 '16 at 7:35
  • In the end I decided to reinstall ubuntu 15.10. Now hibernation works again. Maybe I will install 16.04 on another partition. When I'll do so, I will refer to this question and answers. – Enrico Maria De Angelis May 16 '16 at 13:07
5

Forcing hibernate to power off the machine:

After looking around a long time for an answer to this that actually addressed the issue (not related ones), I found a tip here which got the job done for me:

Create a file in the pm config directory:

sudo vim /etc/pm/config.d/hibernate_mode

that sets the variable HIBERNATE_MODE like so:

HIBERNATE_MODE="shutdown"

After doing this, hibernate powered down the machine on completion like expected. An explanation for what setting HIBERNATE_MODE does is in the manual for pm-hibernate:

Default method to power down the system when hibernating. If not set, the system will use the kernel default as a default value. Check /sys/power/disk for valid values. The default value will be surrounded by [square brackets].

My default in that file was platform. Setting the variable above to shutdown overrides this, and gets what we want happening.

Related information and tips for getting hibernate to work correctly:

As for those "related issues" everyone seems to have with hibernating, quick debugging tips:

  1. Check that the command sudo pm-hibernate actually does something. If not, none of these other tips will make any difference. If it doesn't work, ensure 1) the size of your swap partition is greater than that of your RAM and 2) secure boot is disabled in your BIOS.

  2. Only once that command works, look at integrating hibernate into your system as you please. A couple of common ones:

    • Add hibernate to the Ubuntu menu: This seems to be the best answer to me. Official documentation also has a slightly different version.
      Note: once hibernate is added to the Ubuntu menu, you may also need to fix the alternative call to sudo systemctl hibernate. Apparently, (at least for Ubuntu 16.04) the Ubuntu menu option calls sudo systemctl hibernate instead of sudo pm-hibernate. systemctl hibernate was fixed for me by adding the following content to file /etc/systemd/sleep.conf:

      [Sleep]
      HibernateMode=shutdown

      If the file doesn't exists yet, you can create it. More info here.

    • Change the behaviour of the power button (by default it displays in interactive menu): To change it to directly hibernate, or shutdown you need to modify the associated gsettings entry. A lot of other answers go through the GUI way if that floats your boat. To see the available options use gsettings range org.gnome.settings-daemon.plugins.power button-power

2

By seeing your last image and EDIT 2, I can understand that Ubuntu can't find a Swap Partition on your system. So I suggest you should create a Swap partition equal to or larger than your RAM size, and try again by running

sudo pm-hibernate

You can create swap partition using GParted, run this to install it

sudo apt-get install gparted
2

I had the same problem after upgrading from 15.10 to 16.04:

  • Closing the lid did not do anything
  • Manually suspending with the menu item in the system tray resulted in a half suspended state with the only way out to reset the system.

I solved these issues by

  1. upgrading the kernel to 4.4.8 (after this suspend from menu worked for me)
  2. Adding the line HandleLidSwitchDocked=suspend to /etc/systemd/logind.conf (wich made the lid switch to work again).

I think both issues are bugs that should be fixed (https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1574120).

  • Did this solve the problem for suspension only, or also for hibernation? – Enrico Maria De Angelis May 17 '16 at 16:21
0

Hibernate has been disabled by default.

Try this

sudo pm-hibernate

If the hibernate test works, you can continue to use the sudo pm-hibernate command when you want to hibernate.

You can also enable the hibernate option in the menus. To do that, use your favorite text editor to create /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla. Add the following to the file and save:

[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.hibernate-multiple-sessions
ResultActive=yes

Read More on Hibernation 16.04 from this link

To Shutdown

sudo shutdown -h now

To Restart

sudo shutdown -r now
  • As I written, sudo pm-hibernate used to work very well before upgrading form 15.10 to 16.04LTS. So the problem should concern the 16.04LTS version. In addition, maybe I did something very wrong following instruction without understanding them. Could you help me in correcting these problems? – Enrico Maria De Angelis May 13 '16 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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