A complete guide for setting up automatic LUKS disk decryption using TPM2 on Ubuntu 24.04 LTS, without requiring a password prompt at boot.
This guide documents the process of configuring TPM2-based automatic LUKS decryption on Ubuntu 24.04 LTS. Unlike Fedora or Arch Linux where this works out-of-the-box, Ubuntu requires additional configuration due to its use of initramfs-tools instead of dracut, and a missing tss user in the initramfs.
-
Ubuntu's initramfs-tools doesn't support systemd-cryptsetup — The
tpm2-device=autooption in/etc/crypttabis a systemd-cryptsetup feature, but Ubuntu's initramfs uses traditional cryptsetup scripts. -
Security stance — Ubuntu developers have intentionally held back TPM auto-unlock support, arguing that without signed initramfs/UKI, it provides less security than passphrase-based encryption.
-
Missing tss user bug — The
clevis-initramfspackage doesn't include thetssuser/group needed for TPM2 access in the initramfs. -
Experimental official support — Ubuntu 23.10+ has an experimental Snap-based TPM encryption option in the installer, but it's a completely different architecture and marked as experimental.
- Ubuntu 24.04 LTS with LUKS-encrypted root partition
- TPM 2.0 chip (Intel PTT, AMD fTPM, or discrete TPM)
- Secure Boot enabled
- Existing LUKS passphrase (will be kept as backup)
Before starting, verify your system meets the requirements:
# Check TPM version (should show "2")
cat /sys/class/tpm/tpm0/tpm_version_major
# Verify TPM devices exist
ls -la /dev/tpm*
# Check Secure Boot status
mokutil --sb-state
# Identify your LUKS device
lsblk -o NAME,FSTYPE,TYPE,MOUNTPOINT | grep -E "crypt|luks"
# Get LUKS device details
cryptsetup luksDump /dev/nvme0n1p3 # Adjust device path as neededsudo apt install -y clevis clevis-luks clevis-tpm2 clevis-initramfs tpm2-toolsVerify installation:
dpkg -l | grep clevisThis creates a new LUKS keyslot bound to your TPM's PCR 7 (Secure Boot policy):
sudo clevis luks bind -d /dev/nvme0n1p3 tpm2 '{"pcr_ids":"7","pcr_bank":"sha256"}'You'll be prompted for your existing LUKS passphrase.
Verify the binding:
sudo clevis luks list -d /dev/nvme0n1p3Expected output:
1: tpm2 '{"hash":"sha256","key":"ecc","pcr_bank":"sha256","pcr_ids":"7"}'
This is the key fix that most guides miss. The clevis-initramfs package doesn't add the tss user to the initramfs, which causes TPM2 tools to fail during early boot.
Option A: Clone and install
git clone https://github.com/R1DEN/ubuntu-luks-tpm.git
sudo cp ubuntu-luks-tpm/hooks/tss-user /etc/initramfs-tools/hooks/
sudo chmod +x /etc/initramfs-tools/hooks/tss-userOption B: Direct download
sudo curl -o /etc/initramfs-tools/hooks/tss-user https://raw.githubusercontent.com/R1DEN/ubuntu-luks-tpm/master/hooks/tss-user
sudo chmod +x /etc/initramfs-tools/hooks/tss-usersudo update-initramfs -u -k allConfirm the tss user and clevis tools are included:
# Check for tss user
cd /tmp && rm -rf initrd_check && mkdir initrd_check && cd initrd_check
unmkinitramfs /boot/initrd.img-$(uname -r) .
grep tss main/etc/passwd main/etc/group
# Check for clevis and TPM2 tools
lsinitramfs /boot/initrd.img-$(uname -r) | grep -E "clevis|tpm2"Expected output should show:
tssuser in passwd and groupclevis-decrypt-tpm2and varioustpm2_*binaries
sudo rebootThe system should now boot directly to the login screen without prompting for the LUKS passphrase.
After successful setup, your configuration should look like:
| Component | Status |
|---|---|
| Keyslot 0 | Passphrase (backup) |
| Keyslot 1 | Clevis TPM2 |
| /etc/crypttab | Standard entry, no special options needed |
| Custom hook | /etc/initramfs-tools/hooks/tss-user |
Verify with:
sudo cryptsetup luksDump /dev/nvme0n1p3 | grep -E "^ [0-9]+:|^Tokens:|clevis"-
Check boot logs:
journalctl -b | grep -iE "clevis|tpm|crypt" | head -50
-
Verify tss user is in initramfs:
lsinitramfs /boot/initrd.img-$(uname -r) | xargs -I{} echo {} | grep passwd # Then extract and check the actual passwd file
-
Test clevis unlock manually (from live USB or recovery):
sudo clevis luks unlock -d /dev/nvme0n1p3 -n test
If you see errors about /dev/tpm0 being busy, the tpm2-abrmd service might conflict. This usually doesn't affect boot unlock but can be checked:
journalctl -b | grep tpm2-abrmdIf the TPM refuses to unlock after a BIOS/firmware update, the PCR values have changed. Re-bind clevis:
# Remove old binding
sudo clevis luks unbind -d /dev/nvme0n1p3 -s 1
# Re-bind with current PCR values
sudo clevis luks bind -d /dev/nvme0n1p3 tpm2 '{"pcr_ids":"7","pcr_bank":"sha256"}'
# Rebuild initramfs
sudo update-initramfs -u -k allOr use the regenerate command:
sudo clevis luks regen -d /dev/nvme0n1p3 -s 1PCR 7 contains measurements of the Secure Boot policy. This means:
- ✅ Stable across kernel updates
- ✅ Stable across initramfs rebuilds
⚠️ Changes if Secure Boot keys are modified⚠️ Changes if UEFI firmware is updated (sometimes)
For stricter security (but more frequent re-enrollment):
# PCR 0 + 7: Firmware + Secure Boot (breaks on BIOS updates)
sudo clevis luks bind -d /dev/nvme0n1p3 tpm2 '{"pcr_ids":"0,7","pcr_bank":"sha256"}'
# PCR 1 + 7: Hardware config + Secure Boot
sudo clevis luks bind -d /dev/nvme0n1p3 tpm2 '{"pcr_ids":"1,7","pcr_bank":"sha256"}'Always keep your passphrase keyslot (slot 0) intact. This is your recovery method if:
- TPM fails
- You need to access the disk from another machine
- PCR values change unexpectedly
No action needed — clevis and the tss-user hook are automatically included when initramfs is rebuilt.
May require re-binding clevis if PCR values change. You'll know because the system will fall back to password prompt.
# Remove clevis binding
sudo clevis luks unbind -d /dev/nvme0n1p3 -s 1
# Remove custom hook
sudo rm /etc/initramfs-tools/hooks/tss-user
# Rebuild initramfs
sudo update-initramfs -u -k allUbuntu 24.04's initramfs-tools doesn't support systemd-cryptsetup, which is required to use keys enrolled via systemd-cryptenroll. While you can enroll a TPM key with:
systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=7 /dev/nvme0n1p3And add tpm2-device=auto to /etc/crypttab, the initramfs will show:
cryptsetup: WARNING: dm_crypt-0: ignoring unknown option 'tpm2-device'
This is because Ubuntu's cryptroot scripts don't understand systemd-cryptsetup options. Solutions:
- Use Clevis (this guide)
- Replace initramfs-tools with Dracut (more invasive)
- Wait for Ubuntu to adopt UKI/systemd-boot natively
- Ubuntu Bug #1980018 — cryptsetup-initramfs TPM2 support
- Clevis GitHub — Official clevis documentation
- Ubuntu TPM FDE Discussion — Official Ubuntu discussion
Document created: December 2024 Tested on: Ubuntu 24.04.3 LTS with kernel 6.14.0-37-generic Hardware: TPM 2.0 (tpm_crb driver)