# 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/)
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]
HibernateDelaySec=7200
~~~
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:
2020-06-22 10:01:56 +02:00
2020-06-22 10:30:18 +02:00
~~~
HandleSuspendKey=suspend-then-hibernate
HandleLidSwitch=suspend-then-hibernate
~~~
2020-06-22 10:01:56 +02:00
Hiberner au bout de x secondes après une mise en veille