# right fit swap for laptop hibernation Ubuntu 20.04 full ZFS install
2020-06-22 10:32:01 +02:00
## sources
* [rephlex.de - How to hibernate and resume from swap file in Ubuntu 20.04 using full disk encryption](https://rephlex.de/blog/2019/12/27/how-to-hibernate-and-resume-from-swap-file-in-ubuntu-20-04-using-full-disk-encryption/)
* [help.ubuntu.com - Enable Hibernate With Encrypted Swap](https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap#Preparation)
* [tlbdk.github.io - encrypted swap on Ubuntu 18.10](http://tlbdk.github.io/ubuntu/2018/10/22/encrypted-swap.html)
2020-06-22 10:42:05 +02:00
2020-06-22 10:30:18 +02:00
## bios setup
You have to disable secure boot in bios to permit Hibernate because of *kernel lockdown prevent hibernation* see links bellow :
2020-06-22 10:32:01 +02:00
* [stackexchange - Why does the kernel lockdown prevent hibernation?](https://unix.stackexchange.com/questions/591488/why-does-the-kernel-lockdown-prevent-hibernation)
2020-06-22 10:30:18 +02:00
2020-06-22 09:51:26 +02:00
## create swap partition to permit Hibernate
create a swap partition right sized for hibernation.
add theses 2 lines in : */usr/share/ubiquity/zsys-setup*
## configure hibernate to auto switch from sleep to hibernate
2020-06-22 10:25:22 +02:00
source : [Linux Mint Forums : Enable Hibernation with LUKS on LVM and extras](https://forums.linuxmint.com/viewtopic.php?t=287015)
2020-06-22 10:01:56 +02:00
edit : */etc/systemd/sleep.conf*
And add this value to it (The number represents seconds you want to pass in sleep, after which the computer will switch to hibernation, so you can put it in 60 seconds or something short just to check it's working and after that you can put whatever ammount of time you want):
~~~
[Sleep]
2020-06-22 10:44:35 +02:00
HibernateDelaySec=120
2020-06-22 10:01:56 +02:00
~~~
2020-06-22 10:30:18 +02:00
Modify this two lines in /etc/systemd/logind.conf for sleep key and closing the lid actions if that's how you want it: