Unlock LUKS Automatically with TPM 2.0 on Fedora¶
Step-by-step guide for configuring automatic LUKS2 root volume decryption using hardware TPM 2.0 and systemd-cryptenroll.
Tested on: Fedora 44 KDE Plasma
Before you start¶
- Your passphrase stays. The TPM is added as an extra key slot; your existing LUKS passphrase keeps working and is the fallback whenever the TPM refuses to unlock.
- Expect to need it. The binding uses PCR 7 (Secure Boot state), so turning Secure Boot off, enrolling new keys, or some firmware updates will make the TPM refuse, and you'll be asked for the passphrase. Make sure you know it before starting.
- Optional recovery key:
sudo systemd-cryptenroll --recovery-key /dev/<YOUR_PARTITION>prints a key you can store offline (password manager, paper).
1. Install Dependencies¶
Install the required packages to interact with the TPM 2.0 chip using systemd-cryptenroll.
Command:
Example Output:
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
tpm2-tools x86_64 5.5-1.fc44 fedora 1.2 M
tpm2-tss x86_64 4.0.1-3.fc44 fedora 1.5 M
Transaction Summary
================================================================================
Install 2 Packages
...
Complete!
2. Configure Dracut for Early Boot¶
The initramfs must load the TPM modules before attempting to mount the encrypted root filesystem. Create the required configuration file.
Command:
Full File Content (/etc/dracut.conf.d/tpm2.conf):
3. Identify Your LUKS Device Partition¶
Find the exact partition containing your encrypted volume.
Command:
4. Enroll the TPM into the LUKS Volume¶
Bind the unlock process to PCR 7, which ensures the drive only unlocks if the Secure Boot state remains untampered. Replace /dev/<YOUR_PARTITION> with the specific partition identified in the previous step.
Command:
Example Output:
(You can verify the enrollment with sudo systemd-cryptenroll /dev/<YOUR_PARTITION>, which will show the new tpm2 keyslot alongside your existing password slot.)
5. Update Crypttab¶
Modify your configuration to instruct the system to use the TPM during boot by adding the tpm2-device=auto option. Replace <YOUR-UUID> with the exact UUID of your LUKS partition.
Command:
Full Updated File Template (/etc/crypttab):
Keep each entry on one line: crypttab has no line continuation, so an entry split with \ will fail to unlock at boot. The four columns are the mapped name, the device, the key file (none = ask for the passphrase or use the TPM), and the options.
6. Rebuild Initramfs and Reboot¶
Apply the changes to the boot image and restart the machine to verify the configuration.
Commands:
Example Output (dracut):
dracut: Executing: /usr/bin/dracut -f --regenerate-all
dracut: *** Including module: tpm2-tss ***
dracut: *** Including module: crypt ***
dracut: *** Creating image file '/boot/initramfs-6.9.X-XXX.fc44.x86_64.img' ***
dracut: *** Creating initramfs image file '/boot/initramfs-6.9.X-XXX.fc44.x86_64.img' done ***
Undo: go back to passphrase-only unlock¶
- Remove the TPM key slot (the passphrase slot is untouched):
- Edit
/etc/crypttab(sudo nano /etc/crypttab) and removetpm2-device=autofrom the options column, keeping the line otherwise as it was. - Remove the dracut setting and rebuild the boot images:
Sources & Verification:
- ArchWiki: Systemd-cryptenroll and TPM 2.0 configuration
- Freedesktop.org Manual: crypttab(5) syntax for
tpm2-device - Fedora Magazine: Native LUKS decoupling and TPM integration documentation