Hibernation? Using it?

In seconds, that’s very close to the maximum value for a 32-bit signed integer.

1 Like

It’s strange they would use signed integer for time.

1 Like

They don’t want you to hibernate. Like many others, I changed my value to a much lower number… 20 minutes.

The funny thing is in 18.04 they changed the default swap size in the installer to 1 GB because ‘nobody needs more than that with large amounts of RAM’. Oh boy the Launchpad issues around that get spicy. I ended up finding a custom partitioning script to use in my preseed file to make a large enough swap to hibernate.

I honestly didn’t realize that Linux had abandoned hibernation! To be fair, I did a Debian minimal install on my current (non-Framework — I’m batch 5!) with manual partitioning to setup full disk encryption (including encrypted swap), so I’m not exactly a “install using defaults” kind of person.

I fully concur with you that hibernation is wonderful, especially for someone who uses LUKS.

  1. There are no issues with battery drain.
  2. There are no issues with attempting to lock and unlock LUKS devices, since the computer turns off.

The second one is interesting because for the longest time, people sort of wrote off suspend as “less secure” than hibernate, since the LUKS devices wouldn’t be suspended (and so their contents could still be accessed). However, recently, people wrote up integrations with systemd and such to automatically lock LUKS devices before suspend and prompt to unlock them before resuming. However, this was (last I checked) still prone to quite a few bugs, to the point that I stopped using it and just started hibernating.

Hibernation really is a nice sweet spot between suspend and shutdown. It lets you resume your work (like suspend) while preventing any issues should your computer run out of power (like shutdown).

2 Likes

How is hibernation and/or “sleep” different from the “deep sleep” talked about in this thread Ubuntu 21.04 on the Framework Laptop - #8 by jeshikat ?

I’ve configured that option (deep sleep), but am interested in learning about the differences.

Hibernation is hibernation. Sleep and deep sleep are similar but different. As far as the differences, I imagine deep sleep shuts down more while in standby then traditional sleep. However in any sleep case, whether it is deep or not, you will be loosing battery over time.

With hibernation your computer is off and your work session saved. You are not loosing any power at all, as the computer is off.

Those are the differences.

3 Likes

I only use suspend because I can get power draw there low enough that I don’t care, and I’m (possibly unnecessarily) worried about the ssd write cycles if I had a swap file that I wrote my whole ram contents to multiple times a day. I’ve already written too much to my disk while distro-hopping and I’d like to preserve what I can because I’ve already had too many data scares and I don’t want to have to buy a new drive in the next several years at school. Even if it is all backed up, I want to do everything I can to avoid that eventuality.

@epchris hibernation saves the contents of RAM to a file on the drive then shuts the computer off entirely. It’s not as popular on Linux since typically there isn’t good enough driver support from vendors to ensure all the internal devices resume from hibernation nicely.

1 Like

I’m on Arch and trying to get the linux kernel to hibernate properly but it’s failing to do so :frowning:. I’ve got all the kernel parameters (e.g. “resume=UUID=xxxx” going and suspend to RAM works fine, but the hibernation itself always just results in a fresh reboot.

The linux kernel documentation on debugging the hibernation settings narrowed it down to a possible “platform firmware” problem, but I’m kind of stuck now.

Any tips would be appreciated :innocent:

As impractical as a forum is for discussing this, I’ll give it a shot anyway:

So you have initramfs updated to reflect the swap partition you are hibernating to? If you just updated GRUB and not initramfs then this could be your problem.

In general hibernation on Linux works, and the firmware isn’t a problem. I’ve done this on Fedora and Ubuntu.

@2disbetter Yep! That was it. Thanks so much for the pointer.

No worries! Hibernation is a very important function to me. I still don’t understand why Linux desktop just moved away from it without any explanation. it clearly works and is useful when you need it.

I just recently set up hibernation on the framework with Arch. I was shocked at how reliably it is working. Some info:

  • Full disk encryption using LUKS (swap is also encrypted)
  • Swap size 16 GB with 16 GB of RAM
  • Set mem_sleep_default=deep kernel parameter inside /boot/grub/grub.cfg
  • Set resume=UUID=X kernel parameter inside /boot/grub/grub.cfg
  • Edited /etc/systemd/logind.conf HandleLidSwitch=suspend-then-hibernate

The last hibernation did have an issue when I resumed the device the wifi didn’t work and iwctl did not show my adapter. The next time it happens I’m going to try to poke at it to see if I can at least restart it to get wifi working without a reboot.

Overall very impressed with power management via systemd on Arch. We’ll see if I continue to have issues with it.

Maybe you can do a sudo rmmod iwlwifi && sudo modprobe iwlwifi or such? I’ll see if I run into the same issue when I get mine, since I basically use hibernate by default nowadays (more reliable than sleep, drains basically no power, and quick enough to boot that I don’t have to factor that in).

And with the improvements to SSD performance and durability it is also not really an issue anymore to dump system memory to the SSD.

I mean I don’t use hibernation all the time but when I do I’m glad I do.

What I do on mine is actually have the swap partition on the expansion card drive. (I have a 250gb) Since the swap is only used when hibernating I am not worried about wearing it down prematurely either.

I will say that Windows 11 has some really fancy hibernation tech going on. Instead of just dumping the whole 64gb RAM to disk, it compresses and only dumps the RAM in use. It is able to hibernate in something like 4-5 seconds, and restarts in about 9 factoring in the time for the machine to just post.

By contrast Linux is resuming in about 20 seconds. Which is REALLY don’t mind because I’m just using hibernation to save power when I know it is going to be a while before I can get back to working on it.

Hmm, might be the specs. Mine (i5, 16GB RAM) hibernates in about 3 seconds and resumes in about 5-6 after I enter my LUKS password. Then again, it might also be that I’m using sway rather than Gnome or KDE.

1 Like

Checking back in with this, I don’t seem to run into this issue after having hibernated and resumed several times.

I am on the i7 - 85G, 64GB RAM. I believe the time frame is because I’m saving the state to the expansion card memory, and not the NVME I’m using as the system drive.

I just found Sway and I love it! I need to work on getting some quality of life features working on it, but once I get there I think I’ll be good. I just need some GUI elements, like battery life, network status, and a menu that allows me to restart, shutdown, standby, or hibernate.

I got a MNT Reform coming in, which uses Sway by default so I figure I might as well get used to it. Now I actually prefer it.

Yeah, that might be part of it (along with the 64GB of RAM).

Look into waybar instead of the default swaybar — it’s wayyyy more customizable and has a better OOTB config IMO.