1

I grew tired of my laptop losing too much battery while in suspend and therefor wanted to setup hibernate. However, I can not get it to work. Systemctl hibernate shuts off the laptop, but it does not resume its previous state when turned on again. I use Ubuntu 22.04.4 LTS and Windows 11 in a dual boot configuration and I am trying to hibernate Ubuntu (which is the main thing I am using) on a Lenovo L13 Yoga.

I tried a lot of things I found in other posts, the last and biggest post being Ubuntu 18.04 can't resume after hibernate.

Currently I have the following configuration:

cat /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla:

[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

[Enable hibernate to be run via cron] Identity=unix-user:* Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions ResultAny=yes

cat /etc/initramfs-tools/conf.d/resume

RESUME=UUID=5147e4a0-81c2-440a-ba09-ae762f4304fb
RESUME_OFFSET=52942848

cat /etc/default/grub

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT="saved" GRUB_TIMEOUT_STYLE="hidden" GRUB_TIMEOUT="10" GRUB_DISTRIBUTOR="lsb_release -i -s 2> /dev/null || echo Debian" GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=5147e4a0-81c2-440a-ba09-ae762f4304fb resume_offset=52942848" GRUB_CMDLINE_LINUX=""

cat /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p5 during installation
UUID=5147e4a0-81c2-440a-ba09-ae762f4304fb /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=5E7F-D0A8  /boot/efi       vfat    umask=0077      0       1
#UUID=cbc63938-26a9-47c6-b63e-3a1a1b00ee09 none swap sw 0 0
/swapfile                                 none            swap    sw              0       0

free -h

               total        used        free      shared  buff/cache   available
Mem:            15Gi       2,0Gi        10Gi       575Mi       2,7Gi        12Gi
Swap:           20Gi          0B        20Gi

sudo filefrag -v /swapfile

Filesystem type is: ef53
File size of /swapfile is 22548578304 (5505024 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       0:   52942848..  52942848:      1:            
   1:        1..    2047:   52942849..  52944895:   2047:             unwritten

cat /sys/power/state

freeze mem disk

cat /sys/power/disk

[platform] shutdown reboot suspend test_resume 

This is everything I can think of that might be relevant. Please ask if there is anything else I can provide.


EDIT: I removed the swapfile and created a swap partition to try to resume from there, following the instrucions in https://help.ubuntu.com/community/SwapFaq and https://www.geeksforgeeks.org/how-to-enable-hibernate-in-ubuntu-22-04-lts/. (As a consequence, I now see the following GRUB menue enter image description here

EDIT3: this was only happening because I messed up the boot menu, I fixed it and now it behaves exactly like with the swapfile) But it still doesn't resume any of the apps I have open before hibernating. Could there be anything that keeps my laptop from writing the RAM to the swap partition?


EDIT2: I have used "Grub Customizer" in the past to edit the boot sequence scripts. Though I've not used it to edit the boot menu to include resume, but directly edited the file with nano. According to this "https://ubuntuhandbook.org/index.php/2021/08/enable-hibernate-ubuntu-21-10/" Grub Customizer might mess with enabling hibernate?

Sabaca
  • 31

1 Answers1

1

In my boot script made with GRUB Customizer I had the line

linux   /boot/vmlinuz-6.2.0-39-generic root=UUID=5147e4a0-81c2-440a-ba09-ae762f4304fb ro  quiet splash $vt_handoff

Where the "quiet splash" looks like the GRUB_CMDLINE_LINUX option I had to change in the /etc/grub/default, so I guessed that this script is setting up all the boot options and ignoring /etc/default/grub.

Therefor I added the resume=UUID=X to this line

linux   /boot/vmlinuz-6.2.0-39-generic root=UUID=5147e4a0-81c2-440a-ba09-ae762f4304fb ro  quiet splash resume=UUID=e638352c-0d3f-451d-ae01-86f7fbf6c74e $vt_handoff

and now it works!

Sabaca
  • 31