cryptsetup open --type plain -d /dev/urandom /dev/nvme0n1 to-be-wiped
dd if=/dev/zero of=/dev/mapper/to-be-wiped bs=1M status=progress
cryptsetup close to-be-wiped
wipefs -a /dev/nvme0n1Kernel will be stored on EFI System Partition.
Number Size Name Flags
1 1024 MiB efi boot, esp
3 -1 MiB data
-
Format EFI partition with FAT32:
mkfs.fat -F 32 -n EFI /dev/nvme0n1p1 -
Format data partition with LUKS:
cryptsetup luksFormat -i 5000 --label system-luks /dev/nvme0n1p2 cryptsetup --allow-discards --perf-no_read_workqueue --perf-no_write_workqueue --persistent open /dev/nvme0n1p2 system -
Create Btrfs on LUKS:
mkfs.btrfs -L system /dev/mapper/data -
Mount Btrfs:
mount -t btrfs -o autodefrag,compress=zstd:1,noatime,space_cache,ssd /dev/mapper/system /mnt -
Create subvolumes:
cd /mnt btrfs subvolume create @ btrfs subvolume create @home -
Prepare mount points:
mkdir /mnt/@/boot chmod 000 /mnt/@/boot mkdir /mnt/@/home chmod 000 /mnt/@/home -
(Re)mount filesystems:
umount /mnt mount -t btrfs -o autodefrag,compress=zstd:1,noatime,space_cache,ssd,,subvol=@ /dev/mapper/system /mnt mount -t btrfs -o autodefrag,compress=zstd:1,noatime,space_cache,ssd,,subvol=@home /dev/mapper/system /mnt/home mount /dev/nvme0n1p1 /mnt/boot
- The default and recommended cipher is AES-XTS.
- AMD Ryzen 7 4750U has SHA extension that accelerates SHA-1 and SHA-256, but not SHA-512 – better to use SHA-256 (which is also LUKS default).
- The default key size is 512b for XTS, which is effectively 256b due to key splitting. Fedora uses 512b as well.
- Iteration time is recommended 5000 in the articles above, default is 2000.
- My Samsung NVMe disk supports only 512 bytes block size.
- https://wiki.archlinux.org/title/EFI_system_partition
- https://wiki.archlinux.org/title/Dm-crypt/Device_encryption
- https://wiki.archlinux.org/title/Dm-crypt/Specialties#Discard/TRIM_support_for_solid_state_drives_(SSD)
- https://wiki.archlinux.org/title/Dm-crypt/Specialties#Disable_workqueue_for_increased_solid_state_drive_(SSD)_performance
- https://github.com/keithieopia/linux-guides/blob/master/full-disk-encryption.md
-
Install essential packages:
pacstrap /mnt base linux linux-firmware btrfs-progs amd-ucode efibootmgr vim -
Generate fstab:
genfstab -U /mnt >> /mnt/etc/fstab -
chroot into:
arch-chroot /mnt -
Configure time:
ln -sf /usr/share/zoneinfo/Europe/Prague /etc/localtime hwclock --systohc -
Configure locale:
# edit `/etc/locale.gen` and uncomment `en_US.UTF-8 UTF-8` locale-gen echo "LANG=en_US.UTF-8" > /etc/locale.conf -
Configure hostname and hosts:
echo your-hostname > /etc/hostname printf "127.0.0.1\tlocalhost\n::1\tlocalhost\n" >> /etc/hosts printf "127.0.0.1\tyour-hostname.local your-hostname\n::1\tyour-hostname.local your-hostname\n" >> /etc/hosts -
Edit /etc/mkinitcpio.conf and regenerate initramdisk:
- add
vfattoMODULES - remove
fsckfromHOOKS, movekeyboardafterudevand addecryptafterblock mkinitcpio -P
- add
Create boot entry:
efibootmgr --disk /dev/nvme0n1 --part 1 --create --label 'Arch Linux' --load /vmlinuz-linux --unicode 'cryptdevice=UUID=<LUKS-UUID>:system root=/dev/mapper/system rw rootflags=autodefrag,compress=zstd:1,noatime,space_cache,ssd,subvol=@ initrd=\amd-ucode.img initrd=\initramfs-linux.img' --verbose
efibootmgr --bootnum 0000 --activeexit
umount /mnt/boot
umount /mnt/home
umount /mnt
cryptsetup close system
reboot-
Install base-devel:
pacman -S base-devel -
Clone, build and install rtw89-dkms-git from AUR:
$ mkdir ~/pkgbuilds $ git clone https://aur.archlinux.org/packages/rtw89-dkms-git pkgbuilds/rtw89-dkms-git $ cd pkgbuilds/rtw89-dkms-git # Fix PKGBUILD to copy dkms.conf *after* copying files from rtw89 repository $ makepkg -si root# modprobe rtw89pci
-
Install package
efitools. -
Prepare directory for keys:
install -d -m 700 /etc/efi-keys -
Backup vendor keys:
mkdir -p /etc/efi-keys/vendor cd /etc/efi-keys/vendor for i in PK KEK db dbx; do efi-readvar -v $i -o $i.esl; done -
Download efi-mkkeys script:
curl -o efi-mkkeys https://raw.githubusercontent.com/jirutka/efi-mkkeys/v0.1.0/efi-mkkeys chmod +x efi-mkkeys -
Generate self-signed PK, KEK and db key, including .esl and .auth files:
./efi-mkkeys -s "Your Name" -o /etc/efi-keys -
Clone, build and install sbupdate-git from AUR:
$ git clone https://aur.archlinux.org/sbupdate-git.git pkgbuilds/sbupdate-git $ cd pkgbuilds/sbupdate-git $ makepkg -si -
Edit /etc/sbupdate.conf:
BACKUP=1 CMDLINE_DEFAULT="cryptdevice=UUID=<LUKS-UUID>:system root=/dev/mapper/system rw rootflags=autodefrag,compress=zstd:1,noatime,space_cache,ssd,subvol=@" CONFIGS["linux"]="linux linux-fallback" -
Sign kernel:
sbupdate -
Add boot entry:
efibootmgr --disk /dev/nvme0n1 --part 1 --create --label 'Arch Linux (default)' --load /EFI/Arch/linux-signed.efi --verbose -
Reboot system and verify that it boots.
- Reboot system and enter ThinkPad Setup (F1).
- Go to
Security>Secure Boot - Change
Secure BoottoEnabled Reset to Setup Mode- Go to
Key Management Authorized Signature Database (DB)Enroll DB> select your Flash Drive > selectdb.authDelete DB> delete Microsoft certificates
Key Exchange Key (KEK)Enroll KEK> select your Flash Drive > selectKEK.authDelete KEK> delete Microsoft certificates
Platform Key (PK)>Enroll PK> select your Flash Drive > selectPK.auth- Go to top,
Restart>Exit Saving Changes
-
Move
/boot/*to encrypted Btrfs and keep only/boot/EFI/Archon the EFI partition:umount /boot mount LABEL=EFI /mnt chmod 755 /boot mv /mnt/*.img /mnt/vmlinuz-linux /boot/ install -d -m 000 /boot/EFI mv /mnt/EFI/Arch /mnt/ rmdir /mnt/EFI -
Change mountpoint for EFI partition in
/etc/fstabfrom/bootto/boot/EFI. -
Edit
/etc/sbupdate.conf:ESP_DIR="/boot/EFI" OUT_DIR="Arch" -
Delete and re-create boot entries:
efibootmgr -b 0000 --delete-bootnum efibootmgr -b 0001 --delete-bootnum efibootmgr --disk /dev/nvme0n1 --part 1 --create --label 'Arch Linux (default)' --load /Arch/linux-signed.efi --verbose efibootmgr --disk /dev/nvme0n1 --part 1 --create --label 'Arch Linux (fallback)' --load /Arch/linux-fallback-signed.efi --verbose -
Regenerate initramdisks:
mkinitcpio -P sbupdate
One can use
umount -R /mntto unmount all of them at once.