17

Why no answer accepted

For the simple reason that I haven't been using Ubuntu for a long time, so I couldn't test the answers.

The question

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

...$
Enlico
  • 272

4 Answers4

10

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

btalb
  • 596
3

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).

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
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
jarvis
  • 139