Hibernation? Using it?

The Arch wiki covers both hybrid sleep and suspend-then-hibernate:

https://wiki.archlinux.org/title/Power_management#Hybrid-sleep_on_suspend_or_hibernation_request

The former “suspends the system both to RAM and disk, so a complete power loss does not result in lost data. This mode is also called suspend to both.”

The latter “initially suspends the system to RAM and if it is not interrupted within the delay specified by HibernateDelaySec in systemd-sleep.conf(5), then the system will be woken using an RTC alarm and hibernated.”

1 Like

I don’t mind the delay, so I use nothing but Hibernation and Shutdown. Taking a sip of coffee as it starts up is not a big deal to me.

1 Like

Got hibernate working on Ubuntu 21.04, only thing the guide didn’t mention is for me it wouldn’t hibernate until I turned off secure boot

I had hibernation running on my last laptop because I often was coding from the bus. I don’t use it anymore. Everything boots quick enough and it’s a way to ensure I restart things like Chrome or Slack that are memory hogs.

1 Like

On Linux I have found this to be VERY true. However on Windows not so much. At any rate restarting the whole system instead of the process is not my preferred method. But this is an important point nonetheless: A fresh system has many other benefits that might not be captured by a system that hasn’t been restarted in months.

Honestly I get enough system restart simply from updating components and then requiring a restart.

1 Like

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).