Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to hibernate in Debian 11?

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
Gorg
Posts: 23
Joined: 2019-10-24 09:30

How to hibernate in Debian 11?

#1 Post by Gorg »

Hi everyone,

I've just recently installed Debian 11 on my laptop, but I can not get hibernation to my swapfile working.

After adding the swapfile to my /etc/fstab, the "Hibernation" option was added automatically to the logoff screen in KDE Plasma, but it will not resume to my old session.

I read that I have to edit /etc/initramfs-tools/conf.d/resume to point to the file, but whatever I enter, I get initramfs/cryptsetup errors:

Code: Select all

RESUME=/dev/mapper/md1_crypt/swapfile
Leads to:

Code: Select all

sudo update-initramfs -u
...
W: initramfs-tools configuration sets RESUME=/dev/mapper/md1_crypt/swapfile
W: but no matching swap device is available.
While entering

Code: Select all

RESUME=/swapfile
Prints:

Code: Select all

sudo update-initramfs -u
...
cryptsetup: ERROR: Couldn't resolve device /swapfile
If i just enter

Code: Select all

RESUME=/dev/mapper/md1_crypt
The Hibernation-option is removed from the system again.

I know I had hibernation working on Debian 10, but I can't remember having such issues with setting it up. However, I also noticed that both helper packages "hibernate" and "uswsusp" are no longer available.

Does somebody know what goes wrong here, because I can see the active swapfile in "free", but it just won't resume.

Aki
Global Moderator
Global Moderator
Posts: 2823
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 69 times
Been thanked: 385 times

Re: How to hibernate in Debian 11?

#2 Post by Aki »

Hello,

Have you seen here [1] ?

[1] https://wiki.debian.org/Hibernation/Hib ... _Partition
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Gorg
Posts: 23
Joined: 2019-10-24 09:30

Re: How to hibernate in Debian 11?

#3 Post by Gorg »

Hi, thanks.

No, I hadn't previously seen that site. However, I'm failing at the step "aptitude install uswsusp", because, as I mentioned previously, it's not in the Bullseye repository.

I tried adding

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/mapper/md1_crypt"
to my kernel parameters, but that didn't work, either.

I still think I must have missed something, but on Buster I probably did use uswsusp. However, I can't remember even doing all the steps in the guide back then.

I could also just install the package from the Buster repo, but I don't know how "wise" that would be and I don't want to mess up my new installation.

Aki
Global Moderator
Global Moderator
Posts: 2823
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 69 times
Been thanked: 385 times

Re: How to hibernate in Debian 11?

#4 Post by Aki »

Hello,

Do you want to hibernate the operating system on a file or on a swap partition ?

Is it mandatory for you to crypt the swap file or the swap partition ?
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

vv0yy
Posts: 1
Joined: 2021-11-13 14:20

Re: How to hibernate in Debian 11?

#5 Post by vv0yy »

Hi, I just fixed same issue.

Setting up proper grub resume params should do the job,

0. backup important stuff:

Code: Select all

sudo cp /etc/default/grub  /etc/default/grub_bak
sudo cp /etc/initramfs-tools/conf.d/resume /etc/initramfs-tools/conf.d/resume_bak
sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg_bak
1. generate resume params for GRUB:

(note "/swapfile" and change if needed)

Code: Select all

RESUME_PARAMS="resume=UUID=$(findmnt / -o UUID -n) resume_offset=$(sudo filefrag -v /swapfile|awk 'NR==4{gsub(/\./,"");print $4;}') " && echo $RESUME_PARAMS
2. put results in /etc/default/grub:

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="<OUTPUT OF PREVIOUS COMMAND>"
eg:

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=754a5246-51ba-4890-ac36-9a7b1157f866 resume_offset=2146304"

3. update GRUB

Code: Select all

sudo update-grub
BELOW IS WHAT I'M NOT SURE IF IS NEEDED

4. put UUID to /etc/initramfs-tools/conf.d/resume:

Code: Select all

RESUME=UUID=<UUID FROM PREV COMMAND>
eg:

Code: Select all

RESUME=UUID=754a5246-51ba-4890-ac36-9a7b1157f866
5. update initframs

Code: Select all

sudo update-initramfs -c -k $(uname -r)

more to read:
https://forums.linuxmint.com/viewtopic. ... 2&t=284100
https://forums.bunsenlabs.org/viewtopic.php?pid=118541 (till last post)

good luck

BryanFRitt
Posts: 42
Joined: 2014-02-08 19:36

Re: How to hibernate in Debian 11?

#6 Post by BryanFRitt »

Thanks vv0yy for these instructions, it helped me get hibernation working. :)
---
To find out your swap file location. (assuming you already have one)
look in /etc/fstab for the swap file location and/or

Code: Select all

cat /proc/swaps
---
vv0yy wrote: 2021-11-13 14:34 5. update initframs

Code: Select all

sudo update-initramfs -c -k $(uname -r)
If you want to do this for all installed kernels rather than just the current running kernel:

Code: Select all

sudo update-initramfs -c -k all
The use of "all" for the version string specifies that update-initramfs should operate on all installed kernel versions (with -c), or on all installed kernel versions that already have an initramfs (with -d or -u).
from `man update-initramfs`

Post Reply