Problem with wakeup from hibernation

I am unable to wake up my laptop from hibernation.
The laptop seems to go into hibernation when I run sudo systemctl hibernate or close the lid (I’ve edited /etc/systemd/logind.conf) but won’t wake up either by opening the lid, pressing keys or short pressing the power button. Only when I press the power button for about 10 seconds it seems to reboot into grub and after the login screen all running programs are restored.
Is this intended beheavior or is there a way to automatically wake from hibernation just by opening the lid or short-pressing the power button?

I am running Ubuntu 20.04 on dual boot with win10 on a Surface Laptop 3 with surface-linux kernel (https://github.com/linux-surface). RAM is 8 GB and I’ve created a 12GB swapfile and activated hibernation using these instructions: https://fitzcarraldoblog.wordpress.com/2018/07/14/configuring-lubuntu-18-04-to-enable-hibernation-using-a-swap-file/.

Also if there is another way to save power without hibernation when not using the laptop for a few hours I would be interested. Suspend drained the battery by 30-40% in 8 hours, so it isn’t really an option. I’ve also read about TLP, but it is advised against for surface-linux kernel.

I am a newbie to linux so please bear with me if I forgot to mention certain things or if I overlooked an answer to my question.

Edit:
I’ll try to be more accurate. I’ve followed the RP accurately without typos or error messages.
I’ve used the following commands to create a swapfile:

$ sudo swapoff -a
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=12M
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapoff -a
$ sudo swapon /swapfile

$ cat /proc/meminfo | grep -i memtotal
MemTotal:        7730068 kB

$ ls -la /swapfile
-rw------- 1 root root 12884901888 Feb 23 15:34 /swapfile

Then:

$ grep swapfile /etc/fstab
/swapfile                                 none            swap    sw              0       0

Then I found out UUID and resume_offset by running:

$ sudo blkid
$ sudo filefrag -v /swapfile

Then I’ve added UUID and resume_offset.

$ sudo nano /etc/default/grub

to:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=df7a53ad-3937-423e-8575-0d48d5131ee0 resume_offset=104448"

And updated grub.

$ sudo update-grub

Then I edited initramfs to include UUID, resume_offset and # Resume from /swapfile and updated it.

$ sudo nano /etc/initramfs-tools/conf.d/resume    
$ sudo update-initramfs -u -k all

After that I’ve edited polkit (I’ve used both instructions in the RP just to be sure).

First with this command

$ sudo nano /etc/polkit-1/rules.d/85-suspend.rules

To read:

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.login1.suspend" ||
        action.id == "org.freedesktop.login1.suspend-multiple-sessions" ||
        action.id == "org.freedesktop.login1.hibernate" ||
        action.id == "org.freedesktop.login1.hibernate-multiple-sessions")
    {
        return polkit.Result.YES;
    }
});

Second

$ sudo nano /var/lib/polkit-1/localauthority/50-local.d/50-enable-suspend-on-lockscreen.pkla

To read:

[Allow hibernation and suspending with lock screen]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend;org.freedesktop.login1.suspend-multiple-sessions;org.freedesktop.login1.hibernate org.freedesktop.login1.hibernate-multiple-sessions
ResultAny=yes
ResultInactive=yes
ResultActive=yes    

Afterwards I rebooted and edited
/etc/systemd/logind.conf
to
HandleLidSwitch=hibernate (uncommenting the line of course).


Go to Source of this post
Author Of this post: su0341
Title Of post: Problem with wakeup from hibernation
Author Link: {authorlink}