Linuxでスワップパーティションを暗号化する
This content is a draft and will not be included in production builds.
LUKSで暗号化したスワップパーティションを利用する。スワップファイルでもいいが、スワップはパーティションとファイルどちらがいいのかで調べたところパーティションの方が無難そうだった。
mkinitcpio で busybox と systemd どちらのフックを使っているかで設定内容は異なるが、LUKS暗号化する場合は圧倒的に systemd フックの方が便利なので、ここではその前提でまとめる。
カーネルパラメータを追加
Section titled “カーネルパラメータを追加”スワップパーティションを /dev/mapper/cryptswap として参照するため、パーティションのUUIDをブートローダーの設定に加える。また、 resume= パラメータとして cryptswap のUUIDを追加する。
/boot/loader/entries/--- arch-old.conf 2022-10-24 10:55:46.000000000 +0900+++ arch.conf 2022-10-24 10:55:16.000000000 +0900@@ -2,4 +2,4 @@ linux /vmlinuz-linux initrd /intel-ucode.img initrd /initramfs-linux.img options luks.name=5dbdf837-6472-4944-932a-f3ce5071af2c=cryptroot+options luks.name=cd175a85-1be3-4ac7-bca0-19843cdae635=cryptswap options root=/dev/mapper/cryptroot rootflags=subvol=@ rw+options resume=UUID=dda4100b-7a5c-4cfe-8faf-7661f61dcbcf