Ubuntu 16.04 doesn't shut down after suspend or hibernate
Solution 1
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:
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.-
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 tosudo systemctl hibernate
. Apparently, (at least for Ubuntu 16.04) the Ubuntu menu option callssudo systemctl hibernate
instead ofsudo pm-hibernate
.systemctl hibernate
was fixed for me by adding the following content to file/etc/systemd/sleep.conf
:[Sleep]
HibernateMode=shutdownIf 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
-
Solution 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
- upgrading the kernel to 4.4.8 (after this suspend from menu worked for me)
- 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).
Solution 3
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
Related videos on Youtube
Enlico
Answers I'm most proud of They're not for free... Haskell Elegant way to combine multiple filtering functions in Haskell C++ What's the difference between std::move and std::forward; the question was almost 9 years old when I answered, but I think my explanation is damn clear How to pass a rvalue reference parameter to a template operator() function in C++?; turned out to be an in-depth walkthrough of this code for currying functions taken from Functional Programming in C++. C++11 enable_if on return type of subscript operator of template parameter How do I display the contents of a std::vector of my own datatype and display the name on the console using std::copy? decltype on the variable of reference type with curly braces, downvoted by a couple of arrogant people who don't know what template/auto type deduction is. What is calling void(); doing? What exactly is decltype(std::get<0>(tup))? bash, awk, sed, ... How do I edit current shell command without executing it? How to make git-log scroll up instead of down (solution with Sed) How to sort a file by line length and then alphabetically for the second key? with a very interesting quirk about sort, which was simultaneously investigated with this question of mine Try WinZoZ which is my very first Vim plug-in for easy window movement and resizing. He/him/his I/Chuck Norris/(and) your mom
Updated on September 18, 2022Comments
-
Enlico almost 2 years
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
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.
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
...$
-
Admin about 8 yearsMaybe 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.
-
Admin about 8 yearsStab 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.
-
Admin about 8 yearsUndo 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/resume
and the added two resume stanzas frometc/default/grub
, run the last two lines to update grub and the initrd. Delete /swapfile. Runsudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
. Try any of these targets withsudo systemctl suspend
. What happens? -
Admin about 8 yearsIn 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.
-
-
Enlico about 8 yearsAs 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?
-
Enlico about 8 yearsDid this solve the problem for suspension only, or also for hibernation?