wiki-system/encrypt-swap-Ubuntu-20.04.md

104 lines
1.9 KiB
Markdown
Raw Normal View History

2020-06-23 06:35:36 +02:00
## encrypt swap partition
sources :
* [wiki.archlinux.org - dm-crypt/Swap encryption](https://wiki.archlinux.org/index.php/Dm-crypt/Swap_encryption#LVM_on_LUKS)
* [help.ubuntu.com - Enable Hibernate With Encrypted Swap](https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap)
~~~
apt-get install ecryptfs-utils
swapoff -a
cryptsetup luksFormat --cipher aes-xts-plain64 --verify-passphrase --key-size 256 /dev/nvme0n1p2
cryptsetup open /dev/<device> swapDevice
2020-06-23 06:59:24 +02:00
mkswap /dev/mapper/mkswap /dev/mapper/cryptswap
2020-06-23 06:35:36 +02:00
~~~
edit : /etc/default/grub
~~~
2020-06-23 06:59:24 +02:00
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUUUUUU"
2020-06-23 06:35:36 +02:00
~~~
~~~
update-grub
~~~
Now ajust /etc/fstab to use your mapper, replace your encrypt swap device like bellow :
~~~
2020-06-23 06:59:24 +02:00
/dev/mapper/cryptswap none swap discard 0 0
2020-06-23 06:35:36 +02:00
~~~
2020-06-23 06:59:24 +02:00
add your encrypt swap device define in /etc/crypttab
2020-06-23 06:35:36 +02:00
~~~
2020-06-23 06:59:24 +02:00
cryptswap /dev/nvme0n1p2 none luks
2020-06-23 06:35:36 +02:00
~~~
~~~
swapon -a
~~~
Register these changes.
~~~
update-initramfs -u -k all
~~~
## disable encrypt swap partition
* Turn off swap
~~~
swapoff /dev/mapper/cryptswap1
~~~
* remove your encrypt swap device define in your /etc/crypttab
* ajust /etc/fstab to use your real swap partition
~~~
/dev/nvme0n1p2 none swap discard 0 0
~~~
* Change your /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT to
~~~
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=/dev/nvme0n1p2"
~~~
2020-06-23 06:40:59 +02:00
~~~
update-grub
~~~
2020-06-23 06:35:36 +02:00
* edit /etc/initramfs-tools/conf.d/resume. Replace the existing RESUME line with the following line.
~~~
RESUME=/dev/nvme0n1p2
~~~
2020-06-23 06:40:59 +02:00
Register these changes.
~~~
update-initramfs -u -k all
~~~
2020-06-23 06:35:36 +02:00
* make your partition a swap
~~~
mkswap /dev/nvme0n1p2
~~~
* activate swap
~~~
swapon -a
~~~
2020-06-23 06:40:59 +02:00
2020-06-23 06:35:50 +02:00
## to be solve
2020-06-23 06:35:36 +02:00
~~~
cryptsetup: ERROR: Couln't resolve device rpool/ROOT/ubuntu_...
cryptsetup: WARNING: Couln't determine root device
~~~