Secure Drive Setup
Securing Arch Linux on External USB with LUKS & TPM2
This guide covers the steps to take to configure a encrypted root drive in Arch Linux using LUKS and TPM2.
WHY? Being a remote storage device it could be very prone to theft or loss, so encrypting the drive ensures that even if the physical device is compromised, the data remains secure. adding the TPM2 auto-unlock feature enhances usability by allowing the system to boot without manual password entry when connected to the enrolled TPM2 chip with Secure Boot enabled.
Prerequisites
Existing Arch Linux installation on an external USB drive (e.g., Samsung T7).
Arch Linux Live ISO for recovery and setup.
Basic familiarity with LUKS encryption, systemd-boot, and TPM2.
Backup & Encryption
Phase 1: Backup and Encryption
Boot into the Arch Linux Live ISO.
Create a backup of the existing system using
rsyncto a separate drive.sudo rsync -aAXHvx --info=progress2 \ --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \ / /mnt/backup/arch_backup/Flag Explanations:
-a(archive mode): Preserves permissions, ownership, timestamps, and recursively copies directories-A: Preserves Access Control Lists (ACLs)-X: Preserves extended attributes (xattrs)-H: Preserves hard links-v: Verbose output to see what's being copied-x: Don't cross filesystem boundaries (stays on the source filesystem)--info=progress2: Shows overall progress with transfer speed and time remaining
Exclusions Explained:
/dev/*,/proc/*,/sys/*: Virtual filesystems managed by the kernel/tmp/*,/run/*: Temporary runtime files/mnt/*,/media/*: Mount points (prevents copying the backup destination into itself)/lost+found: Filesystem recovery directory
Identify the target partition (Root) and formatted it with LUKS2 encryption.
cryptsetup luksFormat /dev/sdb2Open the new encrypted container.
cryptsetup open /dev/sdb2 cryptrootFormat the mapped device with your filesystem of choice (e.g., ext4) and mount the system.
mkfs.ext4 /dev/mapper/cryptroot mount /dev/mapper/cryptroot /mnt mkdir /mnt/boot mount /dev/sdb1 /mnt/bootRestore the system backup to the new encrypted partition.
sudo rsync -aAXHv --info=progress2 /mnt/backup/arch_backup/ /mnt/
Boot Configuration
Phase 2: USB Boot Configuration (Critical)
Enter the system environment.
arch-chroot /mntFix 1: Ensure USB drivers are present.
Edit
/etc/mkinitcpio.conf. In theHOOKSarray, removeautodetectand ensuresd-encryptis present.Removing autodetect prevents the installer from stripping USB drivers required to find the external drive at boot.
# /etc/mkinitcpio.conf HOOKS=(base systemd modconf keyboard block sd-encrypt filesystems fsck)Regenerate the initramfs images.
mkinitcpio -PFix 2: Handle USB Timing.
Get the UUID of the encrypted partition (
sdb2).lsblk -fEdit the bootloader config at
/boot/loader/entries/arch.conf.Add the
rd.luks.nameparameter with the UUID.Add
rootwaitto the end of the options line to prevent timeouts while the USB drive spins up.
# /boot/loader/entries/arch.conf title Arch Linux linux /vmlinuz-linux initrd /amd-ucode.img initrd /initramfs-linux.img options rd.luks.name=YOUR-UUID-HERE=cryptroot root=/dev/mapper/cryptroot rw rootwaitTo get YOUR-UUID run the following command (replace /dev/sdb2 with your root partition):
blkid /dev/sdb2Exit chroot and reboot to test the password prompt.
TPM2 Auto-Unlock & Secure Boot
Phase 3: TPM2 Auto-Unlock & Secure Boot
Install TPM2 tools.
sudo pacman -S tpm2-toolsEnroll the TPM chip into the LUKS header. Bind it to PCR 7 (Secure Boot state).
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=7 /dev/sdb2Verify the token was added.
sudo cryptsetup luksDump /dev/sdb2Look for "systemd-tpm2" under the Tokens section.
Update the bootloader to actively check for the TPM device.
Edit
/boot/loader/entries/arch.confand addrd.luks.options=tpm2-device=auto.# Final Options Line options rd.luks.name=YOUR-UUID-HERE=cryptroot rd.luks.options=tpm2-device=auto root=/dev/mapper/cryptroot rw rootwaitReboot. The system should now boot without asking for a password, provided Secure Boot is active and the drive is connected to the enrolled motherboard.