Setting up encrypted volumes with LUKS
LUKS allows encrypting a partition and mapping it as a virtual block device, which can then be used as a normal partition. Guides for other Linux distributions should serve as a general references for installing Alpine onto a LUKS encrypted disk.
The following approaches are known to work:
- Plain LUKS
- LVM on LUKS
The installer has built-in support for encryption. The default installer will not encrypt the swap partition and the boot partition. To setup Alpine Linux with an encrypted swap partition, refer to LVM on LUKS. The GRUB bootloader supports BIOS and EFI boot with an encrypted boot partition.
mkinitfs and LUKS
For those familiar with setting up FDE on other Linux distributions, this section contains only Alpine-specific knowledge required and understanding mkinitfs.
First of all, the cryptsetup
feature needs to be added to /etc/mkinitfs/mkinitfs.conf. Additionally, the following kernel parameters are required:
cryptroot
kernel parameter should point to the encrypted block device.cryptdm
: the name that will be given to the device.root
kernel parameter should point to the mapped block device:/dev/mapper/<name used in cryptdm>
.rootfstype
: the filesystem type of the root partition (e.g.:btrfs
).
For example, if you use grub with GPT partition table using ext4 without LVM the /etc/default/grub file will be as follows:
Contents of /etc/default/grub
Decrypting non-root volumes during boot
To have an encrypted non-root volume be decrypted prior to automatically mounting it somewhere via /etc/fstab
, configure dmcrypt
in the /etc/conf.d/dmcrypt file. The comments inside that file should guide you, but as a simple example, here's what you should include in that file to decrypt and map a partition to some volume named, say, “myvolume
”, given its UUID (here represented using a series of X
s), using a passphrase
Contents of /etc/conf.d/dmcrypt
In /etc/fstab file, then, you would include the following line as follows:
Contents of /etc/fstab
substituting in the proper parameters.