Linux: Full Disk Encryption

From fit-PC wiki
Revision as of 10:35, 1 July 2019 by Denis (Talk | contribs) (Installation)

Jump to: navigation, search


The idea is to encrypt a partition with root filesystem using LUKS and store the keys in the TPM.
During boot user does not have to enter a decryption password, partition will be automatically decrypted using the keys from TPM.
It's a open-source alternative to Windows BitLocker.

  • LUKS (Linux Unified Key Setup) - is a full volume encryption feature, the standard for Linux hard disk encryption
  • TPM (Trusted Platform Module) - is dedicated micro-controller designed to secure hardware through integrated cryptographic keys

List of tested devices

The guide was tested on a system with the specs listed below, but should be easily adaptable.

  • Device: fitlet2
  • OS: Debian GNU/Linux testing (buster)
  • ISO: debian-buster-DI-rc2-amd64-netinst.iso
  • Kernel: 4.19.0-5-amd64
  • BIOS: 09/17/2018 American Megatrends Inc. FLT2.
  • TPM: Firmware based TPM 2.0 implementation (fTPM)


  • Follow the standard installation procedure - choose timezone, hostname, username, password etc.
  • In the "Partition disks" dialog you can choose automatic or manual partitioning scheme
    • Automatic - select "Guided - use entire disk and set up encrypted LVM"
      • Partitions scheme will be defined automatically
      • You will be asked to enter passphrase for encryption
    • Manual (advanced) , for example:
      • #1, size 200.0 MB, use as "EFI System Partition"
      • #2, size 300.0 MB, use as "EXT4 journaling file system", mount point /boot
      • #3, size 3.0 GB, use as "physical volume for encryption"
      • Go to the "Configuring encrypted volumes" and select partition #3 as device to be encrypted
      • You will be asked to enter passphrase for encryption
      • In the "Partition disks" find new appeared encrypted volume #1, use it as "EXT4 journaling file system", mount point /
  • Continue with package manager, software selection etc.
  • Disconnect the installation media and reboot
  • You will be asked for passphrase of encrypted disk, enter it manually, then boot process will continue
  • Login using previously selected username and password.
  • NOTE: The PATH definition in the /etc/profile should be fixed:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

export PATH

Automated Decryption

  • Clevis is a framework for automated decryption of data or automated unlocking of LUKS volumes.
$ su
$ apt install clevis-tpm2 clevis-luks clevis-dracut
  • Test the TPM encryption module, the following example encrypts the words “Hello World!” and writes them to test.txt. Give it a try!
$ echo Hello World! | clevis encrypt tpm2 '{}' > test.txt
$ cat test.txt
$ cat test.txt | clevis decrypt tpm2
Hello World!
  • Bind master key generated by TPM to the LUKS volume. For this there is a specific set of Platform Configuration Registers (PCR) called PCR7.
# Review information about the cryptographic setup of encrypted partition:
$ cryptsetup luksDump /dev/sda3

$ clevis luks bind -d /dev/sda3 tpm2 '{"pcr_ids":"7"}'
Enter existing LUKS password: ******

# Review information about the cryptographic setup again, check if the new key has been written to the LUKS volume:
$ cryptsetup luksDump /dev/sda3