23 - 06 - 2017

Use suspend-freeze with hibernation instead of suspend-to-ram

In somecases you would like to have suspend working but the system is unable to recover from suspend to ram. From Linux Kernel 3.9 we have a chance to configure the new option called 'suspend-freeze'. It's diffrent suspend mode, it does not turn off the computer but it's better than nothing.

My problem was on openSUSE I couldn't get it working after specified timeout via Power management or dconf. But it seems there is an workaround.

Configure systemd to use suspend-freeze

vi /etc/systemd/sleep.conf

Define idle time after going to suspend

vi /etc/systemd/logind.conf

In my environment based on openSuse 13.1 with Cinnamon and GDM it was required to remove pm-suspend binary. Without it the default suspend mode under Cinnamon/Gnome/GDM was suspend-to-ram which is ofcourse broken with my nvidia properiaty modules.

$ rm -f `which pm-suspend` 

Add script for going to hibernate after specified amount of time, under /usr/lib/systemd/system-sleep directory

# Purpose: Auto hibernates after a period of sleep
# Edit the "autohibernate" variable below to set the number of seconds to sleep.
curtime=$(date +%s)
# 30 min

case $1/$2 in
    # Suspending. Record current time, and set a wake up timer.
    echo "Suspending until" `date -d "$autohibernate seconds"`
    echo "$curtime" > $lockfile
    rtcwake -m no -s $autohibernate
    # Coming out of sleep
    sustime=$(cat $lockfile)
    echo -n "Back from suspend... "
    rm $lockfile
    # Did we wake up due to the rtc timer above?
    if [ $(($curtime - $sustime)) -ge $autohibernate ]
        # Then hibernate
        echo "hibernate"
        /usr/bin/systemctl hibernate
        echo "wake-up"
        # Otherwise cancel the rtc timer and wake up normally.
        rtcwake -m disable

I didn't write the script. The source of it comes from ArchLinux forum: https://bbs.archlinux.org/viewtopic.php?id=161053#4


Login Form