[SOLVED} Hibernation Doesn't Work with Swapfile

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
KATAMAPAH
Level 1
Level 1
Posts: 21
Joined: Tue May 14, 2019 9:00 pm

[SOLVED} Hibernation Doesn't Work with Swapfile

Post by KATAMAPAH »

Hi Everyone!

Since "Suspend" option doesn't work for me properly (my laptop may wake up on its own without my interfearance) and even if it doesn't wake up, the Suspend option drains the battery like hell.

I started reading about getting Hibernation option in LM as the Windows hibernation works as expected.

I have LM 20.2 with 5.11.0-36-generic Kernel installed.

I have dual boot having Windows installed on my 512GB NVMe SSD and LM installed on 120GB SATA SSD. The laptop has 32GB of RAM

Since I don't utilize the NVMe SSD fully (I have around 300GB of free space) I figured I could shrink the C drive to get 38GB of space for only one purpose - to create the swapfile.

Since the swap was already enabled during the installation (2GB), I removed that one, used gparted to find the unallocated space from Windows (/dev/nvme0n1p5) and formatted it into linux-swap. I commented out the previous /swapfile and I then entered /dev/nvme0n1p5 none swap sw 0 0 in my /etc/fstab

$free -h shows Swap: 38Gi 0B 38Gi

After that, I tried using sudo pm-hibernate but it didn't work for me properly. It just shut down the OS without restoring the previous state of it. I still added the hibernate button

Code: Select all

sudo -i
cd /var/lib/polkit-1/localauthority/50-local.d/
nano com.ubuntu.enable-hibernate.pkla

Paste the following content into that file:

[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
ResultActive=yes

updated grub, but it doesn't work as expected.

Any ideas how to fix this issue and make the hibernation work propelry?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Hibernation Doesn't Work with Swapfile

Post by rene »

You are going to at least need to update the initramfs: sudo update-initramfs -u -k all. It will tell you what it's going to use for a RESUME partition so make sure it says the right thing.

Note; no experience with hibernation on Mint 20; just know that you will certainly and at least need the above.
KATAMAPAH
Level 1
Level 1
Posts: 21
Joined: Tue May 14, 2019 9:00 pm

Re: Hibernation Doesn't Work with Swapfile

Post by KATAMAPAH »

rene wrote: Thu Sep 23, 2021 7:19 pm You are going to at least need to update the initramfs: sudo update-initramfs -u -k all. It will tell you what it's going to use for a RESUME partition so make sure it says the right thing.

Note; no experience with hibernation on Mint 20; just know that you will certainly and at least need the above.
ok so I ran the command and below is the output. Hibernation still doesn't work properly.

Code: Select all

update-initramfs: Generating /boot/initrd.img-5.11.0-36-generic
W: Possible missing firmware /lib/firmware/i915/skl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/bxt_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/glk_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/cml_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/icl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/ehl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/ehl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/tgl_huc_7.5.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/tgl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/tgl_huc_7.5.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/tgl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/dg1_dmc_ver2_02.bin for module i915
I: The initramfs will attempt to resume from /dev/nvme0n1p5
I: (UUID=c8cbc700-a835-4d89-93ca-fe8b7e02a6d9)
I: Set the RESUME variable to override this.
update-initramfs: Generating /boot/initrd.img-5.11.0-34-generic
W: Possible missing firmware /lib/firmware/i915/skl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/bxt_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/glk_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/kbl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/cml_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/icl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/ehl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/ehl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/tgl_huc_7.5.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/tgl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/tgl_huc_7.5.0.bin for module i915
W: Possible missing firmware /lib/firmware/i915/tgl_guc_49.0.1.bin for module i915
W: Possible missing firmware /lib/firmware/i915/dg1_dmc_ver2_02.bin for module i915
I: The initramfs will attempt to resume from /dev/nvme0n1p5
I: (UUID=c8cbc700-a835-4d89-93ca-fe8b7e02a6d9)
I: Set the RESUME variable to override this
User avatar
SMG
Level 25
Level 25
Posts: 31971
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: Hibernation Doesn't Work with Swapfile

Post by SMG »

KATAMAPAH wrote: Thu Sep 23, 2021 7:10 pmAfter that, I tried using sudo pm-hibernate but it didn't work for me properly. It just shut down the OS without restoring the previous state of it.
Hibernation is turned off by default. You have to take specific steps to enable it.

Here is the [GUIDE] How to hibernate to a swap file in Linux Mint 19.x which people have been successfully using in LM20 as well.
Image
A woman typing on a laptop with LM20.3 Cinnamon.
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Hibernation Doesn't Work with Swapfile

Post by rene »

You don't have to do anything special for hibernation to work. If that pm-hibernate command didn't work, try sudo systemctl hibernate. Just tested on 20.2 and all's fine without any setup; your update-initramfs run shows the right resume device so it should Just Work.
KATAMAPAH
Level 1
Level 1
Posts: 21
Joined: Tue May 14, 2019 9:00 pm

Re: Hibernation Doesn't Work with Swapfile

Post by KATAMAPAH »

SMG wrote: Thu Sep 23, 2021 9:12 pm
KATAMAPAH wrote: Thu Sep 23, 2021 7:10 pmAfter that, I tried using sudo pm-hibernate but it didn't work for me properly. It just shut down the OS without restoring the previous state of it.
Hibernation is turned off by default. You have to take specific steps to enable it.

Here is the [GUIDE] How to hibernate to a swap file in Linux Mint 19.x which people have been successfully using in LM20 as well.
rene wrote: Thu Sep 23, 2021 9:18 pm You don't have to do anything special for hibernation to work. If that pm-hibernate command didn't work, try sudo systemctl hibernate. Just tested on 20.2 and all's fine without any setup; your update-initramfs run shows the right resume device so it should Just Work.
ok so after reading the article shared by SMG and reading about "that it should just work", I decided the double-check my grub entry and found that I used PARTUUID instead of UUID in this line GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=c8cbc700-a835-4d89-93ca-fe8b7e02a6d9"
So I changed it to the actual UUID, ran sudo update-initramfs -u -k all and sudo update-grub and it worked for me!

Code: Select all

@E15 ~ $ blkid 
/dev/nvme0n1p1: LABEL="SYSTEM" UUID="CE45-C046" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="a3fa1cc5-9f3f-497c-b0c9-cfe41269f635"
/dev/nvme0n1p3: LABEL="Windows" UUID="325A49445A4905D7" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="f1121fc5-5794-46d9-bf26-a112327f3d49"
/dev/nvme0n1p4: LABEL="WinRE_DRV" UUID="F8604AA7604A6C86" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="505be37f-aa64-412b-8b87-8cc9546b6925"
/dev/nvme0n1p5: UUID="c8cbc700-a835-4d89-93ca-fe8b7e02a6d9" TYPE="swap" PARTUUID="053ae2b8-6842-4760-bdf2-ccdf4db4dc42"
/dev/sda1: UUID="BD46-E83B" TYPE="vfat" PARTUUID="d836b04c-01"
/dev/sda5: UUID="aa1d012c-1628-45c2-9cb3-40df0767e949" TYPE="ext4" PARTUUID="d836b04c-05"
Thanks to both of you for the help!
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: [SOLVED} Hibernation Doesn't Work with Swapfile

Post by rene »

Good, but please note that you don't have to manually specify the resume device at all like that; if you delete it it works as well.
User avatar
SMG
Level 25
Level 25
Posts: 31971
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: [SOLVED} Hibernation Doesn't Work with Swapfile

Post by SMG »

rene wrote: Thu Sep 23, 2021 9:44 pm Good, but please note that you don't have to manually specify the resume device at all like that; if you delete it it works as well.
People had posted on the forum with issues in the past and usually not correctly specifying the resume device was the source of the problem.

If it now works without it, something must have changed. Someone in another thread (troubleshooting a suspend issue) tried using suspend then hibernate and said it worked without him doing anything special, so I believe you. I just do not know what was changed.
Image
A woman typing on a laptop with LM20.3 Cinnamon.
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: [SOLVED} Hibernation Doesn't Work with Swapfile

Post by rene »

I do believe things have changed semi-recently. Not many moons versions ago the initramfs' RESUME device was on Ubuntu/Mint configured in /etc/initramfs-tools/conf.d/resume and it used to be a common source of a 30 second boot delay when people e.g. forewent or changed their swap partition; that file needing to be removed or updated.

At the moment it's the thing I initially said as to the update-initramfs: it automatically sets the currently active swap device (or file, supposedly) to be the resume device and fairly verbosely advertises such as here for example as:
KATAMAPAH wrote: Thu Sep 23, 2021 9:04 pm

Code: Select all

[ ... ]
I: The initramfs will attempt to resume from /dev/nvme0n1p5
I: (UUID=c8cbc700-a835-4d89-93ca-fe8b7e02a6d9)
I: Set the RESUME variable to override this
Probably also has something to do with the changeover to swap files rather than partitions; Ubuntu having decided the resume device handling needing to be more dynamic now that swap device handling (sort of) was.

Anyways. At this point in time things mostly Just Work then.
Locked

Return to “Installation & Boot”