LM 21.2 hibernated to swapfile does not restore hibernated session

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.
Post Reply
Mintrider
Level 1
Level 1
Posts: 5
Joined: Tue Mar 19, 2024 5:54 am

LM 21.2 hibernated to swapfile does not restore hibernated session

Post by Mintrider »

choco wrote: Wed Jul 26, 2023 9:09 pm Still worked no problem in 21.2 cinnamon.
For me without the no :cry:

Everything worked (no errors) following the guide also checking in the console it outputs "yes" as well having "hibernate" as option in the Quit menu.

Despite all of this the session always starts fresh and nothing is restored.

LM 21.2, 64bit cinnamon with lvm encrypted root partition.
Last edited by karlchen on Tue Mar 19, 2024 6:21 am, edited 3 times in total.
Reason: Split off from a 6 year old tutorial thread, https://forums.linuxmint.com/viewtopic.php?t=284100, the author of which left the forum years ago. Problems reports should not be suffixed to tutorials, please. They deserve their own support threads.
t42
Level 11
Level 11
Posts: 3747
Joined: Mon Jan 20, 2014 6:48 pm

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by t42 »

I think you need chroot and set the resume target to come out of hibernation. Set RESUME=/dev/mapper/swap (or whatever name you used for it) in /etc/initramfs-tools/conf.d/resume and still being in chroot terminal run update-initramfs -u. Don't know if LVM needs adjustments to that.
-=t42=-
Mintrider
Level 1
Level 1
Posts: 5
Joined: Tue Mar 19, 2024 5:54 am

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by Mintrider »

Hello @t42,

thank's for your anwser. I'm not quite sure how to proceed with "chroot" - some research showed that is something quite complex. I "only" want hibernate to work and don't get a degree in computer engineering :lol:

Is it right I need to start a live session from stick for example and then "chroot" into the present installation? My install still works fine just waking up from hibernate does not.

I checked for the file /etc/initramfs-tools/conf.d/resume - it's not present on my system. Is it possible to do the two steps you described without chroot?
BrunoMiranda
Level 4
Level 4
Posts: 359
Joined: Thu Jun 24, 2010 2:22 pm

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by BrunoMiranda »

Hi Mintrider,

I might be missing some context here, but since you claim you can boot into that Mint installation, I assume you don't need to chroot into it, you can do just the normal sudo or open folder on nemo or caja as administrator and then open and edit the files you need. chroot is meant (if I'm not mistaken) for when you can't boot into an OS or you're booting a different one and want to change root (hence the name) into a different installation.

If you're still having troubles making hibernation work I can recommend installing uswsusp. Then (if this isn't automatically offered to you on install) you configure if by:

Code: Select all

sudo dpkg-reconfigure uswsusp
It's text mode only but it will give you the chance to easily select the swap and compressing hibernation data (highly recommended if you're using a SSD you want to spare unnecessary writes and it makes hibernation and resuming faster). It also automatically performs the update-initramfs -u in the end. It might also (not sure!) automatically set the needed information on /etc/initramfs-tools/conf.d/resume. If not, you can create it and give it the swap file info.


Please note I'm writing this out of memory for hibernation to a partition, not to a file but I'm assuming as long as you give it the file to use it will also work. It worked for me when I tried hibernating to a file but that was years ago.

My contents for the /etc/initramfs-tools/conf.d/resume file is:
RESUME=UUID=435987e0-2644-4781-96ff-9dfa2ad2fde0
Again, this is for a swap partition and not for a swap file.


There might be some valuable information here:
https://askubuntu.com/questions/6769/hi ... -swap-file

You might check and even need to configure GRUB for it to know where to resume from after a successful hibernation. This might be the thing you're looking for.


Cheers.
Bye for now,
Bruno


(Always backup before you screw up :)
User avatar
MiZoG
Level 8
Level 8
Posts: 2395
Joined: Fri Jan 26, 2018 8:30 pm
Location: Athens, Greece

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by MiZoG »

There is no easy (graphical) way to configure your system to use hibernation.
You will have to dig (a little bit not that much anyway) deeper into your new OS, execute some commands in a terminal and edit a couple of configuration files. It sounds more intimidating than it really is.

1. Hibernation is not working reliably with all machines on Linux for various reasons

2. uswusp is deprecated and AFAIK not available in Ubuntu repos for Jammy, hence Linux Mint 21.x. systemd is "in charge" now.

3. These instructions on hibernating without swap partition, applicable to Ubuntu-based systems like Mint as well, worked remarkably well for me but -mind you- my hardware is old and well-supported on Linux.
BrunoMiranda
Level 4
Level 4
Posts: 359
Joined: Thu Jun 24, 2010 2:22 pm

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by BrunoMiranda »

MiZoG wrote: Wed Mar 20, 2024 11:37 am uswusp is deprecated and AFAIK not available in Ubuntu repos for Jammy, hence Linux Mint 21.x. systemd is "in charge" now.
Good point, and you make sense. I have uswsusp installed on my Mint 21.3 because it must have been inherited from a Mint 20 upgrade. Synaptic does not give me an option to reinstall it, so it is not available in the repos as you said.
Mind you that I don't use hibernation in any of my systems anymore, i was just commenting on past experience memory.

So, just being curious, I like the way uswsusp compresses the data before writing it to the swap partition or file. With the general use of SSDs which have limited writes, do you know if current hibernation methods also compress the data?
Bye for now,
Bruno


(Always backup before you screw up :)
Mintrider
Level 1
Level 1
Posts: 5
Joined: Tue Mar 19, 2024 5:54 am

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by Mintrider »

BrunoMiranda wrote: Wed Mar 20, 2024 7:24 am
You might check and even need to configure GRUB for it to know where to resume from after a successful hibernation. This might be the thing you're looking for.
That might be very correct!
MiZoG wrote: Wed Mar 20, 2024 11:37 am 3. These instructions on hibernating without swap partition, applicable to Ubuntu-based systems like Mint as well, worked remarkably well for me but -mind you- my hardware is old and well-supported on Linux.
Thank's, while my hardware is also old and well supported on linux these instructions didn't work remarkably well for me.

The mention command:

Code: Select all

filefrag -v /swap|awk 'NR==4{gsub(/\./,"");print $4;}'
doesn't return any label but just a

Code: Select all

open: No such file or directory
.

I didn't expect that hibernating is such a problem with linux. It's essential for my old notebook at it discharges in sleep mode to fast!
t42
Level 11
Level 11
Posts: 3747
Joined: Mon Jan 20, 2014 6:48 pm

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by t42 »

Mintrider wrote: Sat Mar 23, 2024 6:58 am I didn't expect that hibernating is such a problem with linux.
I noticed that in your first comment you are referring to a guide named "How to hibernate to a swap file in Linux Mint 19.x". And it seems that you want it to apply it to
Mintrider wrote: Tue Mar 19, 2024 5:58 am LM 21.2, 64bit cinnamon with lvm encrypted root partition.
So did you have a resume device to point to? If not you need to adjust your LVM setup by creating swap partition not swap file and proceed from there.
-=t42=-
User avatar
MiZoG
Level 8
Level 8
Posts: 2395
Joined: Fri Jan 26, 2018 8:30 pm
Location: Athens, Greece

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by MiZoG »

...

Code: Select all

filefrag -v /swap|awk 'NR==4{gsub(/\./,"");print $4;}
doesn't return any label but just a

Code: Select all

"open: No such file or directory"
In Debian wiki the name used as example is "swap".
By default swapfile on Mint is simply swapfile

So I presume this command will do:

Code: Select all

filefrag -v /swapfile|awk 'NR==4{gsub(/\./,"");print $4;}'
if you get a "permission denied" message, run it with sudo.
BrunoMiranda
Level 4
Level 4
Posts: 359
Joined: Thu Jun 24, 2010 2:22 pm

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by BrunoMiranda »

Mintrider wrote: Sat Mar 23, 2024 6:58 am I didn't expect that hibernating is such a problem with linux.
As far as I remember hibernation as even been disabled by default on Mint. There's a discussion about it here:
viewtopic.php?t=384015

Cheers.
Bye for now,
Bruno


(Always backup before you screw up :)
Mintrider
Level 1
Level 1
Posts: 5
Joined: Tue Mar 19, 2024 5:54 am

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by Mintrider »

t42 wrote: Sat Mar 23, 2024 7:34 am
Mintrider wrote: Tue Mar 19, 2024 5:58 am LM 21.2, 64bit cinnamon with lvm encrypted root partition.
So did you have a resume device to point to? If not you need to adjust your LVM setup by creating swap partition not swap file and proceed from there.
I ended accidentally with a install with LVM. My intention was to have a "normal" full LUKS encrypted root partition.

So in my case I can't use a swap file to resume from hibernation?
MiZoG wrote: Sat Mar 23, 2024 12:58 pm So I presume this command will do:

Code: Select all

filefrag -v /swapfile|awk 'NR==4{gsub(/\./,"");print $4;}'
That's correct! I get a 8-digit number in return

Checking the grub file actually it is already all in their...

Missing piece was the file etc/initramfs-tools/conf.d/resume I created it like your guide explained and did run `update-initramfs -k all -u`

Output:

Code: Select all

update-initramfs: Generating /boot/initrd.img-5.15.0-101-generic
W: initramfs-tools configuration sets RESUME=UUID=ec23714e-a182-44fd-901d-01276a2d26d7
W: but no matching swap device is available.
BrunoMiranda wrote: Sat Mar 23, 2024 1:00 pm As far as I remember hibernation as even been disabled by default on Mint.
Correct, and I followed already more then 5 guides to get it activated. It works partially (going into hibernate) - only the resume is the missing piece now. But maybe my setup with this LVM thing is actually a show stopper...
Mintrider
Level 1
Level 1
Posts: 5
Joined: Tue Mar 19, 2024 5:54 am

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by Mintrider »

Well, it worked! Despite the warning about the swap file!

So missing piece was the resume file!

Thank's to everyone helping me on my journey getting mint to hibernate! :D
BrunoMiranda
Level 4
Level 4
Posts: 359
Joined: Thu Jun 24, 2010 2:22 pm

Re: LM 21.2 hibernated to swapfile does not restore hibernated session

Post by BrunoMiranda »

Glad you made it, @Mintrider.

Can you please edit the topic's subject and add [Solved] before it? This way when folks also having this problem read the topic list they can know this one is a practical one with a valid solution.

Thanks and cheers.
Bye for now,
Bruno


(Always backup before you screw up :)
Post Reply

Return to “Installation & Boot”