How to Measure Machine Identity into TPM2 PCR 14 in Ubuntu Using systemd-pcrmachine

Modern Linux security architectures built around hardware Trusted Platform Module 2.0 (TPM2) chips rely on Platform Configuration Registers (PCRs) to record verifiable measurements of the boot chain. While firmware, the UEFI boot loader, and Unified Kernel Images (UKIs) are traditionally measured into PCRs 0 through 11, binding disk encryption keys to the physical operating system instance requires measuring operating system identity. In systemd version 253 and newer (standard in Ubuntu 24.04 LTS Noble Numbat), the systemd-pcrmachine utility cryptographically hashes the system machine identifier (/etc/machine-id) into TPM2 PCR 14 during early boot. For systems administrators and security engineers, this ensures that TPM-sealed LUKS disks cannot be unsealed if transplanted to a different machine.

Architecture of TPM2 PCR 14 and Machine Identity

In standard systemd-boot and TPM2 integration designs, PCR registers fulfill distinct roles:

  • PCR 0–7: Hardware firmware, UEFI binaries, and Secure Boot certificates.
  • PCR 11: UKI components (kernel binary, initramfs, embedded cmdline) measured by systemd-stub.
  • PCR 14: Operating system machine identity measured by systemd-pcrmachine.
  • PCR 15: File system volume identity and mount paths measured by systemd-pcrfs.

When systemd-pcrmachine.service executes during early boot, it reads the 128-bit hexadecimal machine identity stored in /etc/machine-id, calculates its cryptographic hash, and performs a TPM2 extend operation on PCR 14. Because every Linux installation generates a unique machine-id upon deployment, this binds the TPM state directly to the operating system installation.

Verifying TPM2 and systemd-pcrmachine in Ubuntu

Confirm that your Ubuntu system has an active TPM2 device and runs a compatible systemd version:

systemd --version
sudo systemd-creds has-tpm2

Query the presence and status of the systemd-pcrmachine service unit:

systemctl status systemd-pcrmachine.service

You can inspect the execution parameters of the unit file:

systemctl cat systemd-pcrmachine.service

The unit confirms that systemd-pcrmachine executes automatically during early startup before basic targets and storage services initialize.

Reading the PCR 14 Measurement via TPM2 Tools

To inspect the current cryptographic hash stored inside PCR 14, query the TPM using tpm2_pcrread:

sudo tpm2_pcrread sha256:14

Before systemd-pcrmachine executes, PCR 14 holds an initial empty state (0x000...). Following execution, it contains the SHA-256 digest resulting from extending the register with the system’s machine identifier string.

Manual Verification of the Machine Measurement Hash

You can independently verify that PCR 14 matches the extended hash of your machine ID. View your system machine identity:

cat /etc/machine-id

Simulate the TPM2 extend operation in userspace using OpenSSL:

# Calculate SHA-256 of the machine-id
MACHINE_HASH=$(cat /etc/machine-id | tr -d '\n' | openssl dgst -sha256 -binary | xxd -p -c 32)
echo "Machine ID Hash: $MACHINE_HASH"

When the TPM extends a register starting from zero, the resulting digest matches extending the initial 32 zero bytes with the hash of the machine-id payload.

Binding LUKS Encryption Keys to PCR 14

The primary security use case for systemd-pcrmachine is binding Full Disk Encryption (LUKS2) keys to PCR 14 alongside kernel measurements (PCR 11). This ensures automatic disk unlocking occurs only when booted on the specific physical or virtual machine holding that identity:

sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=11+14 /dev/nvme0n1p3

Under this security policy:

  • If an attacker steals the encrypted NVMe drive and attaches it to another computer, PCR 14 will not match, blocking automatic decryption.
  • If an attacker boots a live recovery ISO or alternate OS kernel on the same machine, PCR 11 will diverge, preserving data confidentiality.

Auditing systemd-pcrmachine Execution in the Journal

To confirm that the machine identity was successfully measured during the most recent system boot, inspect the systemd journal:

journalctl -b 0 -u systemd-pcrmachine.service

The journal logs confirmation of the extend transaction:

systemd[1]: Starting TPM2 PCR Machine ID Measurement...
systemd-pcrmachine[280]: Successfully extended TPM2 PCR 14 with machine ID.
systemd[1]: Finished TPM2 PCR Machine ID Measurement.

By enforcing machine-level measurements into TPM2 PCR 14 via systemd-pcrmachine, Ubuntu administrators establish a robust cryptographic hardware anchor, guaranteeing that sensitive storage volumes remain protected against physical theft and offline drive transplantation.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.