How to get hibernation on the Librem 14 (and librem mini?)

After a long search, i did not find the solution in this forum and looked at other websites. Here is my compilation to get hibernation on the Librem 14 (tested on 2 devices), and probably on the Librem mini.

I can resume from hibernate in 16s with pureboot, and 10s with coreboot, with wifi autostart, so long because the resume starts with a normal boot and ends with resuming the session from swap. It is not so good as a resume on a mac or windows or deybian, but it is worth it. It really changed my UX of the Librem 14. In hibernation, I only loose, maybe, 2% in a day ! You really can forget it !

  • Create a swap partition (maybe the most “difficult’”:

    • with a live Pureos usb stick (you should have the last version or compatible to your pureos version), start with the live version.

    • go to creating a login and install gparted from terminal

    • with gparted, resize your main partition to free enough space for your swap

    • create a partition

    • format it to ‘other’>‘swap’ + parameters : starting point ‘none’, sw, swap

    • MAYBE : be careful. I you add here encryption to your swap, it can be boring afterwards : My Librem 14’s have encryption. But I do not need this at the moment, and overall i did not want to type my passphrase or have to use my librem key TWICE to resume from hibernation (as far as I know we could not even use the libremkey pin to decrypt the swap partition…), so I am now so happy using the shortest way without swap encryption.

    • reboot

  • start ‘disks’ to check your swap partition and get its UUID and its path

  • sudo swapon /dev/nvme0n1p3(replace with your own partition path) to activate the swap partition in your system

  • sudo gedit /etc/fstab : add a line : UUID=fdf4-ggfgf4dfdfxxxxxxxx none swap sw 0 (replace with your swap UUID)

  • sudo gedit /etc/default/grub : to inform grub about your swap partition, add this line or modify it :
    ‘GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash resume=UUID=fdf4-ggfgf4dfdfxxxxxxxx’ (replace with your swap UUID

    • here are some good parameters in that file, to boot fast:
      GRUB_DEFAULT=0
      GRUB_HIDDEN_TIMEOUT=0
      GRUB_HIDDEN_TIMEOUT_QUIET=true
      GRUB_TIMEOUT=5
      GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian
      GRUB_CMDLINE_LINUX_DEFAULT=“quiet nosplash resume=UUID=af40fa1f-e5af-4c8d-a361-f4f0a3b2aed8”
      GRUB_CMDLINE_LINUX=“”
  • sudo gedit /etc/initramfs-tools/conf.d/resume : create this file and add :
    RESUME=UUID=fdf4-ggfgf4dfdfxxxxxxxx (replace with your swap UUID

  • sudo gedit /etc/UPower/UPower.conf, replace HybridSleep at the end of the file like that :
    CriticalPowerAction=Hibernate

    • Here your can change other power settings.
  • sudo update-initramfs -u -k all to update your kernels

  • sudo update-grub to update your boot with grub

  • change in power settings the action of the power button to trigger hibernate (should appear after you swapon)

  • test

  • with dconf (install it if needed),

    • to get autoosleep after 5 minutes, and not only 15 in default settings, just change org.freedesktop.Tracker.Miner.Files initial-sleep = 5
    • if you want auto hibernate instead of auto sleep, just set the ‘sleep-inactive-battery-type’ to ‘hibernate’

Enjoy !

3 Likes

For encrypted swap partition, you have to:

  • get the UUIDs of your swap partition (the “luks” encrypted one and the unencrypted one) with the ‘Disks’ app or sudo blkid

  • sudo nano /etc/default/grub:

    • add the ENCRYPTED UUID instead of the unencrypted one, so that grub at boot finds the encrypted swap partition to resume from suspend.
  • sudo nano /etc/crypttab

    • add the ENCRYPTED swap partition id like: <yourname> luks-<yourencryptedUUID> none luks or <yourname> UUID=<yourencryptedUUID> none luks or <yourname> UUID=<yourencryptedUUID> none luks or <yourname> /dev/mapper/nvme.... none luks, so that pureos opens the encrypted swap partition and give it a name.
  • sudo nano /etc/fstab

    • add the unencrypted UUID like before. So that pureos can use it as a swap partition
  • sudo nano /etc/initramfs-tools/conf.d/resume

    • add the address /dev/… or UUID= of the unencrypted partition, sot that it works.

You will have to give your passphrase at boot and resume for this swap partition just after the passphrase for the normal partition, so twice. Maybe you can tell the system to read the swap passphrase in the main partition but I do not know how to do that.

1 Like

You may want to complete your post first.

Just done. Thanks for the reminder.

1 Like

To get suspend-then-hibernate function:
sudo nano /etc/systemd/sleep.conf
Config example (hibernate after 60min of sleep):

[Sleep]
AllowSuspend=yes
AllowHibernation=yes
AllowSuspendThenHibernate=yes
AllowHybridSleep=yes
#SuspendMode=
#SuspendState=mem standby freeze
#HibernateMode=platform shutdown
HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
HibernateDelaySec=60min

1 Like

ERRATA in my last post How to get hibernation on the Librem 14 (and librem mini?) - #2 by Lionel :
The grub file needs the UNencrypted UUID, otherwise it does not work at all.
Sorry.

1 Like

Since last updates, I don’t know which one, suspend-then-hibernate is not working any more.

sudo systemctl suspend-then-hibernate
works.
but, after entering in suspend, hibernate is not happening.

I found a workaround on a forum, just run:
sudo ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service

1 Like