Comment # 11 on bug 1020965 from
Alright. I fixed hibernate.sh script like this:

---------------
#!/bin/bash

lockfile='/tmp/hibernation_started.lock'

/usr/bin/logger 'AC power is off.'

# Is hibernation already started?
if [ -f "$lockfile" ]
then
    /usr/bin/logger 'Hibernation already started.'
    exit 0
fi

/usr/bin/touch $lockfile

# Wait a bit (it may be just a short power off)
sleep 30

# Is AC power still off?
grep -q "0" /sys/class/power_supply/ADP1/online

if [ $? = 0 ]
then
    /usr/bin/logger 'Power is still off...'
    # Is laptop lid closed?
    grep -q closed /proc/acpi/button/lid/LID0/state
    if [ $? = 0 ]
    then
        /usr/bin/logger 'Initiating closed lid hibernation...'
        /usr/bin/rm $lockfile
# NOTE: I am deliberately setting shutdown instead of hibernate to test if the
script itself works
        shutdown -h now
    fi
fi
---------------

And here is the test (watching 'journalctl -f' through SSH):


// disconnect AC power

Feb 16 18:32:31 acer.group root[2762]: AC power is off.
Feb 16 18:32:32 acer.group systemd-udevd[2767]: Process '/usr/sbin/tlp auto'
failed with exit code 4.

// connect AC power (after less than 30 seconds)

Feb 16 18:33:01 acer.group root[2949]: AC power is on.
Feb 16 18:33:01 acer.group root[2950]: Cancelling closed lid hibernation.

// disconnect AC power (and wait more than 30 seconds)

Feb 16 18:33:22 acer.group root[3049]: AC power is off.
Feb 16 18:33:23 acer.group systemd-udevd[3054]: Process '/usr/sbin/tlp auto'
failed with exit code 4.
Connection to acer closed by remote host.
Connection to acer closed.

// system shuts down successfully

This means the script works fine now. No issue with it and thanks for telling
me that I should check another file for the online state. No idea what the 'tlp
auto' fail means and why it appears.
============================================================

Then I booted the system setting initcall_debug and no_console_suspend in GRUB
on boot, like explained here (after doing the "STFW" step):

https://01.org/blogs/rzhang/2015/best-practice-debug-linux-suspend/hibernate-issues

After booting completed I ran:

# systemctl hibernate

The system powers off after a few seconds of hard disk activity. No any
messages on screen, nothing showed in 'journalctl -f' while watching it through
SSH. Pressing the power button doesn't restore from hibernate but instead boots
through GRUB like from a shutdown state.

After booting in the journal I read:

...
Feb 16 18:40:01 acer systemd[1]: Starting Resume from hibernation using device
/dev/sda1...
Feb 16 18:40:01 acer systemd-hibernate-resume[284]: Could not resume from
'/dev/sda1' (8:1).
Feb 16 18:40:01 acer kernel: PM: Starting manual resume from disk
Feb 16 18:40:01 acer kernel: PM: Hibernation image partition 8:1 present
Feb 16 18:40:01 acer kernel: PM: Looking for hibernation image.
Feb 16 18:40:01 acer kernel: PM: Image not found (code -22)
Feb 16 18:40:01 acer kernel: PM: Hibernation image not present or could not be
loaded.
Feb 16 18:40:01 acer systemd[1]: Started Resume from hibernation using device
/dev/sda1.
Feb 16 18:40:01 acer systemd[1]: Reached target Local File Systems (Pre).
Feb 16 18:40:01 acer systemd[1]: Reached target Local File Systems.
Feb 16 18:40:01 acer systemd[1]: Reached target System Initialization.
Feb 16 18:40:01 acer systemd[1]: Reached target Basic System.
Feb 16 18:40:01 acer systemd[1]: Reached target Initrd Root Device.
...


Trying the same thing without initcall_debug and no_console_suspend hibernates
the system just like explained initially but upon powering it on the monitor is
off, the system doesn't react to any key press or other event and trying to
connect to it through SSH gives "No route to host". The only way to get out of
this is hardware reset.

Here is also my partition layout:

# fdisk -l
Disk /dev/sda: 37.3 GiB, 40007761920 bytes, 78140160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x20a0209f

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1           2048  2105343  2103296    1G 82 Linux swap / Solaris
/dev/sda2  *     2105344 18876415 16771072    8G 83 Linux
/dev/sda3       18876416 78139391 59262976 28.3G 83 Linux


Let me know if that information is enough for you to forward this upstream. If
it is not - please provide steps for further debugging in layman terms
(hopefully not using "STFW"). Thank you.


You are receiving this mail because: