15

I'm running 18.04 and trying to have my system use hibernate instead of pm-hibernate when my laptop's lid closes.

I have a swap partition of 20GB on 16GB of RAM, so ample space.

When I use pm-hibernate, I get a small apci error that pops up very quickly when both hibernating and restoring that I cannot read. While the hibernate works in the sense it seems to dump to disk and restore from disk, it seems to be a sleep state in that it uses battery at a normal rate, rather than shutting down completely and ceasing battery use.

However, when I use the hibernate installed by:

sudo apt-get install hibernate

And run:

sudo hibernate

And restore from that, I notice my machine does in fact shutdown---the LEDs stop throbbing, etc---and battery usage goes to zero. This is the behavior I would like to see when my lid closes, not the sleep behavior that uses battery as if I were making active use of the computer.

I have followed these guides:

modified

/etc/systemd/logind.conf

to include:

#HandleLidSwitch=suspend
HandlelidSwitch=hibernate

And added my swap partition change in:

/etc/default/grub

To include the correct resume= link, and requested s2disk specifically with:

sudo cat /etc/pm/config.d/00sleep_module
SLEEP_MODULE="swsusp"

I have read the following related askubuntus:

I have also read these links on Lenovo and Arch forums:

How can I make sure the that the hibernate called by lid-close is hibernate not pm-hibernate?

Update

This is still a problem and still makes the Carbon X1 6th gen fundamentally useless with ubuntu. Any solutions that could fix this and maybe additionally add a login prompt might be almost as good as a Windows machine from 4 years ago... ;)

6
  • @Mittenchops I could solve this issue for me, please have a look at askubuntu.com/questions/1028947/… Apr 27, 2018 at 22:39
  • 1
    Can you please add the log data from a full hibernate-resume cycle to your question? It should be in /var/log/pm-suspend.log. Thanks. May 2, 2018 at 8:08
  • @Mittenchops not sure but maybe my issue is related with yours. mine is also a Lenovo hardware.
    – ViBE
    May 21, 2018 at 8:41
  • 1
    I don't use hibernation but you could try renaming /usr/sbin/pm-hibernate to /usr/sbin/pm-hibernate.OLD. Then create /usr/sbin/pm-hibernate bash scxript which contains hibernate command. Use type -a hibernate to find the exact path for the command. It doesn't exist on my system because I haven't installed it. Jul 14, 2018 at 4:00
  • I've updated my answer with wrapper script proposed on July 14/2018. Oct 13, 2018 at 15:55

2 Answers 2

1

I too hate having to pass a URL so I will copy and paste the information and attach the web page to the bottom. I do not see this in your link.

While reading this, I noticed that hibernation may not work if you formatted with btrfs file system? So, how is hibernation permanently enabled in Ubuntu 16.04?

To make the Ubuntu hibernation process permanent, you need to create a new file using a text editor on the command line:

sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

The system requires root privileges to enable the hibernation option, hence, the command sudo should be added. You can use other text editors like vi, gedit, emacs, etc.

Now, copy and paste the following text to a file (use the mouse; keyboard shortcuts won’t work):

[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

Press CTRL+O to save, and CTRL+X to exit the nano editor.

Now, logout of your system and then login again. You will now see a hibernate option, along with the Shut Down and Suspend options.

The link for your convenience is: https://fossbytes.com/enable-disable-hibernate-option-ubuntu-power-menu/

1
  • 2
    This does not appear to work in 18.04 Jul 17, 2018 at 21:25
0

Two options

The first option (listed second) is to review journalctl for possible error messages related to hibernation. If the first option doesn't produce results the second option is to create a wrapper script that replaces pm-hibernate with `hibernate.

Create Wrapper script

Creating a wrapper script allows hibernate to replace pm-hibernate.

Find directories commands are located in

Before creating wrapper script you need to know which directories the hibernate and pm-hibernate commands reside. Use these two commands:

$ locate bin/hibernate
/mnt/c/Program Files (x86)/CyberPower PowerPanel Business Edition/bin/hibernate.dll

$ locate bin/pm-hibernate
/mnt/clone/usr/sbin/pm-hibernate
/mnt/old/usr/sbin/pm-hibernate
/usr/sbin/pm-hibernate

The wrapper script you want to create will be /usr/sbin/pm-hibernate. I don't have the hibernate package installed so the first search only finds a Windows utility. According to package file listing, it should reveal /usr/sbin/hibernate along with a couple of other files.

Backup original file

First we want to make an on-line backup copy of the original file:

sudo cp -a /usr/sbin/pm-hibernate /usr/sbin/pm-hibernate.bak

Next delete the original file:

sudo rm -f /usr/sbin/pm-hibernate

Create wrapper script

Note: instead of a wrapper script many find it easier to create a symbolic link for pm-hibernate to hibernate: How to create a soft or symbolic link?

I like to use gedit for editing but you can replace it with nano or vim or whichever editor you prefer:

sudo -H gedit /usr/sbin/pm-hibernate

An empty file will appear. Paste in the following lines

#!/bin/bash
# Wrapper script to replace pm-hibernate with hibernate package
/usr/sbin/hibernate "$@"

Convert wrapper script to executable

Currently the wrapper script is a regular file. We need to convert it to an executable object:

sudo chmod a+x /usr/sbin/pm-hibernate

We now have an operational wrapper script so every time pm-hibernate is called hibernate runs instead. As mentioned at the top though, you should review journalctl first (described next) before creating a wrapper script.

Review journalctl

You can grep the hibernation messages in journalctl for possible problems.

I don't use hibernate but I do use suspend. The following command allows me to see all messages pertaining to suspend which you would replace with hibernate:

$ journalctl -b | grep -i suspend
Oct 09 22:26:33 alien eyesome[21740]: Lid Open/Close: Wait 3 seconds to see if suspending
Oct 09 22:26:48 alien systemd[1]: Starting TLP suspend/resume...
Oct 09 22:26:48 alien systemd[1]: Started TLP suspend/resume.
Oct 09 22:26:48 alien systemd[1]: Starting Suspend...
Oct 09 22:26:48 alien systemd-sleep[22938]: /lib/systemd/system-sleep/sound: Going to suspend...
Oct 09 22:26:48 alien eyesome[22952]: Wakeup: Going to suspend.  Creating: /tmp/eyesome-is-suspending
Oct 09 22:26:49 alien systemd-sleep[22938]: Suspending system...
Oct 10 04:26:38 alien kernel: PM: Suspending system (mem)
Oct 10 04:26:38 alien kernel: Suspending console(s) (use no_console_suspend to debug)
Oct 10 04:26:38 alien kernel: PM: suspend of devices complete after 1142.044 msecs
Oct 10 04:26:38 alien kernel: PM: late suspend of devices complete after 19.766 msecs
Oct 10 04:26:38 alien kernel: PM: noirq suspend of devices complete after 61.505 msecs
Oct 10 04:26:38 alien kernel: Suspended for 21583.011 seconds
Oct 10 04:26:38 alien eyesome[23137]: Lid Open/Close: Wait 3 seconds to see if suspending
Oct 10 04:26:38 alien systemd-sleep[22938]: /lib/systemd/system-sleep/sound: Waking up from suspend...
Oct 10 04:26:38 alien eyesome[23168]: Wakeup: Called from suspend.
Oct 10 04:26:41 alien systemd[1]: Started Suspend.
Oct 10 04:26:41 alien systemd[1]: Stopping TLP suspend/resume...
Oct 10 04:26:41 alien systemd[1]: Reached target Suspend.
Oct 10 04:26:41 alien systemd[1]: suspend.target: Unit is bound to inactive unit systemd-suspend.service. Stopping, too.
Oct 10 04:26:41 alien systemd[1]: Stopped target Suspend.
Oct 10 04:26:42 alien systemd[1]: Stopped TLP suspend/resume.
Oct 10 04:26:52 alien eyesome[24459]: Daemon: Removed file: /tmp/eyesome-is-suspending
Oct 10 05:47:09 alien eyesome[12434]: Lid Open/Close: Wait 3 seconds to see if suspending
Oct 10 05:51:43 alien systemd[1]: Starting TLP suspend/resume...
Oct 10 05:51:44 alien systemd[1]: Started TLP suspend/resume.
Oct 10 05:51:44 alien systemd[1]: Starting Suspend...
Oct 10 05:51:44 alien systemd-sleep[28353]: /lib/systemd/system-sleep/sound: Going to suspend...
Oct 10 05:51:44 alien eyesome[28367]: Wakeup: Suspending.  Creating /tmp/eyesome-is-suspending
Oct 10 05:51:45 alien systemd-sleep[28353]: Suspending system...
Oct 10 16:30:59 alien kernel: PM: Suspending system (mem)
Oct 10 16:30:59 alien kernel: Suspending console(s) (use no_console_suspend to debug)
Oct 10 16:30:59 alien kernel: PM: suspend of devices complete after 623.519 msecs
Oct 10 16:30:59 alien kernel: PM: late suspend of devices complete after 19.654 msecs
Oct 10 16:30:59 alien kernel: PM: noirq suspend of devices complete after 61.549 msecs
Oct 10 16:30:59 alien kernel: Suspended for 38348.943 seconds
Oct 10 16:30:59 alien eyesome[28563]: Lid Open/Close: Wait 3 seconds to see if suspending
Oct 10 16:30:59 alien systemd-sleep[28353]: /lib/systemd/system-sleep/sound: Waking up from suspend...
Oct 10 16:30:59 alien eyesome[28599]: Wakeup: Called from suspend.
Oct 10 16:31:02 alien systemd[1]: Started Suspend.
Oct 10 16:31:02 alien systemd[1]: Stopping TLP suspend/resume...
Oct 10 16:31:02 alien systemd[1]: Reached target Suspend.
Oct 10 16:31:02 alien systemd[1]: suspend.target: Unit is bound to inactive unit systemd-suspend.service. Stopping, too.
Oct 10 16:31:02 alien systemd[1]: Stopped target Suspend.
Oct 10 16:31:03 alien systemd[1]: Stopped TLP suspend/resume.
Oct 10 16:31:13 alien eyesome[30020]: Daemon: Removed file: /tmp/eyesome-is-suspending
8
  • How does sudo -H /usr/sbin/pm-hibernate open an editor? I'm trying to follow the instructions, don't want to make assumptions
    – Stewart
    Oct 13, 2018 at 16:34
  • 1
    @Stewart Good catch. It should read sudo -H gedit /usr/sbin/pm-hibernate as I've just changed. Oct 13, 2018 at 16:44
  • 1
    @Stewart Are you hibernating with lid-close, power button or menu option? Oct 13, 2018 at 17:00
  • 1
    Finally fixed it! Your suggestion gave me enough clue, that with some google-fu, I ended up at unix.stackexchange.com/a/386837
    – Stewart
    Oct 13, 2018 at 18:55
  • 1
    @Stewart Glad to hear. Thanks for pointing out the Unix & Linux answer. I up-voted it. Oct 13, 2018 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .