<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Coolman</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Coolman"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Coolman"/>
	<updated>2026-05-10T05:55:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Hardened_malloc&amp;diff=28847</id>
		<title>Hardened malloc</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Hardened_malloc&amp;diff=28847"/>
		<updated>2025-01-16T19:26:43Z</updated>

		<summary type="html">&lt;p&gt;Coolman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== What is it? ===&lt;br /&gt;
An excerpt on [https://github.com/GrapheneOS/hardened_malloc github] [1]:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This is a security-focused general purpose memory allocator providing the malloc API along with various extensions. It provides substantial hardening against heap corruption vulnerabilities.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== How to use ===&lt;br /&gt;
{{note| Need Alpine Linux Edge with testing repo in &amp;lt;code&amp;gt;/etc/apk/repositories&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{cmd| $ doas apk add hardened-malloc}}&lt;br /&gt;
&lt;br /&gt;
Then you can set &amp;lt;code&amp;gt;LD_PRELOAD=&amp;quot;/usr/lib/libhardened_malloc.so&amp;quot;&amp;lt;/code&amp;gt; while launching individual applications or before your window manager starts if you prefer.  For a more global setting placing the LD_PRELOAD reference into &amp;lt;code&amp;gt;/etc/profile&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;/etc/profile.d/&amp;lt;/code&amp;gt; might help, as well as &amp;lt;code&amp;gt;/etc/environment&amp;lt;/code&amp;gt; for PAM-based systems.&lt;br /&gt;
&lt;br /&gt;
=== External sources ===&lt;br /&gt;
Hardened malloc github&lt;br /&gt;
* [https://github.com/GrapheneOS/hardened_malloc https://github.com/GrapheneOS/hardened_malloc] [1]&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Coolman</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Hardened_malloc&amp;diff=28846</id>
		<title>Hardened malloc</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Hardened_malloc&amp;diff=28846"/>
		<updated>2025-01-16T19:26:27Z</updated>

		<summary type="html">&lt;p&gt;Coolman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== What is it? ===&lt;br /&gt;
An excerpt on [https://github.com/GrapheneOS/hardened_malloc github] [1]:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This is a security-focused general purpose memory allocator providing the malloc API along with various extensions. It provides substantial hardening against heap corruption vulnerabilities.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== How to use ===&lt;br /&gt;
{{note| Need Alpine Linux Edge with testing repo in &amp;lt;code&amp;gt;/etc/apk/repositories&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{cmd| $ doas apk add hardened-malloc}}&lt;br /&gt;
&lt;br /&gt;
Then you can set &amp;lt;code&amp;gt;LD_PRELOAD=&amp;quot;/usr/lib/libhardened_malloc.so&amp;quot;&amp;lt;/code&amp;gt; while launching individual applications or before your window manager starts if you prefer.  For a more global setting placing the LD_PRELOAD reference into &amp;lt;code&amp;gt;/etc/profile&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;/etc/profile.d/&amp;lt;/code&amp;gt; might help, as well as /etc/environment for PAM-based systems.&lt;br /&gt;
&lt;br /&gt;
=== External sources ===&lt;br /&gt;
Hardened malloc github&lt;br /&gt;
* [https://github.com/GrapheneOS/hardened_malloc https://github.com/GrapheneOS/hardened_malloc] [1]&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Coolman</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Hardened_malloc&amp;diff=28845</id>
		<title>Hardened malloc</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Hardened_malloc&amp;diff=28845"/>
		<updated>2025-01-16T19:25:58Z</updated>

		<summary type="html">&lt;p&gt;Coolman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== What is it? ===&lt;br /&gt;
An excerpt on [https://github.com/GrapheneOS/hardened_malloc github] [1]:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This is a security-focused general purpose memory allocator providing the malloc API along with various extensions. It provides substantial hardening against heap corruption vulnerabilities.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== How to use ===&lt;br /&gt;
{{note| Need Alpine Linux Edge with testing repo in &amp;lt;code&amp;gt;/etc/apk/repositories&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{cmd| $ doas apk add hardened-malloc}}&lt;br /&gt;
&lt;br /&gt;
Then you can set &amp;lt;code&amp;gt;LD_PRELOAD=&amp;quot;/usr/lib/libhardened_malloc.so&amp;quot;&amp;lt;/code&amp;gt; while launching individual applications or before your window manager starts if you prefer.  For a more global setting placing the LD_PRELOAD reference into /etc/profile or /etc/profile.d/ might help, as well as /etc/environment for PAM-based systems.&lt;br /&gt;
&lt;br /&gt;
=== External sources ===&lt;br /&gt;
Hardened malloc github&lt;br /&gt;
* [https://github.com/GrapheneOS/hardened_malloc https://github.com/GrapheneOS/hardened_malloc] [1]&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Coolman</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Hardened_malloc&amp;diff=28844</id>
		<title>Hardened malloc</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Hardened_malloc&amp;diff=28844"/>
		<updated>2025-01-16T19:16:24Z</updated>

		<summary type="html">&lt;p&gt;Coolman: /etc/ld.so.preload is a glibc thing, not going to work on Alpine&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== What is it? ===&lt;br /&gt;
An excerpt on [https://github.com/GrapheneOS/hardened_malloc github] [1]:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This is a security-focused general purpose memory allocator providing the malloc API along with various extensions. It provides substantial hardening against heap corruption vulnerabilities.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== How to use ===&lt;br /&gt;
{{note| Need Alpine Linux Edge with testing repo in &amp;lt;code&amp;gt;/etc/apk/repositories&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{cmd| $ doas apk add hardened-malloc}}&lt;br /&gt;
&lt;br /&gt;
Then you can set &amp;lt;code&amp;gt;LD_PRELOAD=&amp;quot;/usr/lib/libhardened_malloc.so&amp;quot;&amp;lt;/code&amp;gt; while launching individual applications or before your window manager starts if you prefer.&lt;br /&gt;
&lt;br /&gt;
=== External sources ===&lt;br /&gt;
Hardened malloc github&lt;br /&gt;
* [https://github.com/GrapheneOS/hardened_malloc https://github.com/GrapheneOS/hardened_malloc] [1]&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Coolman</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25882</id>
		<title>Full disk encryption secure boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25882"/>
		<updated>2023-12-18T21:50:04Z</updated>

		<summary type="html">&lt;p&gt;Coolman: /* Configuring LUKS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Disclaimer : this is not to be followed, only for testing purposes. This will be updated when GRUB 2.12 rc1 will be available for LUKSv2, GRUB and FDE to work&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
This guide is to explain, step-by-step, how to setup Alpine Linux with Full Disk Encryption using LUKS2, LVM (one Physical Volume Partition with three Logical Volume Partitions (/ /boot &amp;amp; swap) with hibernation on a NVMe drive, with UEFI &amp;amp; Secure Boot. This guide has been written using Alpine Linux Std 3.16.1, please adapt some commands if needed.&lt;br /&gt;
&lt;br /&gt;
The goal of this guide is to follow the KISS principle, but another file system can be used, multiple partitions for /home; /var/log etc.. can also be added, if the proposed configuration is not meeting your requirements.&lt;br /&gt;
&lt;br /&gt;
= Installing packages =&lt;br /&gt;
&lt;br /&gt;
To facilitate the partitioning we will use gdisk :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lsblk gptfdisk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For encryption, we will use cryptsetup :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add cryptsetup&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For LVM:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lvm2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For using and managing UEFI, multiple packages are needed :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efibootmgr e2fsprogs grub grub-efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Preparing / overwriting the disk =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add haveged&amp;lt;/pre&amp;gt;&lt;br /&gt;
This can take long, on my side for a 500GB nVME it tooks ~30 minutes.&lt;br /&gt;
&amp;lt;pre&amp;gt;# haveged -n 0 | dd of=/dev/nvme0n1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Partitioning the disk =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s assume the disk is /dev/nvme0n1 and no partition is present, we will create two partitions :&lt;br /&gt;
 &lt;br /&gt;
* one for UEFI&lt;br /&gt;
* one for LVM&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; # gdisk /dev/nvme0n1&lt;br /&gt;
GPT fdisk (gdisk) version 1.0.9.1&lt;br /&gt;
&lt;br /&gt;
Partition table scan:&lt;br /&gt;
  MBR: not present&lt;br /&gt;
  BSD: not present&lt;br /&gt;
  APM: not present&lt;br /&gt;
  GPT: not present&lt;br /&gt;
&lt;br /&gt;
Creating new GPT entries in memory.&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (1-128, default 1): &lt;br /&gt;
First sector (34-1000215182, default = 2048) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (2048-1000215182, default = 1000214527) or {+-}size{KMGTP}: 512M&lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): ef00&lt;br /&gt;
Changed type of partition to &#039;EFI system partition&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (2-128, default 2): &lt;br /&gt;
First sector (34-1000215182, default = 1050624) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (1050624-1000215182, default = 1000214527) or {+-}size{KMGTP}: &lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): 8309&lt;br /&gt;
Changed type of partition to &#039;Linux LUKS&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): w&lt;br /&gt;
&lt;br /&gt;
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING&lt;br /&gt;
PARTITIONS!!&lt;br /&gt;
&lt;br /&gt;
Do you want to proceed? (Y/N): Y&lt;br /&gt;
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.&lt;br /&gt;
The operation has completed successfully.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Populate /dev with the new partitions&lt;br /&gt;
&amp;lt;pre&amp;gt; # partprobe /dev/nvme0n1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring LUKS =&lt;br /&gt;
&lt;br /&gt;
Using luks2 (unsupported by GRUB at the moment):&lt;br /&gt;
&amp;lt;pre&amp;gt;# cryptsetup -v -c aes-xts-plain64 -s 512 --hash sha512 --pbkdf pbkdf2 --iter-time 1000 --use-random luksFormat /dev/nvme0n1p2&amp;lt;/pre&amp;gt;&lt;br /&gt;
Using luks1:&lt;br /&gt;
&amp;lt;pre&amp;gt;# cryptsetup -v -c aes-xts-plain64 -s 512 --hash sha512 --iter-time 1000 --use-urandom --type luks1 luksFormat /dev/nvme0n1p2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WARNING!&lt;br /&gt;
========&lt;br /&gt;
This will overwrite data on /dev/nvme0n1p2 irrevocably.&lt;br /&gt;
&lt;br /&gt;
Are you sure? (Type &#039;yes&#039; in capital letters): YES&lt;br /&gt;
Enter passphrase for /dev/nvme0n1p2: &lt;br /&gt;
Verify passphrase: &lt;br /&gt;
Key slot 0 created.&lt;br /&gt;
Command successful.&lt;br /&gt;
&lt;br /&gt;
# cryptsetup luksOpen /dev/nvme0n1p2 lvmcrypt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= LVM : Physical &amp;amp; Logical Volumes creation =&lt;br /&gt;
&amp;lt;pre&amp;gt;# pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
  Physical volume &amp;quot;/dev/mapper/lvmcrypt&amp;quot; successfully created.&lt;br /&gt;
# vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
  Volume group &amp;quot;vg0&amp;quot; successfully created&lt;br /&gt;
# lvcreate -L 20G vg0 -n swap (I have a 16GB RAM laptop)&lt;br /&gt;
  Logical volume &amp;quot;swap&amp;quot; created.&lt;br /&gt;
# lvcreate -l 100%FREE vg0 -n root&lt;br /&gt;
  Logical volume &amp;quot;root&amp;quot; created.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check the creation :&lt;br /&gt;
&amp;lt;pre&amp;gt;# lvscan&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/swap&#039; [20.00 GiB] inherit&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/root&#039; [455.92 GiB] inherit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Mounting points and File System =&lt;br /&gt;
&lt;br /&gt;
Create vfat file system for UEFI partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.vfat /dev/nvme0n1p1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ext4 file system for / partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.ext4 /dev/vg0/root&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activate SWAP:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkswap /dev/vg0/swap&lt;br /&gt;
# swapon /dev/vg0/swap&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount / partition to /mnt :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t ext4 /dev/vg0/root /mnt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /boot/efi:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /mnt/boot/efi -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount UEFI partition to /mnt/boot/efi :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t vfat /dev/nvme0n1p1 /mnt/boot/efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk&lt;br /&gt;
nvme0n1        259:0    0 476.9G  0 disk  &lt;br /&gt;
├─nvme0n1p1    259:1    0   511M  0 part  /mnt/boot/efi&lt;br /&gt;
└─nvme0n1p2    259:2    0 476.4G  0 part  &lt;br /&gt;
  └─lvmcrypt   253:0    0 476.4G  0 crypt &lt;br /&gt;
    ├─vg0-swap 253:1    0    20G  0 lvm   [SWAP]&lt;br /&gt;
    └─vg0-root 253:2    0 456.4G  0 lvm   /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Alpine =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# setup-disk -m sys /mnt/&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mkinitfs settings &amp;amp; modules =&lt;br /&gt;
Edit the /mnt/etc/mkinitfs/mkinitfs.conf file and append the modules to the features parameters (keymap only needed if your keyboard is not QWERTY):&lt;br /&gt;
&amp;lt;pre&amp;gt;features=&amp;quot;ata base ide scsi usb virtio ext4 lvm nvme keymap cryptsetup cryptkey resume&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Regenerate the initram:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkinitfs -c /mnt/etc/mkinitfs/mkinitfs.conf -b /mnt/ $(ls /mnt/lib/modules/)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Grub settings =&lt;br /&gt;
&lt;br /&gt;
Create a crypto_keyfile.bin to avoid typing the passphrase twice during the boot process (one for Grub partition, one for Alpine partition):&lt;br /&gt;
&amp;lt;pre&amp;gt;# touch /mnt/crypto_keyfile.bin&lt;br /&gt;
# chmod 600 /mnt/crypto_keyfile.bin&lt;br /&gt;
# dd if=/dev/random bs=512 count=4 | xxd -p -c999 | tr -d &#039;\n&#039; &amp;gt; /mnt/crypto_keyfile.bin&lt;br /&gt;
# cryptsetup luksAddKey /dev/nvme0n1p2 /mnt/crypto_keyfile.bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, let&#039;s mount and chroot to our fresh installation:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t proc /proc /mnt/proc&lt;br /&gt;
# mount --rbind /dev /mnt/dev&lt;br /&gt;
# mount --make-rslave /mnt/dev&lt;br /&gt;
# mount --rbind /sys /mnt/sys&lt;br /&gt;
# chroot /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/default/grub and add cryptkey after cryptdm=root parameter like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_TIMEOUT=2&lt;br /&gt;
GRUB_DISABLE_SUBMENU=y&lt;br /&gt;
GRUB_DISABLE_RECOVERY=true&lt;br /&gt;
GRUB_CMDLINE_LINUX_DEFAULT=&amp;quot;modules=sd-mod,usb-storage,ext4,nvme cryptroot=UUID=XXXX cryptdm=lvmcrypt cryptkey quiet rootfstype=ext4&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
XXXX could be found with blkid command&lt;br /&gt;
&lt;br /&gt;
Add a new GRUB_PRELOAD_MODULES line like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_PRELOAD_MODULES=&amp;quot;luks cryptodisk part_gpt lvm&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, add the cryptodisk parameter :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_ENABLE_CRYPTODISK=y&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let&#039;s show the UUID of our partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a /root/grub-pre.cfg and replace &amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt; with your encrypted lvm partition UUID (here /dev/nvme0n1p2) without hyphens, replace &amp;lt;YYYY&amp;gt; with VG UUID from vgdisplay and replace &amp;lt;ZZZZ&amp;gt; with LV UUID from lvdisplay of your /dev/vg0/root&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set crypto_uuid=&amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt;&lt;br /&gt;
cryptomount -u $crypto_uuid&lt;br /&gt;
set root=&#039;lvmid/&amp;lt;YYYY&amp;gt;/&amp;lt;ZZZZ&amp;gt;&#039;&lt;br /&gt;
set prefix=($root)/boot/grub&lt;br /&gt;
insmod normal&lt;br /&gt;
normal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring Secure Boot =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efi-mkkeys efibootmgr sbsigntool&lt;br /&gt;
# efi-mkkeys -s &amp;quot;Your Name&amp;quot; -o /etc/uefi-keys&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-install Grub:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /boot/efi/EFI/AlpineLinuxSecureBoot&lt;br /&gt;
# grub-mkimage -p /boot/grub -O x86_64-efi -c /root/grub-pre.cfg -o /tmp/grubx64.efi luks2 part_gpt cryptodisk lvm ext2 gcry_rijndael pbkdf2 gcry_sha512&lt;br /&gt;
# install -v /tmp/grubx64.efi /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sed -i &#039;s/SecureBoot/SecureB00t/&#039; /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi&lt;br /&gt;
# cd /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sbsign --key /etc/uefi-keys/db.key --cert /etc/uefi-keys/db.crt --output grubx64.efi.signed grubx64.efi&lt;br /&gt;
# grub-mkconfig -o /boot/grub/grub.cfg&lt;br /&gt;
# efibootmgr --disk /dev/nvme0n1p1 --part 1 --create --label &#039;Alpine Linux Secure Boot Signed&#039; --load /EFI/AlpineLinuxSecureBoot/grubx64.efi.signed --verbose&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check that your .efi is signed :&lt;br /&gt;
&amp;lt;pre&amp;gt; # sbverify --cert /etc/uefi-keys/db.crt /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed &lt;br /&gt;
Signature verification OK&lt;br /&gt;
# sbverify --list /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed&lt;br /&gt;
signature 1&lt;br /&gt;
image signature issuers:&lt;br /&gt;
 - /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
image signature certificates:&lt;br /&gt;
 - subject: /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
   issuer:  /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy db.auth, KEK.auth and PK.auth files from /etc/uefi-keys to a FAT formatted file system.&lt;br /&gt;
&lt;br /&gt;
Reboot &amp;amp; enter into your UEFI (Fx key depending of your laptop)&lt;br /&gt;
&lt;br /&gt;
== Import keys to UEFI ==&lt;br /&gt;
&lt;br /&gt;
This is just an example from an XPS laptop, each UEFI is unique.&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;&#039;Boot Configuration&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;Secure Boot&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Secure Boot&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Secure Boot Mode&#039;&#039;&#039; to &#039;&#039;&#039;Deployed Mode&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Custom Mode&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Go to &#039;&#039;&#039;Custom Mode Key Management&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Reset All Keys&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;db&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;db.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;KEK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;KEK.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;PK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;PK.auth&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;APPLY CHANGES&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;EXIT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check Secure Boot State:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add mokutil&lt;br /&gt;
# mokutil --sb-state&lt;br /&gt;
SecureBoot enabled&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Congrats!&lt;br /&gt;
&lt;br /&gt;
== Hibernate on encrypted LVM swap partition ==&lt;br /&gt;
&lt;br /&gt;
Find your vg0-swap UUID :&lt;br /&gt;
&amp;lt;pre&amp;gt;lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add resume parameter to your /etc/default/grub :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_CMDLINE_LINUX_DEFAULT=....resume=UUID=&amp;lt;UUID of your vg0-swap partition&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a line to your /etc/fstab :&lt;br /&gt;
&amp;lt;pre&amp;gt;/dev/vg0/swap   none            swap     sw    0 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable swap service during boot :&lt;br /&gt;
&amp;lt;pre&amp;gt;rc-update add swap default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install zzz and test it&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add zzz&lt;br /&gt;
zzz- Z&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Done and congrats !&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Coolman</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25881</id>
		<title>Full disk encryption secure boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25881"/>
		<updated>2023-12-18T20:24:55Z</updated>

		<summary type="html">&lt;p&gt;Coolman: /* Configuring LUKS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Disclaimer : this is not to be followed, only for testing purposes. This will be updated when GRUB 2.12 rc1 will be available for LUKSv2, GRUB and FDE to work&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
This guide is to explain, step-by-step, how to setup Alpine Linux with Full Disk Encryption using LUKS2, LVM (one Physical Volume Partition with three Logical Volume Partitions (/ /boot &amp;amp; swap) with hibernation on a NVMe drive, with UEFI &amp;amp; Secure Boot. This guide has been written using Alpine Linux Std 3.16.1, please adapt some commands if needed.&lt;br /&gt;
&lt;br /&gt;
The goal of this guide is to follow the KISS principle, but another file system can be used, multiple partitions for /home; /var/log etc.. can also be added, if the proposed configuration is not meeting your requirements.&lt;br /&gt;
&lt;br /&gt;
= Installing packages =&lt;br /&gt;
&lt;br /&gt;
To facilitate the partitioning we will use gdisk :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lsblk gptfdisk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For encryption, we will use cryptsetup :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add cryptsetup&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For LVM:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lvm2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For using and managing UEFI, multiple packages are needed :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efibootmgr e2fsprogs grub grub-efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Preparing / overwriting the disk =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add haveged&amp;lt;/pre&amp;gt;&lt;br /&gt;
This can take long, on my side for a 500GB nVME it tooks ~30 minutes.&lt;br /&gt;
&amp;lt;pre&amp;gt;# haveged -n 0 | dd of=/dev/nvme0n1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Partitioning the disk =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s assume the disk is /dev/nvme0n1 and no partition is present, we will create two partitions :&lt;br /&gt;
 &lt;br /&gt;
* one for UEFI&lt;br /&gt;
* one for LVM&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; # gdisk /dev/nvme0n1&lt;br /&gt;
GPT fdisk (gdisk) version 1.0.9.1&lt;br /&gt;
&lt;br /&gt;
Partition table scan:&lt;br /&gt;
  MBR: not present&lt;br /&gt;
  BSD: not present&lt;br /&gt;
  APM: not present&lt;br /&gt;
  GPT: not present&lt;br /&gt;
&lt;br /&gt;
Creating new GPT entries in memory.&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (1-128, default 1): &lt;br /&gt;
First sector (34-1000215182, default = 2048) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (2048-1000215182, default = 1000214527) or {+-}size{KMGTP}: 512M&lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): ef00&lt;br /&gt;
Changed type of partition to &#039;EFI system partition&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (2-128, default 2): &lt;br /&gt;
First sector (34-1000215182, default = 1050624) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (1050624-1000215182, default = 1000214527) or {+-}size{KMGTP}: &lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): 8309&lt;br /&gt;
Changed type of partition to &#039;Linux LUKS&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): w&lt;br /&gt;
&lt;br /&gt;
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING&lt;br /&gt;
PARTITIONS!!&lt;br /&gt;
&lt;br /&gt;
Do you want to proceed? (Y/N): Y&lt;br /&gt;
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.&lt;br /&gt;
The operation has completed successfully.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Populate /dev with the new partitions&lt;br /&gt;
&amp;lt;pre&amp;gt; # partprobe /dev/nvme0n1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring LUKS =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# cryptsetup -v -c aes-xts-plain64 -s 512 --hash sha512 --pbkdf pbkdf2 --iter-time 1000 --use-random luksFormat /dev/nvme0n1p2&lt;br /&gt;
&lt;br /&gt;
WARNING!&lt;br /&gt;
========&lt;br /&gt;
This will overwrite data on /dev/nvme0n1p2 irrevocably.&lt;br /&gt;
&lt;br /&gt;
Are you sure? (Type &#039;yes&#039; in capital letters): YES&lt;br /&gt;
Enter passphrase for /dev/nvme0n1p2: &lt;br /&gt;
Verify passphrase: &lt;br /&gt;
Key slot 0 created.&lt;br /&gt;
Command successful.&lt;br /&gt;
&lt;br /&gt;
# cryptsetup luksOpen /dev/nvme0n1p2 lvmcrypt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
= LVM : Physical &amp;amp; Logical Volumes creation =&lt;br /&gt;
&amp;lt;pre&amp;gt;# pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
  Physical volume &amp;quot;/dev/mapper/lvmcrypt&amp;quot; successfully created.&lt;br /&gt;
# vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
  Volume group &amp;quot;vg0&amp;quot; successfully created&lt;br /&gt;
# lvcreate -L 20G vg0 -n swap (I have a 16GB RAM laptop)&lt;br /&gt;
  Logical volume &amp;quot;swap&amp;quot; created.&lt;br /&gt;
# lvcreate -l 100%FREE vg0 -n root&lt;br /&gt;
  Logical volume &amp;quot;root&amp;quot; created.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check the creation :&lt;br /&gt;
&amp;lt;pre&amp;gt;# lvscan&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/swap&#039; [20.00 GiB] inherit&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/root&#039; [455.92 GiB] inherit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Mounting points and File System =&lt;br /&gt;
&lt;br /&gt;
Create vfat file system for UEFI partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.vfat /dev/nvme0n1p1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ext4 file system for / partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.ext4 /dev/vg0/root&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activate SWAP:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkswap /dev/vg0/swap&lt;br /&gt;
# swapon /dev/vg0/swap&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount / partition to /mnt :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t ext4 /dev/vg0/root /mnt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /boot/efi:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /mnt/boot/efi -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount UEFI partition to /mnt/boot/efi :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t vfat /dev/nvme0n1p1 /mnt/boot/efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk&lt;br /&gt;
nvme0n1        259:0    0 476.9G  0 disk  &lt;br /&gt;
├─nvme0n1p1    259:1    0   511M  0 part  /mnt/boot/efi&lt;br /&gt;
└─nvme0n1p2    259:2    0 476.4G  0 part  &lt;br /&gt;
  └─lvmcrypt   253:0    0 476.4G  0 crypt &lt;br /&gt;
    ├─vg0-swap 253:1    0    20G  0 lvm   [SWAP]&lt;br /&gt;
    └─vg0-root 253:2    0 456.4G  0 lvm   /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Alpine =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# setup-disk -m sys /mnt/&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mkinitfs settings &amp;amp; modules =&lt;br /&gt;
Edit the /mnt/etc/mkinitfs/mkinitfs.conf file and append the modules to the features parameters (keymap only needed if your keyboard is not QWERTY):&lt;br /&gt;
&amp;lt;pre&amp;gt;features=&amp;quot;ata base ide scsi usb virtio ext4 lvm nvme keymap cryptsetup cryptkey resume&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Regenerate the initram:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkinitfs -c /mnt/etc/mkinitfs/mkinitfs.conf -b /mnt/ $(ls /mnt/lib/modules/)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Grub settings =&lt;br /&gt;
&lt;br /&gt;
Create a crypto_keyfile.bin to avoid typing the passphrase twice during the boot process (one for Grub partition, one for Alpine partition):&lt;br /&gt;
&amp;lt;pre&amp;gt;# touch /mnt/crypto_keyfile.bin&lt;br /&gt;
# chmod 600 /mnt/crypto_keyfile.bin&lt;br /&gt;
# dd if=/dev/random bs=512 count=4 | xxd -p -c999 | tr -d &#039;\n&#039; &amp;gt; /mnt/crypto_keyfile.bin&lt;br /&gt;
# cryptsetup luksAddKey /dev/nvme0n1p2 /mnt/crypto_keyfile.bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, let&#039;s mount and chroot to our fresh installation:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t proc /proc /mnt/proc&lt;br /&gt;
# mount --rbind /dev /mnt/dev&lt;br /&gt;
# mount --make-rslave /mnt/dev&lt;br /&gt;
# mount --rbind /sys /mnt/sys&lt;br /&gt;
# chroot /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/default/grub and add cryptkey after cryptdm=root parameter like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_TIMEOUT=2&lt;br /&gt;
GRUB_DISABLE_SUBMENU=y&lt;br /&gt;
GRUB_DISABLE_RECOVERY=true&lt;br /&gt;
GRUB_CMDLINE_LINUX_DEFAULT=&amp;quot;modules=sd-mod,usb-storage,ext4,nvme cryptroot=UUID=XXXX cryptdm=lvmcrypt cryptkey quiet rootfstype=ext4&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
XXXX could be found with blkid command&lt;br /&gt;
&lt;br /&gt;
Add a new GRUB_PRELOAD_MODULES line like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_PRELOAD_MODULES=&amp;quot;luks cryptodisk part_gpt lvm&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, add the cryptodisk parameter :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_ENABLE_CRYPTODISK=y&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let&#039;s show the UUID of our partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a /root/grub-pre.cfg and replace &amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt; with your encrypted lvm partition UUID (here /dev/nvme0n1p2) without hyphens, replace &amp;lt;YYYY&amp;gt; with VG UUID from vgdisplay and replace &amp;lt;ZZZZ&amp;gt; with LV UUID from lvdisplay of your /dev/vg0/root&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set crypto_uuid=&amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt;&lt;br /&gt;
cryptomount -u $crypto_uuid&lt;br /&gt;
set root=&#039;lvmid/&amp;lt;YYYY&amp;gt;/&amp;lt;ZZZZ&amp;gt;&#039;&lt;br /&gt;
set prefix=($root)/boot/grub&lt;br /&gt;
insmod normal&lt;br /&gt;
normal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring Secure Boot =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efi-mkkeys efibootmgr sbsigntool&lt;br /&gt;
# efi-mkkeys -s &amp;quot;Your Name&amp;quot; -o /etc/uefi-keys&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-install Grub:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /boot/efi/EFI/AlpineLinuxSecureBoot&lt;br /&gt;
# grub-mkimage -p /boot/grub -O x86_64-efi -c /root/grub-pre.cfg -o /tmp/grubx64.efi luks2 part_gpt cryptodisk lvm ext2 gcry_rijndael pbkdf2 gcry_sha512&lt;br /&gt;
# install -v /tmp/grubx64.efi /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sed -i &#039;s/SecureBoot/SecureB00t/&#039; /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi&lt;br /&gt;
# cd /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sbsign --key /etc/uefi-keys/db.key --cert /etc/uefi-keys/db.crt --output grubx64.efi.signed grubx64.efi&lt;br /&gt;
# grub-mkconfig -o /boot/grub/grub.cfg&lt;br /&gt;
# efibootmgr --disk /dev/nvme0n1p1 --part 1 --create --label &#039;Alpine Linux Secure Boot Signed&#039; --load /EFI/AlpineLinuxSecureBoot/grubx64.efi.signed --verbose&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check that your .efi is signed :&lt;br /&gt;
&amp;lt;pre&amp;gt; # sbverify --cert /etc/uefi-keys/db.crt /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed &lt;br /&gt;
Signature verification OK&lt;br /&gt;
# sbverify --list /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed&lt;br /&gt;
signature 1&lt;br /&gt;
image signature issuers:&lt;br /&gt;
 - /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
image signature certificates:&lt;br /&gt;
 - subject: /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
   issuer:  /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy db.auth, KEK.auth and PK.auth files from /etc/uefi-keys to a FAT formatted file system.&lt;br /&gt;
&lt;br /&gt;
Reboot &amp;amp; enter into your UEFI (Fx key depending of your laptop)&lt;br /&gt;
&lt;br /&gt;
== Import keys to UEFI ==&lt;br /&gt;
&lt;br /&gt;
This is just an example from an XPS laptop, each UEFI is unique.&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;&#039;Boot Configuration&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;Secure Boot&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Secure Boot&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Secure Boot Mode&#039;&#039;&#039; to &#039;&#039;&#039;Deployed Mode&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Custom Mode&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Go to &#039;&#039;&#039;Custom Mode Key Management&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Reset All Keys&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;db&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;db.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;KEK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;KEK.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;PK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;PK.auth&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;APPLY CHANGES&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;EXIT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check Secure Boot State:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add mokutil&lt;br /&gt;
# mokutil --sb-state&lt;br /&gt;
SecureBoot enabled&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Congrats!&lt;br /&gt;
&lt;br /&gt;
== Hibernate on encrypted LVM swap partition ==&lt;br /&gt;
&lt;br /&gt;
Find your vg0-swap UUID :&lt;br /&gt;
&amp;lt;pre&amp;gt;lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add resume parameter to your /etc/default/grub :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_CMDLINE_LINUX_DEFAULT=....resume=UUID=&amp;lt;UUID of your vg0-swap partition&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a line to your /etc/fstab :&lt;br /&gt;
&amp;lt;pre&amp;gt;/dev/vg0/swap   none            swap     sw    0 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable swap service during boot :&lt;br /&gt;
&amp;lt;pre&amp;gt;rc-update add swap default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install zzz and test it&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add zzz&lt;br /&gt;
zzz- Z&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Done and congrats !&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Coolman</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25880</id>
		<title>Full disk encryption secure boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25880"/>
		<updated>2023-12-18T20:24:10Z</updated>

		<summary type="html">&lt;p&gt;Coolman: /* Configuring LUKS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Disclaimer : this is not to be followed, only for testing purposes. This will be updated when GRUB 2.12 rc1 will be available for LUKSv2, GRUB and FDE to work&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
This guide is to explain, step-by-step, how to setup Alpine Linux with Full Disk Encryption using LUKS2, LVM (one Physical Volume Partition with three Logical Volume Partitions (/ /boot &amp;amp; swap) with hibernation on a NVMe drive, with UEFI &amp;amp; Secure Boot. This guide has been written using Alpine Linux Std 3.16.1, please adapt some commands if needed.&lt;br /&gt;
&lt;br /&gt;
The goal of this guide is to follow the KISS principle, but another file system can be used, multiple partitions for /home; /var/log etc.. can also be added, if the proposed configuration is not meeting your requirements.&lt;br /&gt;
&lt;br /&gt;
= Installing packages =&lt;br /&gt;
&lt;br /&gt;
To facilitate the partitioning we will use gdisk :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lsblk gptfdisk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For encryption, we will use cryptsetup :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add cryptsetup&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For LVM:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lvm2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For using and managing UEFI, multiple packages are needed :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efibootmgr e2fsprogs grub grub-efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Preparing / overwriting the disk =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add haveged&amp;lt;/pre&amp;gt;&lt;br /&gt;
This can take long, on my side for a 500GB nVME it tooks ~30 minutes.&lt;br /&gt;
&amp;lt;pre&amp;gt;# haveged -n 0 | dd of=/dev/nvme0n1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Partitioning the disk =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s assume the disk is /dev/nvme0n1 and no partition is present, we will create two partitions :&lt;br /&gt;
 &lt;br /&gt;
* one for UEFI&lt;br /&gt;
* one for LVM&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; # gdisk /dev/nvme0n1&lt;br /&gt;
GPT fdisk (gdisk) version 1.0.9.1&lt;br /&gt;
&lt;br /&gt;
Partition table scan:&lt;br /&gt;
  MBR: not present&lt;br /&gt;
  BSD: not present&lt;br /&gt;
  APM: not present&lt;br /&gt;
  GPT: not present&lt;br /&gt;
&lt;br /&gt;
Creating new GPT entries in memory.&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (1-128, default 1): &lt;br /&gt;
First sector (34-1000215182, default = 2048) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (2048-1000215182, default = 1000214527) or {+-}size{KMGTP}: 512M&lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): ef00&lt;br /&gt;
Changed type of partition to &#039;EFI system partition&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (2-128, default 2): &lt;br /&gt;
First sector (34-1000215182, default = 1050624) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (1050624-1000215182, default = 1000214527) or {+-}size{KMGTP}: &lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): 8309&lt;br /&gt;
Changed type of partition to &#039;Linux LUKS&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): w&lt;br /&gt;
&lt;br /&gt;
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING&lt;br /&gt;
PARTITIONS!!&lt;br /&gt;
&lt;br /&gt;
Do you want to proceed? (Y/N): Y&lt;br /&gt;
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.&lt;br /&gt;
The operation has completed successfully.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Populate /dev with the new partitions&lt;br /&gt;
&amp;lt;pre&amp;gt; # partprobe /dev/nvme0n1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring LUKS =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# cryptsetup -v -c aes-xts-plain64 -s 512 --hash sha512 --pbkdf pbkdf2 --iter-time 1000 --use-random luksFormat /dev/nvme0n1p2&lt;br /&gt;
&lt;br /&gt;
WARNING!&lt;br /&gt;
========&lt;br /&gt;
This will overwrite data on /dev/nvme0n1p2 irrevocably.&lt;br /&gt;
&lt;br /&gt;
Are you sure? (Type &#039;yes&#039; in capital letters): YES&lt;br /&gt;
Enter passphrase for /dev/nvme0n1p2: &lt;br /&gt;
Verify passphrase: &lt;br /&gt;
Key slot 0 created.&lt;br /&gt;
Command successful.&lt;br /&gt;
&lt;br /&gt;
# cryptsetup luksOpen /dev/nvme0n1p2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
= LVM : Physical &amp;amp; Logical Volumes creation =&lt;br /&gt;
&amp;lt;pre&amp;gt;# pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
  Physical volume &amp;quot;/dev/mapper/lvmcrypt&amp;quot; successfully created.&lt;br /&gt;
# vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
  Volume group &amp;quot;vg0&amp;quot; successfully created&lt;br /&gt;
# lvcreate -L 20G vg0 -n swap (I have a 16GB RAM laptop)&lt;br /&gt;
  Logical volume &amp;quot;swap&amp;quot; created.&lt;br /&gt;
# lvcreate -l 100%FREE vg0 -n root&lt;br /&gt;
  Logical volume &amp;quot;root&amp;quot; created.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check the creation :&lt;br /&gt;
&amp;lt;pre&amp;gt;# lvscan&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/swap&#039; [20.00 GiB] inherit&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/root&#039; [455.92 GiB] inherit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Mounting points and File System =&lt;br /&gt;
&lt;br /&gt;
Create vfat file system for UEFI partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.vfat /dev/nvme0n1p1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ext4 file system for / partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.ext4 /dev/vg0/root&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activate SWAP:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkswap /dev/vg0/swap&lt;br /&gt;
# swapon /dev/vg0/swap&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount / partition to /mnt :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t ext4 /dev/vg0/root /mnt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /boot/efi:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /mnt/boot/efi -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount UEFI partition to /mnt/boot/efi :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t vfat /dev/nvme0n1p1 /mnt/boot/efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk&lt;br /&gt;
nvme0n1        259:0    0 476.9G  0 disk  &lt;br /&gt;
├─nvme0n1p1    259:1    0   511M  0 part  /mnt/boot/efi&lt;br /&gt;
└─nvme0n1p2    259:2    0 476.4G  0 part  &lt;br /&gt;
  └─lvmcrypt   253:0    0 476.4G  0 crypt &lt;br /&gt;
    ├─vg0-swap 253:1    0    20G  0 lvm   [SWAP]&lt;br /&gt;
    └─vg0-root 253:2    0 456.4G  0 lvm   /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Alpine =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# setup-disk -m sys /mnt/&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mkinitfs settings &amp;amp; modules =&lt;br /&gt;
Edit the /mnt/etc/mkinitfs/mkinitfs.conf file and append the modules to the features parameters (keymap only needed if your keyboard is not QWERTY):&lt;br /&gt;
&amp;lt;pre&amp;gt;features=&amp;quot;ata base ide scsi usb virtio ext4 lvm nvme keymap cryptsetup cryptkey resume&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Regenerate the initram:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkinitfs -c /mnt/etc/mkinitfs/mkinitfs.conf -b /mnt/ $(ls /mnt/lib/modules/)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Grub settings =&lt;br /&gt;
&lt;br /&gt;
Create a crypto_keyfile.bin to avoid typing the passphrase twice during the boot process (one for Grub partition, one for Alpine partition):&lt;br /&gt;
&amp;lt;pre&amp;gt;# touch /mnt/crypto_keyfile.bin&lt;br /&gt;
# chmod 600 /mnt/crypto_keyfile.bin&lt;br /&gt;
# dd if=/dev/random bs=512 count=4 | xxd -p -c999 | tr -d &#039;\n&#039; &amp;gt; /mnt/crypto_keyfile.bin&lt;br /&gt;
# cryptsetup luksAddKey /dev/nvme0n1p2 /mnt/crypto_keyfile.bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, let&#039;s mount and chroot to our fresh installation:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t proc /proc /mnt/proc&lt;br /&gt;
# mount --rbind /dev /mnt/dev&lt;br /&gt;
# mount --make-rslave /mnt/dev&lt;br /&gt;
# mount --rbind /sys /mnt/sys&lt;br /&gt;
# chroot /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/default/grub and add cryptkey after cryptdm=root parameter like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_TIMEOUT=2&lt;br /&gt;
GRUB_DISABLE_SUBMENU=y&lt;br /&gt;
GRUB_DISABLE_RECOVERY=true&lt;br /&gt;
GRUB_CMDLINE_LINUX_DEFAULT=&amp;quot;modules=sd-mod,usb-storage,ext4,nvme cryptroot=UUID=XXXX cryptdm=lvmcrypt cryptkey quiet rootfstype=ext4&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
XXXX could be found with blkid command&lt;br /&gt;
&lt;br /&gt;
Add a new GRUB_PRELOAD_MODULES line like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_PRELOAD_MODULES=&amp;quot;luks cryptodisk part_gpt lvm&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, add the cryptodisk parameter :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_ENABLE_CRYPTODISK=y&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let&#039;s show the UUID of our partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a /root/grub-pre.cfg and replace &amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt; with your encrypted lvm partition UUID (here /dev/nvme0n1p2) without hyphens, replace &amp;lt;YYYY&amp;gt; with VG UUID from vgdisplay and replace &amp;lt;ZZZZ&amp;gt; with LV UUID from lvdisplay of your /dev/vg0/root&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set crypto_uuid=&amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt;&lt;br /&gt;
cryptomount -u $crypto_uuid&lt;br /&gt;
set root=&#039;lvmid/&amp;lt;YYYY&amp;gt;/&amp;lt;ZZZZ&amp;gt;&#039;&lt;br /&gt;
set prefix=($root)/boot/grub&lt;br /&gt;
insmod normal&lt;br /&gt;
normal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring Secure Boot =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efi-mkkeys efibootmgr sbsigntool&lt;br /&gt;
# efi-mkkeys -s &amp;quot;Your Name&amp;quot; -o /etc/uefi-keys&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-install Grub:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /boot/efi/EFI/AlpineLinuxSecureBoot&lt;br /&gt;
# grub-mkimage -p /boot/grub -O x86_64-efi -c /root/grub-pre.cfg -o /tmp/grubx64.efi luks2 part_gpt cryptodisk lvm ext2 gcry_rijndael pbkdf2 gcry_sha512&lt;br /&gt;
# install -v /tmp/grubx64.efi /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sed -i &#039;s/SecureBoot/SecureB00t/&#039; /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi&lt;br /&gt;
# cd /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sbsign --key /etc/uefi-keys/db.key --cert /etc/uefi-keys/db.crt --output grubx64.efi.signed grubx64.efi&lt;br /&gt;
# grub-mkconfig -o /boot/grub/grub.cfg&lt;br /&gt;
# efibootmgr --disk /dev/nvme0n1p1 --part 1 --create --label &#039;Alpine Linux Secure Boot Signed&#039; --load /EFI/AlpineLinuxSecureBoot/grubx64.efi.signed --verbose&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check that your .efi is signed :&lt;br /&gt;
&amp;lt;pre&amp;gt; # sbverify --cert /etc/uefi-keys/db.crt /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed &lt;br /&gt;
Signature verification OK&lt;br /&gt;
# sbverify --list /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed&lt;br /&gt;
signature 1&lt;br /&gt;
image signature issuers:&lt;br /&gt;
 - /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
image signature certificates:&lt;br /&gt;
 - subject: /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
   issuer:  /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy db.auth, KEK.auth and PK.auth files from /etc/uefi-keys to a FAT formatted file system.&lt;br /&gt;
&lt;br /&gt;
Reboot &amp;amp; enter into your UEFI (Fx key depending of your laptop)&lt;br /&gt;
&lt;br /&gt;
== Import keys to UEFI ==&lt;br /&gt;
&lt;br /&gt;
This is just an example from an XPS laptop, each UEFI is unique.&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;&#039;Boot Configuration&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;Secure Boot&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Secure Boot&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Secure Boot Mode&#039;&#039;&#039; to &#039;&#039;&#039;Deployed Mode&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Custom Mode&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Go to &#039;&#039;&#039;Custom Mode Key Management&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Reset All Keys&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;db&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;db.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;KEK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;KEK.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;PK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;PK.auth&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;APPLY CHANGES&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;EXIT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check Secure Boot State:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add mokutil&lt;br /&gt;
# mokutil --sb-state&lt;br /&gt;
SecureBoot enabled&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Congrats!&lt;br /&gt;
&lt;br /&gt;
== Hibernate on encrypted LVM swap partition ==&lt;br /&gt;
&lt;br /&gt;
Find your vg0-swap UUID :&lt;br /&gt;
&amp;lt;pre&amp;gt;lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add resume parameter to your /etc/default/grub :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_CMDLINE_LINUX_DEFAULT=....resume=UUID=&amp;lt;UUID of your vg0-swap partition&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a line to your /etc/fstab :&lt;br /&gt;
&amp;lt;pre&amp;gt;/dev/vg0/swap   none            swap     sw    0 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable swap service during boot :&lt;br /&gt;
&amp;lt;pre&amp;gt;rc-update add swap default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install zzz and test it&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add zzz&lt;br /&gt;
zzz- Z&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Done and congrats !&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Coolman</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25879</id>
		<title>Full disk encryption secure boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25879"/>
		<updated>2023-12-18T20:18:29Z</updated>

		<summary type="html">&lt;p&gt;Coolman: /* Partitioning the disk */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Disclaimer : this is not to be followed, only for testing purposes. This will be updated when GRUB 2.12 rc1 will be available for LUKSv2, GRUB and FDE to work&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
This guide is to explain, step-by-step, how to setup Alpine Linux with Full Disk Encryption using LUKS2, LVM (one Physical Volume Partition with three Logical Volume Partitions (/ /boot &amp;amp; swap) with hibernation on a NVMe drive, with UEFI &amp;amp; Secure Boot. This guide has been written using Alpine Linux Std 3.16.1, please adapt some commands if needed.&lt;br /&gt;
&lt;br /&gt;
The goal of this guide is to follow the KISS principle, but another file system can be used, multiple partitions for /home; /var/log etc.. can also be added, if the proposed configuration is not meeting your requirements.&lt;br /&gt;
&lt;br /&gt;
= Installing packages =&lt;br /&gt;
&lt;br /&gt;
To facilitate the partitioning we will use gdisk :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lsblk gptfdisk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For encryption, we will use cryptsetup :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add cryptsetup&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For LVM:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lvm2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For using and managing UEFI, multiple packages are needed :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efibootmgr e2fsprogs grub grub-efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Preparing / overwriting the disk =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add haveged&amp;lt;/pre&amp;gt;&lt;br /&gt;
This can take long, on my side for a 500GB nVME it tooks ~30 minutes.&lt;br /&gt;
&amp;lt;pre&amp;gt;# haveged -n 0 | dd of=/dev/nvme0n1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Partitioning the disk =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s assume the disk is /dev/nvme0n1 and no partition is present, we will create two partitions :&lt;br /&gt;
 &lt;br /&gt;
* one for UEFI&lt;br /&gt;
* one for LVM&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; # gdisk /dev/nvme0n1&lt;br /&gt;
GPT fdisk (gdisk) version 1.0.9.1&lt;br /&gt;
&lt;br /&gt;
Partition table scan:&lt;br /&gt;
  MBR: not present&lt;br /&gt;
  BSD: not present&lt;br /&gt;
  APM: not present&lt;br /&gt;
  GPT: not present&lt;br /&gt;
&lt;br /&gt;
Creating new GPT entries in memory.&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (1-128, default 1): &lt;br /&gt;
First sector (34-1000215182, default = 2048) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (2048-1000215182, default = 1000214527) or {+-}size{KMGTP}: 512M&lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): ef00&lt;br /&gt;
Changed type of partition to &#039;EFI system partition&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (2-128, default 2): &lt;br /&gt;
First sector (34-1000215182, default = 1050624) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (1050624-1000215182, default = 1000214527) or {+-}size{KMGTP}: &lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): 8309&lt;br /&gt;
Changed type of partition to &#039;Linux LUKS&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): w&lt;br /&gt;
&lt;br /&gt;
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING&lt;br /&gt;
PARTITIONS!!&lt;br /&gt;
&lt;br /&gt;
Do you want to proceed? (Y/N): Y&lt;br /&gt;
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.&lt;br /&gt;
The operation has completed successfully.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Populate /dev with the new partitions&lt;br /&gt;
&amp;lt;pre&amp;gt; # partprobe /dev/nvme0n1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring LUKS =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# cryptsetup -v -c aes-xts-plain64 -s 512 --hash sha512 --pbkdf pbkdf2 --iter-time 1000 --use-random luksFormat /dev/nvme0n1p2&lt;br /&gt;
&lt;br /&gt;
WARNING!&lt;br /&gt;
========&lt;br /&gt;
This will overwrite data on /dev/nvme0n1p2 irrevocably.&lt;br /&gt;
&lt;br /&gt;
Are you sure? (Type &#039;yes&#039; in capital letters): YES&lt;br /&gt;
Enter passphrase for /dev/nvme0n1p2: &lt;br /&gt;
Verify passphrase: &lt;br /&gt;
Key slot 0 created.&lt;br /&gt;
Command successful.&lt;br /&gt;
&lt;br /&gt;
# cryptsetup luksOpen /dev/nvme0n1p2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
= LVM : Physical &amp;amp; Logical Volumes creation=&lt;br /&gt;
&amp;lt;pre&amp;gt;# pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
  Physical volume &amp;quot;/dev/mapper/lvmcrypt&amp;quot; successfully created.&lt;br /&gt;
# vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
  Volume group &amp;quot;vg0&amp;quot; successfully created&lt;br /&gt;
# lvcreate -L 20G vg0 -n swap (I have a 16GB RAM laptop)&lt;br /&gt;
  Logical volume &amp;quot;swap&amp;quot; created.&lt;br /&gt;
# lvcreate -l 100%FREE vg0 -n root&lt;br /&gt;
  Logical volume &amp;quot;root&amp;quot; created.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check the creation :&lt;br /&gt;
&amp;lt;pre&amp;gt;# lvscan&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/swap&#039; [20.00 GiB] inherit&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/root&#039; [455.92 GiB] inherit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Mounting points and File System =&lt;br /&gt;
&lt;br /&gt;
Create vfat file system for UEFI partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.vfat /dev/nvme0n1p1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ext4 file system for / partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.ext4 /dev/vg0/root&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activate SWAP:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkswap /dev/vg0/swap&lt;br /&gt;
# swapon /dev/vg0/swap&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount / partition to /mnt :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t ext4 /dev/vg0/root /mnt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /boot/efi:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /mnt/boot/efi -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount UEFI partition to /mnt/boot/efi :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t vfat /dev/nvme0n1p1 /mnt/boot/efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk&lt;br /&gt;
nvme0n1        259:0    0 476.9G  0 disk  &lt;br /&gt;
├─nvme0n1p1    259:1    0   511M  0 part  /mnt/boot/efi&lt;br /&gt;
└─nvme0n1p2    259:2    0 476.4G  0 part  &lt;br /&gt;
  └─lvmcrypt   253:0    0 476.4G  0 crypt &lt;br /&gt;
    ├─vg0-swap 253:1    0    20G  0 lvm   [SWAP]&lt;br /&gt;
    └─vg0-root 253:2    0 456.4G  0 lvm   /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Alpine =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# setup-disk -m sys /mnt/&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mkinitfs settings &amp;amp; modules =&lt;br /&gt;
Edit the /mnt/etc/mkinitfs/mkinitfs.conf file and append the modules to the features parameters (keymap only needed if your keyboard is not QWERTY):&lt;br /&gt;
&amp;lt;pre&amp;gt;features=&amp;quot;ata base ide scsi usb virtio ext4 lvm nvme keymap cryptsetup cryptkey resume&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Regenerate the initram:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkinitfs -c /mnt/etc/mkinitfs/mkinitfs.conf -b /mnt/ $(ls /mnt/lib/modules/)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Grub settings =&lt;br /&gt;
&lt;br /&gt;
Create a crypto_keyfile.bin to avoid typing the passphrase twice during the boot process (one for Grub partition, one for Alpine partition):&lt;br /&gt;
&amp;lt;pre&amp;gt;# touch /mnt/crypto_keyfile.bin&lt;br /&gt;
# chmod 600 /mnt/crypto_keyfile.bin&lt;br /&gt;
# dd if=/dev/random bs=512 count=4 | xxd -p -c999 | tr -d &#039;\n&#039; &amp;gt; /mnt/crypto_keyfile.bin&lt;br /&gt;
# cryptsetup luksAddKey /dev/nvme0n1p2 /mnt/crypto_keyfile.bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, let&#039;s mount and chroot to our fresh installation:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t proc /proc /mnt/proc&lt;br /&gt;
# mount --rbind /dev /mnt/dev&lt;br /&gt;
# mount --make-rslave /mnt/dev&lt;br /&gt;
# mount --rbind /sys /mnt/sys&lt;br /&gt;
# chroot /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/default/grub and add cryptkey after cryptdm=root parameter like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_TIMEOUT=2&lt;br /&gt;
GRUB_DISABLE_SUBMENU=y&lt;br /&gt;
GRUB_DISABLE_RECOVERY=true&lt;br /&gt;
GRUB_CMDLINE_LINUX_DEFAULT=&amp;quot;modules=sd-mod,usb-storage,ext4,nvme cryptroot=UUID=XXXX cryptdm=lvmcrypt cryptkey quiet rootfstype=ext4&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
XXXX could be found with blkid command&lt;br /&gt;
&lt;br /&gt;
Add a new GRUB_PRELOAD_MODULES line like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_PRELOAD_MODULES=&amp;quot;luks cryptodisk part_gpt lvm&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, add the cryptodisk parameter :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_ENABLE_CRYPTODISK=y&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let&#039;s show the UUID of our partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a /root/grub-pre.cfg and replace &amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt; with your encrypted lvm partition UUID (here /dev/nvme0n1p2) without hyphens, replace &amp;lt;YYYY&amp;gt; with VG UUID from vgdisplay and replace &amp;lt;ZZZZ&amp;gt; with LV UUID from lvdisplay of your /dev/vg0/root&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set crypto_uuid=&amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt;&lt;br /&gt;
cryptomount -u $crypto_uuid&lt;br /&gt;
set root=&#039;lvmid/&amp;lt;YYYY&amp;gt;/&amp;lt;ZZZZ&amp;gt;&#039;&lt;br /&gt;
set prefix=($root)/boot/grub&lt;br /&gt;
insmod normal&lt;br /&gt;
normal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring Secure Boot =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efi-mkkeys efibootmgr sbsigntool&lt;br /&gt;
# efi-mkkeys -s &amp;quot;Your Name&amp;quot; -o /etc/uefi-keys&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-install Grub:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /boot/efi/EFI/AlpineLinuxSecureBoot&lt;br /&gt;
# grub-mkimage -p /boot/grub -O x86_64-efi -c /root/grub-pre.cfg -o /tmp/grubx64.efi luks2 part_gpt cryptodisk lvm ext2 gcry_rijndael pbkdf2 gcry_sha512&lt;br /&gt;
# install -v /tmp/grubx64.efi /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sed -i &#039;s/SecureBoot/SecureB00t/&#039; /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi&lt;br /&gt;
# cd /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sbsign --key /etc/uefi-keys/db.key --cert /etc/uefi-keys/db.crt --output grubx64.efi.signed grubx64.efi&lt;br /&gt;
# grub-mkconfig -o /boot/grub/grub.cfg&lt;br /&gt;
# efibootmgr --disk /dev/nvme0n1p1 --part 1 --create --label &#039;Alpine Linux Secure Boot Signed&#039; --load /EFI/AlpineLinuxSecureBoot/grubx64.efi.signed --verbose&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check that your .efi is signed :&lt;br /&gt;
&amp;lt;pre&amp;gt; # sbverify --cert /etc/uefi-keys/db.crt /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed &lt;br /&gt;
Signature verification OK&lt;br /&gt;
# sbverify --list /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed&lt;br /&gt;
signature 1&lt;br /&gt;
image signature issuers:&lt;br /&gt;
 - /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
image signature certificates:&lt;br /&gt;
 - subject: /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
   issuer:  /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy db.auth, KEK.auth and PK.auth files from /etc/uefi-keys to a FAT formatted file system.&lt;br /&gt;
&lt;br /&gt;
Reboot &amp;amp; enter into your UEFI (Fx key depending of your laptop)&lt;br /&gt;
&lt;br /&gt;
== Import keys to UEFI ==&lt;br /&gt;
&lt;br /&gt;
This is just an example from an XPS laptop, each UEFI is unique.&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;&#039;Boot Configuration&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;Secure Boot&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Secure Boot&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Secure Boot Mode&#039;&#039;&#039; to &#039;&#039;&#039;Deployed Mode&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Custom Mode&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Go to &#039;&#039;&#039;Custom Mode Key Management&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Reset All Keys&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;db&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;db.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;KEK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;KEK.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;PK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;PK.auth&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;APPLY CHANGES&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;EXIT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check Secure Boot State:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add mokutil&lt;br /&gt;
# mokutil --sb-state&lt;br /&gt;
SecureBoot enabled&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Congrats!&lt;br /&gt;
&lt;br /&gt;
== Hibernate on encrypted LVM swap partition ==&lt;br /&gt;
&lt;br /&gt;
Find your vg0-swap UUID :&lt;br /&gt;
&amp;lt;pre&amp;gt;lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add resume parameter to your /etc/default/grub :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_CMDLINE_LINUX_DEFAULT=....resume=UUID=&amp;lt;UUID of your vg0-swap partition&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a line to your /etc/fstab :&lt;br /&gt;
&amp;lt;pre&amp;gt;/dev/vg0/swap   none            swap     sw    0 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable swap service during boot :&lt;br /&gt;
&amp;lt;pre&amp;gt;rc-update add swap default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install zzz and test it&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add zzz&lt;br /&gt;
zzz- Z&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Done and congrats !&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Coolman</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25878</id>
		<title>Full disk encryption secure boot</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Full_disk_encryption_secure_boot&amp;diff=25878"/>
		<updated>2023-12-18T19:21:09Z</updated>

		<summary type="html">&lt;p&gt;Coolman: /* Preparing / overwriting the disk */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Disclaimer : this is not to be followed, only for testing purposes. This will be updated when GRUB 2.12 rc1 will be available for LUKSv2, GRUB and FDE to work&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
This guide is to explain, step-by-step, how to setup Alpine Linux with Full Disk Encryption using LUKS2, LVM (one Physical Volume Partition with three Logical Volume Partitions (/ /boot &amp;amp; swap) with hibernation on a NVMe drive, with UEFI &amp;amp; Secure Boot. This guide has been written using Alpine Linux Std 3.16.1, please adapt some commands if needed.&lt;br /&gt;
&lt;br /&gt;
The goal of this guide is to follow the KISS principle, but another file system can be used, multiple partitions for /home; /var/log etc.. can also be added, if the proposed configuration is not meeting your requirements.&lt;br /&gt;
&lt;br /&gt;
= Installing packages =&lt;br /&gt;
&lt;br /&gt;
To facilitate the partitioning we will use gdisk :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lsblk gptfdisk&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For encryption, we will use cryptsetup :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add cryptsetup&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For LVM:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add lvm2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For using and managing UEFI, multiple packages are needed :&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efibootmgr e2fsprogs grub grub-efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Preparing / overwriting the disk =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add haveged&amp;lt;/pre&amp;gt;&lt;br /&gt;
This can take long, on my side for a 500GB nVME it tooks ~30 minutes.&lt;br /&gt;
&amp;lt;pre&amp;gt;# haveged -n 0 | dd of=/dev/nvme0n1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Partitioning the disk =&lt;br /&gt;
&lt;br /&gt;
Let&#039;s assume the disk is /dev/nvme0n1 and no partition is present, we will create two partitions :&lt;br /&gt;
 &lt;br /&gt;
* one for UEFI&lt;br /&gt;
* one for LVM&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; # gdisk /dev/nvme0n1&lt;br /&gt;
GPT fdisk (gdisk) version 1.0.9.1&lt;br /&gt;
&lt;br /&gt;
Partition table scan:&lt;br /&gt;
  MBR: not present&lt;br /&gt;
  BSD: not present&lt;br /&gt;
  APM: not present&lt;br /&gt;
  GPT: not present&lt;br /&gt;
&lt;br /&gt;
Creating new GPT entries in memory.&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (1-128, default 1): &lt;br /&gt;
First sector (34-1000215182, default = 2048) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (2048-1000215182, default = 1000214527) or {+-}size{KMGTP}: 512M&lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): ef00&lt;br /&gt;
Changed type of partition to &#039;EFI system partition&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): n&lt;br /&gt;
Partition number (2-128, default 2): &lt;br /&gt;
First sector (34-1000215182, default = 1050624) or {+-}size{KMGTP}: &lt;br /&gt;
Last sector (1050624-1000215182, default = 1000214527) or {+-}size{KMGTP}: &lt;br /&gt;
Current type is 8300 (Linux filesystem)&lt;br /&gt;
Hex code or GUID (L to show codes, Enter = 8300): 8309&lt;br /&gt;
Changed type of partition to &#039;Linux LUKS&#039;&lt;br /&gt;
&lt;br /&gt;
Command (? for help): w&lt;br /&gt;
&lt;br /&gt;
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING&lt;br /&gt;
PARTITIONS!!&lt;br /&gt;
&lt;br /&gt;
Do you want to proceed? (Y/N): Y&lt;br /&gt;
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.&lt;br /&gt;
The operation has completed successfully.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring LUKS =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# cryptsetup -v -c aes-xts-plain64 -s 512 --hash sha512 --pbkdf pbkdf2 --iter-time 1000 --use-random luksFormat /dev/nvme0n1p2&lt;br /&gt;
&lt;br /&gt;
WARNING!&lt;br /&gt;
========&lt;br /&gt;
This will overwrite data on /dev/nvme0n1p2 irrevocably.&lt;br /&gt;
&lt;br /&gt;
Are you sure? (Type &#039;yes&#039; in capital letters): YES&lt;br /&gt;
Enter passphrase for /dev/nvme0n1p2: &lt;br /&gt;
Verify passphrase: &lt;br /&gt;
Key slot 0 created.&lt;br /&gt;
Command successful.&lt;br /&gt;
&lt;br /&gt;
# cryptsetup luksOpen /dev/nvme0n1p2 lvmcrypt&lt;br /&gt;
&lt;br /&gt;
= LVM : Physical &amp;amp; Logical Volumes creation=&lt;br /&gt;
&amp;lt;pre&amp;gt;# pvcreate /dev/mapper/lvmcrypt&lt;br /&gt;
  Physical volume &amp;quot;/dev/mapper/lvmcrypt&amp;quot; successfully created.&lt;br /&gt;
# vgcreate vg0 /dev/mapper/lvmcrypt&lt;br /&gt;
  Volume group &amp;quot;vg0&amp;quot; successfully created&lt;br /&gt;
# lvcreate -L 20G vg0 -n swap (I have a 16GB RAM laptop)&lt;br /&gt;
  Logical volume &amp;quot;swap&amp;quot; created.&lt;br /&gt;
# lvcreate -l 100%FREE vg0 -n root&lt;br /&gt;
  Logical volume &amp;quot;root&amp;quot; created.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check the creation :&lt;br /&gt;
&amp;lt;pre&amp;gt;# lvscan&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/swap&#039; [20.00 GiB] inherit&lt;br /&gt;
  ACTIVE            &#039;/dev/vg0/root&#039; [455.92 GiB] inherit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Mounting points and File System =&lt;br /&gt;
&lt;br /&gt;
Create vfat file system for UEFI partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.vfat /dev/nvme0n1p1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create ext4 file system for / partition:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkfs.ext4 /dev/vg0/root&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activate SWAP:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkswap /dev/vg0/swap&lt;br /&gt;
# swapon /dev/vg0/swap&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount / partition to /mnt :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t ext4 /dev/vg0/root /mnt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create /boot/efi:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /mnt/boot/efi -p&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Mount UEFI partition to /mnt/boot/efi :&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t vfat /dev/nvme0n1p1 /mnt/boot/efi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk&lt;br /&gt;
nvme0n1        259:0    0 476.9G  0 disk  &lt;br /&gt;
├─nvme0n1p1    259:1    0   511M  0 part  /mnt/boot/efi&lt;br /&gt;
└─nvme0n1p2    259:2    0 476.4G  0 part  &lt;br /&gt;
  └─lvmcrypt   253:0    0 476.4G  0 crypt &lt;br /&gt;
    ├─vg0-swap 253:1    0    20G  0 lvm   [SWAP]&lt;br /&gt;
    └─vg0-root 253:2    0 456.4G  0 lvm   /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Installing Alpine =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# setup-disk -m sys /mnt/&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= mkinitfs settings &amp;amp; modules =&lt;br /&gt;
Edit the /mnt/etc/mkinitfs/mkinitfs.conf file and append the modules to the features parameters (keymap only needed if your keyboard is not QWERTY):&lt;br /&gt;
&amp;lt;pre&amp;gt;features=&amp;quot;ata base ide scsi usb virtio ext4 lvm nvme keymap cryptsetup cryptkey resume&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
Regenerate the initram:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkinitfs -c /mnt/etc/mkinitfs/mkinitfs.conf -b /mnt/ $(ls /mnt/lib/modules/)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Grub settings =&lt;br /&gt;
&lt;br /&gt;
Create a crypto_keyfile.bin to avoid typing the passphrase twice during the boot process (one for Grub partition, one for Alpine partition):&lt;br /&gt;
&amp;lt;pre&amp;gt;# touch /mnt/crypto_keyfile.bin&lt;br /&gt;
# chmod 600 /mnt/crypto_keyfile.bin&lt;br /&gt;
# dd if=/dev/random bs=512 count=4 | xxd -p -c999 | tr -d &#039;\n&#039; &amp;gt; /mnt/crypto_keyfile.bin&lt;br /&gt;
# cryptsetup luksAddKey /dev/nvme0n1p2 /mnt/crypto_keyfile.bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, let&#039;s mount and chroot to our fresh installation:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mount -t proc /proc /mnt/proc&lt;br /&gt;
# mount --rbind /dev /mnt/dev&lt;br /&gt;
# mount --make-rslave /mnt/dev&lt;br /&gt;
# mount --rbind /sys /mnt/sys&lt;br /&gt;
# chroot /mnt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/default/grub and add cryptkey after cryptdm=root parameter like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_TIMEOUT=2&lt;br /&gt;
GRUB_DISABLE_SUBMENU=y&lt;br /&gt;
GRUB_DISABLE_RECOVERY=true&lt;br /&gt;
GRUB_CMDLINE_LINUX_DEFAULT=&amp;quot;modules=sd-mod,usb-storage,ext4,nvme cryptroot=UUID=XXXX cryptdm=lvmcrypt cryptkey quiet rootfstype=ext4&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
XXXX could be found with blkid command&lt;br /&gt;
&lt;br /&gt;
Add a new GRUB_PRELOAD_MODULES line like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_PRELOAD_MODULES=&amp;quot;luks cryptodisk part_gpt lvm&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, add the cryptodisk parameter :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_ENABLE_CRYPTODISK=y&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let&#039;s show the UUID of our partition scheme:&lt;br /&gt;
&amp;lt;pre&amp;gt;# lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a /root/grub-pre.cfg and replace &amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt; with your encrypted lvm partition UUID (here /dev/nvme0n1p2) without hyphens, replace &amp;lt;YYYY&amp;gt; with VG UUID from vgdisplay and replace &amp;lt;ZZZZ&amp;gt; with LV UUID from lvdisplay of your /dev/vg0/root&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set crypto_uuid=&amp;lt;XXXX-UUID_WITHOUT_HYPHENS&amp;gt;&lt;br /&gt;
cryptomount -u $crypto_uuid&lt;br /&gt;
set root=&#039;lvmid/&amp;lt;YYYY&amp;gt;/&amp;lt;ZZZZ&amp;gt;&#039;&lt;br /&gt;
set prefix=($root)/boot/grub&lt;br /&gt;
insmod normal&lt;br /&gt;
normal&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Configuring Secure Boot =&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add efi-mkkeys efibootmgr sbsigntool&lt;br /&gt;
# efi-mkkeys -s &amp;quot;Your Name&amp;quot; -o /etc/uefi-keys&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-install Grub:&lt;br /&gt;
&amp;lt;pre&amp;gt;# mkdir /boot/efi/EFI/AlpineLinuxSecureBoot&lt;br /&gt;
# grub-mkimage -p /boot/grub -O x86_64-efi -c /root/grub-pre.cfg -o /tmp/grubx64.efi luks2 part_gpt cryptodisk lvm ext2 gcry_rijndael pbkdf2 gcry_sha512&lt;br /&gt;
# install -v /tmp/grubx64.efi /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sed -i &#039;s/SecureBoot/SecureB00t/&#039; /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi&lt;br /&gt;
# cd /boot/efi/EFI/AlpineLinuxSecureBoot/&lt;br /&gt;
# sbsign --key /etc/uefi-keys/db.key --cert /etc/uefi-keys/db.crt --output grubx64.efi.signed grubx64.efi&lt;br /&gt;
# grub-mkconfig -o /boot/grub/grub.cfg&lt;br /&gt;
# efibootmgr --disk /dev/nvme0n1p1 --part 1 --create --label &#039;Alpine Linux Secure Boot Signed&#039; --load /EFI/AlpineLinuxSecureBoot/grubx64.efi.signed --verbose&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check that your .efi is signed :&lt;br /&gt;
&amp;lt;pre&amp;gt; # sbverify --cert /etc/uefi-keys/db.crt /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed &lt;br /&gt;
Signature verification OK&lt;br /&gt;
# sbverify --list /boot/efi/EFI/AlpineLinuxSecureBoot/grubx64.efi.signed&lt;br /&gt;
signature 1&lt;br /&gt;
image signature issuers:&lt;br /&gt;
 - /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
image signature certificates:&lt;br /&gt;
 - subject: /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
   issuer:  /CN=&amp;quot;Your Name&amp;quot; (db)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy db.auth, KEK.auth and PK.auth files from /etc/uefi-keys to a FAT formatted file system.&lt;br /&gt;
&lt;br /&gt;
Reboot &amp;amp; enter into your UEFI (Fx key depending of your laptop)&lt;br /&gt;
&lt;br /&gt;
== Import keys to UEFI ==&lt;br /&gt;
&lt;br /&gt;
This is just an example from an XPS laptop, each UEFI is unique.&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;&#039;Boot Configuration&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;Secure Boot&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Secure Boot&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Secure Boot Mode&#039;&#039;&#039; to &#039;&#039;&#039;Deployed Mode&#039;&#039;&#039;&lt;br /&gt;
# Change &#039;&#039;&#039;Enable Custom Mode&#039;&#039;&#039; to &#039;&#039;&#039;ON&#039;&#039;&#039;&lt;br /&gt;
# Go to &#039;&#039;&#039;Custom Mode Key Management&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Reset All Keys&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;db&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;db.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;KEK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;KEK.auth&#039;&#039;&#039;&lt;br /&gt;
#* &#039;&#039;&#039;Select Key Database&#039;&#039;&#039; select &#039;&#039;&#039;PK&#039;&#039;&#039; &amp;gt; Replace from file &amp;gt; select your Flash Drive &amp;gt; select &#039;&#039;&#039;PK.auth&#039;&#039;&#039;&lt;br /&gt;
# &#039;&#039;&#039;APPLY CHANGES&#039;&#039;&#039; &amp;gt; &#039;&#039;&#039;EXIT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check Secure Boot State:&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add mokutil&lt;br /&gt;
# mokutil --sb-state&lt;br /&gt;
SecureBoot enabled&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Congrats!&lt;br /&gt;
&lt;br /&gt;
== Hibernate on encrypted LVM swap partition ==&lt;br /&gt;
&lt;br /&gt;
Find your vg0-swap UUID :&lt;br /&gt;
&amp;lt;pre&amp;gt;lsblk -f&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add resume parameter to your /etc/default/grub :&lt;br /&gt;
&amp;lt;pre&amp;gt;GRUB_CMDLINE_LINUX_DEFAULT=....resume=UUID=&amp;lt;UUID of your vg0-swap partition&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a line to your /etc/fstab :&lt;br /&gt;
&amp;lt;pre&amp;gt;/dev/vg0/swap   none            swap     sw    0 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable swap service during boot :&lt;br /&gt;
&amp;lt;pre&amp;gt;rc-update add swap default&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install zzz and test it&lt;br /&gt;
&amp;lt;pre&amp;gt;# apk add zzz&lt;br /&gt;
zzz- Z&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Done and congrats !&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Coolman</name></author>
	</entry>
</feed>