Hibernation / Hibernate on Librem

Trying to change my librems behaviour from suspend (draining the battery within one day) to hibernate as i want to preserve my current state of work without having to reopen everything (i’m used to work with hibernation from my old laptop).

Using

  • the system menu (right upper corner, icon screwdriver + spanner)
  • energy
  • suspend & power button
  • when pressing power button: hibernate

Result:

  • i only get logged out
  • no hibernation, no nothing

Having followed the only thread close to this topic that didn’t come up with a solution, i wonder, as i think, i can’t be the only one with those problems.

RAM: 16GB
Swap: 17.14GB (should be enough?)

Can anybody point me towards how to get my laptop to use hibernation? Thanks in advance

1 Like

I don’t have a solution to this issue unfortunately, but I’m wondering how you selected hibernate from the “when the power button is pressed” option in power settings? Mine only has three available options here - “Suspend” “Power Off” and “Nothing.”

What version are you running? I have 15v3 and I have hibernate as an option…

Mine is 13 v3, PureOS updated via a) sudo apt update && sudo apt-get upgrade + b) via software - updates. I’ve got 4 options - your’s + hibernate.

Following this and that one can assume, i don’t have enough swap-space (16GB RAM - 20GB Swap).

sudo pm-hibernate had the screen go blank and return to previous state (as when i started).

Librem 13v3 PureOS also fully updated via sudo apt update & sudo apt full-upgrade. Only have the three options listed above, no hibernate.

Furthermore followed this guide successfully until GParted stumbled on resize with something like "a partition with used sectors xxx greater than its length xxx+2.

So no further progress.

I am the author of the thread you linked to in your initial post. I have been trying to make some progress on this for some time. Recently my computer state was corrupted after my laptop (15v3) ran out of juice. As a result I had to reinstall PureOS. I was not able to install it on an encrypted partition as per the instructions on the PureOS wiki page. I managed instead to set up a normal installation (unencrypted partition) and the default setup creates a swap partition which my previous installation (factory shipped) did not have.

I now confirm that I can hibernate my laptop using the poweroff button which you can setup in your power settings. However, I am still unable to get the critical battery issue sorted out.

For me - the issue is a month old, but my problems not sorted out - it looked like the main-problem were

a) Swap-Partition not big enough
b) disk-encryption (which also stopped me from resizing via GParted)

@mladen It might be an idea to consider increasing the default (OEM) swap-partition to a decent size that general hibernation & hibernation on emergency shutdown due to low battery are working by default (using a premium-priced laptop, one can assume, that such a common feature should be working out of the box).

Please create an issue here: https://tracker.pureos.net

Thanks!

done: https://tracker.pureos.net/T535

2 Likes

my original factory-install did not come with a swap partition…yours has one???

yes. seemed so. …

I’m a happy new user of a Librem15v4 which comes with a swap partition, and after little reading and investigation I saw that hibernating couldn’t work at resume stage because of the swap encryption setting: the line of my /etc/crypttab for swap encryption used to read

luks-7f1003b8-e5a0-4fae-9b4d-f8a1428b5255 /dev/disk/by-id/wwn-0x5002538e700e9681-part3  /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256

This means the key for swap encryption was regenerated with a different value at each boot! I can understand security concerns, e.g. making it extremely hard to access memory pages stored on swap after a brutal shutdown; however, I have a decent amount of RAM with respect to my common usage, so I use very little swap except for hibernating.
So I went for setting swap using standard LUKS with passphrase prompt.
I detail below the steps I followed on pre-installed PureOS to get hibernation working, with an encrypted root partition as /dev/dm-0, and an encrypted swap as described above, which can also be reached as /dev/dm-1.

I first did in a terminal

sudo swapoff /dev/dm-1

then opened gnome-disks to reset the partition hosting the encrypted device (UUID=7f1003b8-e5a0-4fae-9b4d-f8a1428b5255, meaning /dev/sda3 in my case), created on it a standard LUKS device containing a swap partition, and enabled it. Then I edited the line of crypttab regarding swap so it now reads

luks-de5ef9e9-e265-4b74-9316-2856129af62b UUID=de5ef9e9-e265-4b74-9316-2856129af62b     none    luks,initramfs

If you reproduce my setup, put the correct value for the two occurences of the UUID of the disk partition that supports the LUKS device used for swap. Then, I updated the line in /etc/fstab regarding the new swap device, and finally I did in a terminal

sudo update-initramfs -u -k 4.19.0-2-amd64
sudo update-grub

Note that I deliberately chose not to update init ramdisks of all kernels at once: in case something went wrong, I could with higher probability still boot with another installed kernel by simply editing GRUB command-line at boot time removing “resume=” setting and run a kernel with an unchanged init ramdisk (I also noticed recovery mode in GRUB menu, but did’t want to risk needing it!). You may need to put another kernel release name in update-initramfs invocation (autocompletion of kernel releases worked for me there!).

With this setup, I still have to type the passphrase for opening encrypted root partition when resuming, whereas it should not be necessary IMHO: ideally, the initramfs stage should be self-contained enough to prompt for the passphrase used to open swap, and try to resume from it before looking for a root partition. When I get too tired of typing two passphrases at each boot, I may look further into this.

when you say that you are reseting the swap partition, do you mean that you are formatting it, or do you mean that you are deleting it and re-creating it?

Sorry just want to make sure before i mess up my system. I really want hibernation to work.

Thanks for the help!

@jeremiah could you be prevailed upon to help explain the intricacies of this? My questions are:

  1. To get a new LUKS partition, I’ll need to delete the swap partition, and create a new one, insuring that I format it as a LUKS one. This will give me the new luks-key (or whatever you call it). Is this correct? Or does resetting the partition in this case mean something else?

  2. Editing /etc/crypttab I would replace the previos swap line with:

luks-my-specific-one UUID=my-specific-one none luks,initramfs

  1. Here though I need to ensure the right UUID is given elsewhere in the file that is referencing the swap drive? I have 2 entries, and I thought the first was just the root drive. As I didn’t mess with that partition why would I need to change anything here?

  2. Using uname I can find the current kernel being used and use it with the following:

sudo update-initramfs -u -k current-kernel
sudo update-grub

Now assuming that the bios is set to boot off the right drive, then I should just have to enter my password twice, to decrypt the root and swap?

This information is crucial to getting hibernation working on the Librem and I appreciate your time!

You may find this useful: https://aur.archlinux.org/packages/mkinitcpio-openswap/