Recently I have had the opportunity/necessity to use Windows for a bit. Windows, expecially with WSL (Windows Subsystem for Linux) is much better than it used to be. One thing that I really liked was "susped to hibernate".
When closing the lid on the laptop, the system would suspend, and then after some time it would power off. This is really nice behavior for someone who often comes to find a laptop they've suspended a couple days ago and that they have no power.
So... How to do that on linux? Specifically Ubuntu 22.04
To suspend-then-hibernate, there are 2 sticking points
-
Configuration of hibernate. There is good documentation on Arch wiki that is also relevant to Ubuntu. There is also an askubuntu post here that shows how to configure hibernation.
-
No secure-boot - At least on Ubuntu, you cannot hibernate while booted into secure-boot. This is unfortunate.
-
Configuration of suspend-then-hibernate on Lid close. I want this to work when I close the lid. I don't want to have to type 'sudo systemctl suspend-to-hibernate'. Unfortunately, I have not gotten this part to work yet. I'm not sure if gnome is causing issue here or not. You should be able to:
- edit
/etc/systemd/logind.conf
link - sudo systemctl kill --signal=HUP systemd-logind
- edit
Also you can tweak how long that waits before Hibernate by editing the HibernateDelaySec
setting in /etc/systemd/sleep.conf. [doc].
Hi Scott! What I did to configure suspend-then-hibernate when closing the laptop lid is to replace the suspend service by the suspend-then-hibernate one as follows:
cd /usr/lib/systemd/system sudo mv systemd-suspend.service systemd-suspend.service.backup sudo ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service systemd-suspend.service
Since by default Ubuntu 22.04 suspends when closing the lid, now it suspends-then-hibernates. It's a bit of a hack but it's good enough for me.