Modern Linux security architectures increasingly rely on Trusted Platform Module 2.0 (TPM2) chips to attest boot-chain integrity and seal disk encryption keys. While UEFI firmware and systemd measure boot phases, kernel command lines, and system credentials into designated Platform Configuration Registers (PCRs), file system identity and mount paths historically lacked cryptographic attestation. In systemd version 253 and newer (standard in Ubuntu 24.04 LTS Noble Numbat), the systemd-pcrfs tool (and its accompanying [email protected] unit) cryptographically measures file system identity, UUIDs, and mount paths directly into TPM2 PCR 15. For systems engineers and security auditors, this enables binding LUKS volumes and sensitive policies to verified file system mount states.
Architecture of TPM2 PCR Measurements and systemd-pcrfs
TPM2 Platform Configuration Registers store SHA-256 hashes representing measured boot events. Each PCR register serves a specific architectural role:
- PCR 0–7: Hardware firmware, UEFI binaries, Secure Boot policies, and boot loaders.
- PCR 11: Unified Kernel Image (UKI) components measured by
systemd-stub. - PCR 14: Machine identity measured by
systemd-pcrmachine. - PCR 15: Operating system volume measurements performed by
systemd-pcrfs.
Whenever a file system is mounted, systemd-pcrfs executes an extend operation on PCR 15. The extended hash incorporates three distinct structural components:
- The target mount path (e.g.,
/,/usr,/var). - The block device filesystem type (e.g.,
ext4,btrfs,xfs). - The unique Filesystem UUID and Volume Label.
If an attacker substitutes a root partition, clones a disk with a different UUID, or redirects mount targets via rogue initramfs scripts, the PCR 15 hash will diverge, automatically locking sealed cryptographic keys.
Verifying TPM2 and systemd-pcrfs in Ubuntu
Ensure that your Ubuntu system has an active TPM2 device and runs systemd 253 or later:
systemd --version
systemd-analyze security-tpm
Verify that the systemd-pcrfs binary is present and query its active service template:
/usr/lib/systemd/systemd-pcrfs --version
systemctl list-unit-files [email protected]
Reading Active Measurements in PCR 15
To inspect the current cryptographic state of PCR 15, use the TPM2 tools or systemd diagnostic utilities:
sudo systemd-creds has-tpm2
sudo tpm2_pcrread sha256:15
Before any file systems are mounted, PCR 15 contains an initial zero hash (0x000...). As systemd-fstab-generator and mount targets fire, the register state updates dynamically.
Enabling Automatic File System Measurements
File system measurements are instantiated per mount point using systemd’s templated service. To measure the root file system (sysroot) and /usr:
# Enable measurement for the root mount
sudo systemctl enable [email protected]
# Enable measurement for the /usr partition
sudo systemctl enable [email protected]
You can inspect the execution parameters of the unit file:
systemctl cat [email protected]
The unit confirms that systemd-pcrfs executes automatically after the designated mount target transitions to an active state.
Sealing LUKS Encryption Keys to Verified Mount States
The core practical application of systemd-pcrfs is binding encrypted secondary partitions or data volumes to PCR 15 using systemd-cryptenroll. This guarantees that disks cannot be decrypted if mounted on unauthorized devices or modified mount trees:
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=11+14+15 /dev/nvme0n1p3
In this policy:
- PCR 11: Verifies the kernel and initramfs integrity.
- PCR 14: Verifies the physical machine ID.
- PCR 15: Verifies that the correct root filesystem UUID and mount paths are active.
Auditing PCR 15 Event Logs in the Journal
To verify which specific file systems were measured during the previous boot sequence, query the systemd journal:
journalctl -b 0 -u "systemd-pcrfs*"
The log outputs confirmation entries detailing each extended hash:
systemd[1]: Starting File System PCR Measurement (/)...
systemd-pcrfs[412]: Successfully measured / (UUID=9b1e4c3a-..., type=ext4) into TPM2 PCR 15.
systemd[1]: Finished File System PCR Measurement (/).
By implementing systemd-pcrfs in Ubuntu, security administrators establish an unbroken, hardware-attested cryptographic link between physical storage volumes and running userspace mounts, providing resilient defense against physical disk tampering and offline supply-chain attacks.