This post is a record of setting up full disk encryption on Proxmox VE 9. Compared with the earlier article, this time we’ll set up several automatic unlock methods such as TPM2 and a USB key, which suits edge node deployments that need encrypted storage.

Note that this post includes a lot of Mermaid diagrams, so it may load slowly.

Deployment Plan

The overall installation flow:

  1. Create and configure the LUKS encrypted partition
  2. Initialize the LVM volume group and logical volumes
  3. Install a Debian 13 base system with debootstrap
  4. Configure GRUB boot and fstab mounts
  5. Deploy Proxmox VE on top of the encrypted system

The focus of this deployment is configuring several LUKS unlock methods (passphrase, TPM2, USB key) for unattended automatic unlock, so an encrypted node can restore its services after a power loss and reboot.

How It Works

How LUKS Encryption Works

LUKS (Linux Unified Key Setup) is the disk encryption standard on Linux and defines a platform-independent on-disk format. Its core design separates the encryption key from the user passphrase with a master key and key slot architecture.

Encryption Architecture

LUKS has two layers:

  1. Master key layer: the key that actually encrypts disk data, usually a 256-bit or 512-bit random number. It is generated at random when the LUKS partition is created and never changes. All disk data is encrypted with this master key using algorithms such as AES-XTS.

  2. Key slot layer: LUKS supports up to 8 key slots (LUKS1) or 32 (LUKS2), and each slot can hold a copy of the master key encrypted in a different way. A user can decrypt any one slot with a passphrase, key file, TPM, smart card, or other method, and unlock the whole disk.

LUKS Architecture Diagram

graph TB
    subgraph "LUKS Partition Structure"
        A[LUKS Header<br/>Metadata Area] --> B[Key Slot Area<br/>Key Slots Area]
        B --> C[Encrypted Data Area<br/>Encrypted Data]
    end
    
    subgraph "Key Slot Details - Up to 32"
        B --> D[Slot 0: Passphrase]
        B --> E[Slot 1: USB Key]
        B --> F[Slot 2: TPM2]
        B --> G[Slot 3-31: ...]
    end
    
    subgraph "Encryption Layers"
        H[User Passphrase/Token] -->|Decrypt| I[Encrypted Master Key<br/>in the Key Slot]
        I -->|Decrypt| J[Master Key<br/>512 bits]
        J -->|AES-XTS| C
    end
    

How it works:

sequenceDiagram
    participant U as User
    participant L as LUKS
    participant S as Key Slot
    participant M as Master Key
    participant D as Encrypted Disk
    
    Note over U,D: Initialization phase
    U->>L: luksFormat /dev/sda3
    L->>M: Generate a random master key (512 bits)
    U->>L: Enter the passphrase
    L->>S: Encrypt a copy of the master key with the passphrase
    S-->>L: Store in slot 0
    M->>D: Encrypt all data with the master key
    
    Note over U,D: Add a new unlock method
    U->>L: luksAddKey (TPM/USB Key)
    L->>S: Read the master key (existing passphrase required)
    L->>S: Encrypt a copy of the master key with the new method
    S-->>L: Store in a new slot
    
    Note over U,D: Unlock phase
    U->>L: cryptsetup open
    L->>S: Try to decrypt a key slot
    S->>M: Return the master key
    M->>D: Decrypt data with the master key
    D-->>U: Access plaintext data

The advantages of this design:

  • Changing an unlock method (such as changing the passphrase) only requires re-encrypting the master key copy in that slot, not re-encrypting the whole disk
  • Several unlock methods can coexist, which gives a lot of flexibility
  • Even if one slot’s key leaks, the disk data stays safe as long as you delete that slot promptly and change the other unlock methods

LUKS2 Improvements

LUKS2 brings a number of improvements over LUKS1:

  • More flexible header structure: redundant metadata storage improves fault tolerance
  • More key slots: from 8 to 32
  • Token support: native support for hardware tokens such as TPM2 and FIDO2
  • Argon2 key derivation: uses the stronger Argon2id algorithm instead of PBKDF2, which resists brute force better
  • Online re-encryption: change the encryption algorithm without unmounting the partition

How TPM2 Unlock Works

A TPM (Trusted Platform Module) is a dedicated security chip that provides hardware-level key storage and cryptographic operations. TPM2 unlocks LUKS as follows:

TPM2 Architecture Diagram

graph LR
    subgraph "System Components"
        A[UEFI Firmware] --> B[GRUB]
        B --> C[Kernel]
        C --> D[initramfs]
    end
    
    subgraph "TPM Chip"
        E[PCR Registers]
        F[Key Storage]
        G[Crypto Engine]
    end
    
    subgraph "LUKS Partition"
        H[Token: TPM2 Blob]
        I[Key Slot 2]
        J[Encrypted Data]
    end
    
    A -.Measure.-> E
    B -.Measure.-> E
    D -->|Request unseal| G
    E -->|Verify PCR| G
    G -->|Unseal key| D
    D -->|Use key| I
    I -->|Decrypt master key| J
    

PCR Measurement Chain

sequenceDiagram
    participant UEFI as UEFI Firmware
    participant PCR0 as PCR 0
    participant PCR7 as PCR 7
    participant GRUB as GRUB
    participant Kernel as Kernel
    participant TPM as TPM Chip
    
    Note over UEFI,TPM: Boot measurement phase
    UEFI->>PCR0: Measure firmware code hash
    UEFI->>PCR7: Measure Secure Boot state
    UEFI->>GRUB: Load GRUB
    GRUB->>Kernel: Load the kernel
    Kernel->>TPM: Request key unseal
    TPM->>PCR0: Read current value
    TPM->>PCR7: Read current value
    
    alt PCR values match
        TPM-->>Kernel: [Success] Return the unsealed key
        Kernel->>Kernel: Unlock the LUKS partition
    else PCR values do not match
        TPM-->>Kernel: [Failure] Refuse to unseal
        Kernel->>Kernel: Fall back to another unlock method
    end

Enrollment Phase

When you enroll the TPM with systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/sda3:

  1. Generate a random key: systemd-cryptenroll generates a random key that will be added to one of the LUKS key slots
  2. TPM seal operation: the random key is encrypted with the TPM’s seal function and bound to specific PCR (Platform Configuration Register) values
  3. Store the encrypted key: the encrypted key (a blob) is stored in a LUKS2 token, which you can inspect with cryptsetup luksDump

TPM enrollment flowchart:

flowchart TD
    A[Run systemd-cryptenroll] --> B[Generate a random key]
    B --> C[Read current PCR 0, 7 values]
    C --> D{TPM available?}
    
    D -->|Yes| E[TPM Seal operation]
    D -->|No| F[Error: TPM unavailable]
    
    E --> G[Bind to PCR 0+7]
    G --> H[Generate TPM blob]
    H --> I[Add the key to a LUKS slot]
    I --> J[Store the blob in a LUKS token]
    J --> K["Enrollment complete"]
    
    F --> L[Check TPM hardware/driver]
    

What PCRs Do

PCRs (Platform Configuration Registers) are a set of registers in the TPM that record measurements (hashes) from each stage of the boot process. Commonly used PCRs:

PCR What it measures Purpose
PCR 0 BIOS/UEFI firmware code Detect firmware tampering
PCR 1 BIOS/UEFI configuration Detect BIOS setting changes
PCR 2 UEFI drivers and applications Detect changes in boot components
PCR 4 Bootloader (GRUB) Detect bootloader tampering
PCR 7 Secure Boot state Detect Secure Boot policy changes

Using --tpm2-pcrs=0+7 binds the key to the current PCR 0 and PCR 7 values. The TPM only unseals the key when those PCR values at boot match the values at enrollment.

How PCR values are computed:

PCR value = Hash(Hash(Hash(initial value, measurement 1), measurement 2), measurement 3, ...)

For example, PCR 0:
Initial value: 0x0000...
Measurement 1: Hash(UEFI firmware code)
PCR 0 = Hash(0x0000..., measurement 1)

This chained hashing ensures that a change at any stage produces a different final PCR value.

Unlock Phase

At boot:

  1. initramfs detection: systemd-cryptsetup detects the TPM2 token on the LUKS partition
  2. Read PCR values: read the current PCR 0 and 7 values
  3. Request unseal: send an unseal request to the TPM along with the current PCR values
  4. PCR verification: the TPM compares the current PCR values with those at enrollment
  5. Unseal the key: if the PCR values match, the TPM unseals and returns the random key
  6. Unlock LUKS: use the unsealed key to unlock the LUKS partition

Security Properties

TPM2 unlock provides the following guarantees:

  • Hardware binding: the key is stored in the TPM chip and cannot be read directly by software
  • Boot state verification: PCRs ensure the firmware and bootloader have not been tampered with
  • Protection against malicious boot: booting from another device or modifying the firmware changes the PCR values, so the TPM refuses to unseal
  • Passphrase-free unlock: automatic unlock in a trusted state without manual input

Limitations of TPM Unlock

  • Sensitive to firmware updates: a BIOS/UEFI update changes PCR 0, so automatic unlock stops working until you re-enroll
  • Hardware dependency: the motherboard must have a TPM 2.0 chip
  • Secure Boot requirement: UEFI Secure Boot usually needs to be enabled for full effect

How USB Key Unlock Works

USB key unlock is a key-file-based method. The principle is relatively simple but just as effective.

USB Key Workflow

flowchart TD
    subgraph "Preparation Phase"
        A[Format the USB device] --> B[Generate a random key file<br/>4 KB of random data]
        B --> C[Add it to a LUKS key slot]
        C --> D[Copy the key to the USB key]
    end
    
    subgraph "Boot and Unlock Phase"
        E[System boots] --> F[initramfs loads]
        F --> G{Detect USB device}
        G -->|USB-KEY found| H[Mount the USB device]
        G -->|Not found| I[Wait 3 seconds or time out]
        I --> G
        H --> J[Read the key file]
        J --> K[Unlock LUKS with the key]
        K --> L[Unmount the USB device]
        L --> M[Continue booting]
    end
    

Key File Layout

flowchart TB
    subgraph USB["USB Key Device"]
        A["/dev/sdb"]
        A --> B["Partition Table"]
        B --> C["/dev/sdb1<br/>ext4 filesystem<br/>Label: USB-KEY"]
    end
    
    subgraph FILES["File Structure"]
        C --> D["/luks_usb.key<br/>4096 bytes<br/>random data"]
        C --> E["Other files<br/>(optional)"]
    end
    
    subgraph LUKS["LUKS Key Slot"]
        F["Slot 1"] --> G["Master key encrypted<br/>with the key file"]
    end
    
    D -.Unlock.-> F
    

Creation Phase

  1. Generate a random key file: use dd if=/dev/urandom of=/tmp/luks_usb.key bs=4096 count=1 to generate a 4 KB random key file
  2. Add it to LUKS: use cryptsetup luksAddKey /dev/sda3 /tmp/luks_usb.key to add the key file to a new key slot
  3. Store it on the USB drive: copy the key file to a specific path on the USB device, such as /mnt/usbkey/luks_usb.key

Detailed flow:

sequenceDiagram
    participant Admin as Administrator
    participant USB as USB Key
    participant LUKS as LUKS Partition
    participant Slot as Key Slot 1
    
    Note over Admin,Slot: Initialize the USB key
    Admin->>USB: mkfs.ext4 -L 'USB-KEY'
    Admin->>Admin: dd if=/dev/urandom of=key
    
    Note over Admin,Slot: Add it to LUKS
    Admin->>LUKS: luksAddKey /dev/sda3 key
    LUKS->>Admin: Request the existing passphrase
    Admin->>LUKS: Enter the passphrase for verification
    LUKS->>Slot: Encrypt the master key with the key file
    Slot-->>LUKS: Storage complete
    
    Note over Admin,Slot: Save the key
    Admin->>USB: Mount the USB key
    Admin->>USB: Copy the key file
    Admin->>USB: chmod 400 luks_usb.key
    Admin->>USB: Unmount and store it safely

Unlock Phase

During the initramfs stage:

  1. Detect the USB device: at boot, look for the USB device (by UUID or LABEL)
  2. Mount the USB drive: mount the USB device at a temporary path
  3. Read the key file: read the contents of the key file from the USB drive
  4. Unlock LUKS: use the key file contents as the passphrase to unlock the LUKS partition
  5. Unmount the USB drive: unmount it after a successful unlock

Configuration

Automatic LUKS unlock is configured mainly through /etc/crypttab. The initramfs reads this file at boot and decides how to unlock encrypted devices.

/etc/crypttab in Detail

Basic format:

<target> <source> <key-file> <options>

A real example:

cryptlvm UUID=558ed1f4-cc23-4d7d-8b14-a2b2de3d0882 none luks,initramfs,discard

Fields:

  1. target: cryptlvm

    • The device mapper name after unlock
    • Creates the /dev/mapper/cryptlvm device
    • This name is referenced in /etc/fstab and the LVM configuration
    • Naming: prefer a descriptive name with only letters, digits, underscores, and hyphens
  2. source: UUID=558ed1f4-cc23-4d7d-8b14-a2b2de3d0882

    • The identifier of the encrypted device
    • Prefer UUID= over a device path such as /dev/sda3
    • A UUID survives repartitioning and changes in device order
    • Accepted formats:
      • UUID=<uuid> - recommended, most stable
      • PARTUUID=<partuuid> - GPT partition UUID
      • LABEL=<label> - device label
      • /dev/disk/by-id/<disk-id> - disk ID
      • /dev/sda3 - not recommended, may change

    How to find the UUID:

    # Method 1: use blkid
    blkid /dev/sda3
    
    # Method 2: use lsblk
    lsblk -f /dev/sda3
    
    # Method 3: look in /dev/disk/by-uuid/
    ls -la /dev/disk/by-uuid/
    
  3. key-file: none

    • Path to the key file used for automatic unlock
    • none means no key file; other unlock methods (passphrase, TPM token) are used
    • With a USB key this still says none, because a custom script handles USB unlock
    • Fixed key file example: /root/keyfile.key - unlock automatically with that file
    • Note: the key file must be accessible when the initramfs is built
  4. options: luks,initramfs,discard

    This is the most important part. Separate multiple options with commas and no spaces.

    Common options:

    • luks - required

      • Marks the device as LUKS-encrypted
      • cryptsetup handles it with luksOpen
      • LUKS1 or LUKS2 is detected automatically
    • initramfs - very important

      • Includes this entry in the initramfs
      • Without it, the device is only unlocked after the system has fully booted
      • Required for an encrypted root partition
      • Affects update-initramfs behavior
    • discard - SSD optimization

      • Enables TRIM so the SSD can optimize storage
      • Performance: extends SSD life and improves write performance
      • Security warning: may leak filesystem usage information
      • Use it only on SSDs; HDDs ignore it
      • Supported by default in LUKS2; LUKS1 requires enabling it explicitly
    • nofail - optional, improves fault tolerance

      • The system keeps booting even if unlock fails
      • Suitable for non-critical partitions such as data disks
      • Don’t use it on the root partition, or the system won’t boot
    • timeout=<seconds> - optional

      • Sets how long to wait for unlock
      • Example: timeout=90 - wait 90 seconds
      • After the timeout, behavior depends on other options (such as nofail)
    • tries=<count> - optional

      • Number of passphrase attempts
      • Default: 3
      • Example: tries=5 - allow 5 passphrase attempts
    • keyfile-timeout=<seconds> - optional

      • How long to wait for the key file to become available
      • For external storage such as a USB key
      • Example: keyfile-timeout=10
    • noauto - optional

      • Don’t unlock automatically at boot
      • Requires a manual cryptsetup open
      • For encrypted partitions mounted on demand
    • readonly - optional

      • Open the encrypted device read-only
      • For data protection scenarios

More advanced examples:

# Example 1: data partition unlocked with a key file
data UUID=12345678-... /root/data.key luks,discard,nofail

# Example 2: non-critical encrypted partition, failures allowed
backup UUID=abcdef01-... none luks,nofail,timeout=30

# Example 3: external encrypted USB disk, wait for the device
usbdrive UUID=fedcba98-... none luks,nofail,timeout=60,tries=3

# Example 4: read-only encrypted partition
archive UUID=11111111-... none luks,readonly,nofail
Verifying the Configuration

After editing /etc/crypttab, run these checks:

# 1. Check for syntax errors
cat /etc/crypttab

# 2. Verify the UUID
blkid | grep 558ed1f4

# 3. Test the configuration (without unlocking)
cryptdisks_start --test cryptlvm

# 4. Update the initramfs
update-initramfs -u -k all

# 5. Verify that crypttab is included in the initramfs
lsinitramfs /boot/initrd.img-$(uname -r) | grep crypttab
Working with Custom Scripts

In this setup:

  • /etc/crypttab defines the basic unlock configuration
  • The /etc/initramfs-tools/scripts/local-top/cryptroot-unlock script implements the actual unlock logic
  • TPM token and USB key unlock are handled by the script and don’t show up in crypttab
  • crypttab mainly tells the initramfs which devices need unlocking
FAQ

Q: Why does USB key unlock still work when key-file is none?

A: Because a custom cryptroot-unlock script handles USB key unlock. crypttab only defines the device; the script implements the unlock logic.

Q: What do I need to do after editing crypttab?

A: You must run update-initramfs -u -k all to regenerate the initramfs. Otherwise the change has no effect.

Q: Is the discard option safe?

A: discard can leak filesystem usage patterns (which blocks are in use) but not data contents. If your threat model includes preventing usage-pattern analysis, disable it. In most cases the SSD performance benefit outweighs the risk.

Security Considerations

USB key unlock security depends on:

  • Physical security: keep the USB key safe; losing it means losing your unlock path
  • Combining methods: combine it with a passphrase to require “something you have (the USB key) + something you know (the passphrase)”
  • Key file quality: the key file should be high-quality random data, at least 512 bytes
  • Filesystem encryption: ideally encrypt the USB key itself so it can’t be cloned

Threat model:

graph TD
    A[USB Key Security Threats] --> B[Physical loss]
    A --> C[Cloning]
    A --> D[Tampering]
    
    B --> E[Solution:<br/>Backup + timely revocation]
    C --> F[Solution:<br/>Encrypt the USB key itself]
    D --> G[Solution:<br/>Checksum verification]
    
    H[Best practices] --> I[USB + passphrase]
    H --> J[Rotate keys regularly]
    H --> K[Multiple backups]
    

Multi-Factor Unlock Strategies

LUKS2 supports several unlock methods at once, which allows flexible security policies:

Comparing Unlock Methods

graph TB
    subgraph "Unlock Method Comparison"
        A[Passphrase Unlock]
        B[TPM2 Unlock]
        C[USB Key Unlock]
    end
    
    A --> A1[Pros: always available<br/>no extra hardware]
    A --> A2[Cons: manual input required<br/>can be forgotten]
    
    B --> B1[Pros: fully automatic<br/>hardware-bound security]
    B --> B2[Cons: sensitive to firmware updates<br/>requires TPM hardware]
    
    C --> C1[Pros: physical token<br/>relatively flexible]
    C --> C2[Cons: can be lost<br/>can be cloned]
    

1. Single-Factor Unlock (Any One Method)

Example configuration:

  • Key slot 0: user passphrase
  • Key slot 1: USB key
  • Key slot 2: TPM2

Any one method can unlock independently, which suits different situations:

  • Normal boot: TPM2 auto-unlock
  • TPM failure: unlock with the USB key
  • Recovery: unlock with the passphrase

Unlock priority flow:

flowchart LR
    A[System boots] --> B{Try TPM2}
    B -->|Success| Z["Boot complete"]
    B -->|Failure| C{Try USB Key}
    C -->|Success| Z
    C -->|Failure| D{Passphrase entry}
    D -->|Correct| Z
    D -->|Incorrect| E["Retry or recovery mode"]
    

2. Combining Factors (Experimental)

LUKS2.1+ supports policy combinations, for example requiring both TPM2 AND the USB key to unlock, which raises the security level.

Two-factor example:

flowchart TD
    A[Boot the system] --> B{TPM2 verification}
    B -->|Failure| F["Access denied"]
    B -->|Pass| C{USB Key verification}
    C -->|Failure| F
    C -->|Pass| D["Unlock succeeded"]
    
    E[Optional: passphrase as<br/>emergency recovery] -.Fallback path.-> D
    

3. Priority Strategy

The initramfs can define the order of unlock attempts:

  1. Try TPM2 first (most convenient)
  2. If TPM fails, try the USB key
  3. If both fail, prompt for the passphrase (the last fallback)

The full multi-layer unlock architecture:

flowchart TB
    subgraph layer1["Layer 1 - Automatic Unlock"]
        A[TPM2 auto-unlock] --> A1{PCR verification}
        A1 -->|Pass| SUCCESS["Unlock succeeded"]
        A1 -->|Failure| B
    end
    
    subgraph layer2["Layer 2 - Physical Token"]
        B[USB Key unlock] --> B1{Detect USB}
        B1 -->|Found| SUCCESS
        B1 -->|Not found| C
    end
    
    subgraph layer3["Layer 3 - Manual Intervention"]
        C[Passphrase unlock] --> C1{Passphrase verification}
        C1 -->|Correct| SUCCESS
        C1 -->|Wrong 3 times| D[Recovery Shell]
    end
    
    subgraph layer4["Layer 4 - Emergency Recovery"]
        D --> E[Live CD repair]
        E --> F[Administrator intervention]
    end
    

Real-World Scenarios

Scenario Comparison Matrix

Scenario Primary unlock Backup Emergency recovery Suitability
Edge node TPM2 auto USB Key Passphrase + remote unlock ★★★★★
Personal workstation Passphrase TPM2 USB Key ★★★★
Data center TPM2 Network unlock Passphrase ★★★★★
Laptop Passphrase TPM2 USB Key ★★★
High-security environment TPM2 + USB + passphrase Admin key Multi-person authorization ★★★★★

Automatic Unlock on Edge Nodes

For an encrypted node in an edge data center:

graph LR
    subgraph "Normal Operation"
        A[Power loss] --> B[Automatic reboot]
        B --> C[TPM2 auto-unlock]
        C --> D[Services restored]
    end
    
    subgraph "TPM Failure Scenario"
        E[BIOS update] --> F[TPM fails]
        F --> G[USB Key unlock]
        G --> H[Services restored]
    end
    
    subgraph "Total Failure"
        I[Hardware failure] --> J[Remote SSH unlock]
        J --> K[Or on-site passphrase entry]
    end
    

Configuration strategy:

  • Primary: TPM2 auto-unlock, no manual intervention after a reboot
  • Backup: a USB key for when the TPM fails
  • Emergency: keep passphrase unlock for remote rescue

Personal Workstation

For a personal workstation:

mindmap
    root((Personal Workstation<br/>Encryption Strategy))
        Daily use
            Passphrase unlock
            Simple and direct
            Familiar input
        Convenience
            TPM2 optional
            Fast boot
            Auto-unlock
        Data recovery
            USB Key backup
            Stored in a safe place
            Passphrase written down

Configuration strategy:

  • Primary: passphrase unlock, keep it simple
  • Convenience: TPM2 auto-unlock (optional)
  • Recovery: a USB key as a fallback if you forget the passphrase

High-Security Environments

For environments with high security requirements:

sequenceDiagram
    participant U as User
    participant T as TPM2
    participant K as USB Key
    participant P as Passphrase System
    participant S as System
    
    Note over U,S: Multi-factor verification flow
    
    U->>T: Boot the system
    T->>T: PCR verification
    T-->>S: [Success] TPM passed
    
    S->>K: Detect the USB key
    K-->>S: [Success] USB passed
    
    S->>U: Request a passphrase
    U->>P: Enter the passphrase
    P->>P: Verify passphrase strength
    P-->>S: [Success] Passphrase passed
    
    S->>S: All checks passed
    S-->>U: System unlocked

Configuration strategy:

  • Multiple factors: require TPM2 + USB key + passphrase
  • Regular rotation: change the passphrase and regenerate the USB key periodically
  • Audit trail: log every unlock attempt

This flexible, layered unlock mechanism lets LUKS fit everything from a personal desktop to an enterprise data center, balancing security and convenience.

System Boot Flow

To make the boot process of an encrypted system easier to follow, here is the complete flow:

flowchart TD
    A[UEFI firmware starts] --> B[Load the GRUB bootloader]
    B --> C[Load the kernel and initramfs]
    C --> D[initramfs environment starts]
    D --> E[Run /scripts/local-top/cryptroot-unlock]
    
    E --> F{Is the device already unlocked?}
    F -->|Already unlocked| Z[System ready - login screen]
    F -->|Not unlocked| G[Start the unlock process]
    
    G --> H{Step 1: Try TPM token unlock}
    
    H -->|TPM device found| I[Run cryptsetup open --token-only]
    H -->|No TPM device| M
    
    I --> J{TPM unlock result}
    J -->|Success| K[Create /dev/mapper/cryptlvm]
    J -->|Failure| L[Log TPM unlock failure]
    
    L --> M{Step 2: Try USB Key unlock}
    
    M --> N[Wait for USB device - udevadm settle]
    N --> O{USB-KEY found within 30 seconds?}
    
    O -->|USB-KEY found| P[Mount /dev/disk/by-label/USB-KEY]
    O -->|30-second timeout| U
    
    P --> Q{Does the key file exist?}
    Q -->|luks_usb.key found| R[Run cryptsetup luksOpen --key-file]
    Q -->|File not found| S[Unmount USB]
    
    R --> T{USB Key unlock result}
    T -->|Success| K
    T -->|Failure| S
    
    S --> U[Log USB Key unlock failure]
    U --> V{Step 3: systemd passphrase prompt}
    
    V --> W[systemd-cryptsetup requests a passphrase]
    W --> X{User enters the passphrase}
    X -->|Correct passphrase| K
    X -->|Wrong passphrase| Y[Retry or time out into a recovery shell]
    
    Y --> X
    
    K --> AA[Activate LVM volume group pve]
    AA --> AB[Mount the root filesystem /dev/pve/root]
    AB --> AC[Mount /boot and /boot/efi]
    AC --> AD[Switch to the real root]
    AD --> AE[Start systemd init]
    AE --> AF[Start system services]
    AF --> Z
    

Boot Process in Detail

Stage 1: UEFI boot (PCR 0 and 7 measurements)

  1. The UEFI firmware initializes the hardware and measures itself into PCR 0
  2. If Secure Boot is enabled, the relevant state is recorded in PCR 7
  3. UEFI loads the GRUB bootloader

Stage 2: GRUB loading (PCR 2 and 4 measurements)

  1. GRUB reads /boot/grub/grub.cfg
  2. It loads the Linux kernel into memory
  3. It loads the initramfs (which contains the custom unlock scripts)

Stage 3: initramfs environment setup

  1. After the kernel starts, it runs /init from the initramfs
  2. It loads the necessary kernel modules (USB, TPM, encryption)
  3. It runs /scripts/local-top/cryptroot-unlock

Stage 4: Unlock attempts in priority order

With your /etc/initramfs-tools/scripts/local-top/cryptroot-unlock script, the flow is:

Step 1 - TPM2 token unlock (highest priority):

# Script logic:
if [ -e /dev/tpm0 ] || [ -e /dev/tpmrm0 ]; then
    # TPM device detected
    cryptsetup open --token-only /dev/disk/by-uuid/558ed1f4... cryptlvm
    if [ $? -eq 0 ]; then
        # Unlock succeeded, exit immediately
        exit 0
    fi
fi

How it works:

  1. Check whether /dev/tpm0 or /dev/tpmrm0 exists
  2. Try to unlock with the TPM2 token using cryptsetup --token-only
  3. The TPM chip verifies that the current PCR 0+7 values match those at enrollment
  4. If they match, the TPM unseals the key and unlocks automatically ✅
  5. If they don’t (for example after a BIOS update), the TPM refuses to unseal ❌

Step 2 - USB Key unlock:

# Script logic:
udevadm settle --timeout=10  # Wait for devices to settle

for i in $(seq 1 30); do
    if [ -e "/dev/disk/by-label/$USB_LABEL" ]; then
        # USB key found
        mount -t ext4 -o ro "/dev/disk/by-label/$USB_LABEL" /tmp/usbkey
        if [ -f "/tmp/usbkey/$KEYFILE" ]; then
            cryptsetup luksOpen ... --key-file "/tmp/usbkey/$KEYFILE"
            # Unlock succeeded, clean up and exit
            umount /tmp/usbkey
            exit 0
        fi
        umount /tmp/usbkey
    fi
    sleep 1  # Check once per second, up to 30 seconds
done

How it works:

  1. Run udevadm settle to wait for device enumeration
  2. Poll for 30 seconds, looking once per second for a device labeled USB-KEY
  3. When found, mount it read-only
  4. Check whether the luks_usb.key key file exists
  5. Unlock with cryptsetup luksOpen and the key file ✅
  6. Unmount the USB key and exit on success

Step 3 - Passphrase unlock (fallback):

# The script returns exit 0 when it finishes
# systemd-cryptsetup takes over and prompts for the passphrase

How it works:

  1. If the first two methods fail, the script exits normally
  2. systemd’s [email protected] continues
  3. It shows a passphrase prompt on the console:
    Please unlock disk cryptlvm:
    
  4. The user enters the passphrase for verification
  5. A correct passphrase unlocks ✅; a wrong one retries
  6. After several failures it drops into an emergency shell

Stage 5: Mount the real root filesystem

  1. LUKS unlock succeeds and creates /dev/mapper/cryptlvm
  2. LVM activates the pve volume group and its logical volumes
  3. Mount /dev/pve/root at /sysroot
  4. Mount /dev/sda1 at /sysroot/boot
  5. Mount /dev/sda2 at /sysroot/boot/efi

Stage 6: Switch to the real system

  1. switch_root switches to /sysroot
  2. The initramfs environment is torn down
  3. systemd (PID 1) starts on the real system

Stage 7: System services start

  1. systemd starts services in dependency order
  2. Networking, SSH, Proxmox VE, and other services start
  3. The system becomes usable

Key Timings (Reference)

Stage Time Notes
UEFI initialization 2-5 seconds Hardware dependent
GRUB loading 0.5 seconds Nearly instant
Kernel loading 1-2 seconds
TPM2 token unlock 0.5-1 seconds PCR verification is fast
USB Key detection + unlock 3-10 seconds Waits for USB enumeration, 30-second timeout
Passphrase unlock N/A Waits for user input
LVM activation 0.5 seconds
Root filesystem mount 0.5-1 seconds Faster on SSD
systemd startup 5-10 seconds Depends on the number of services

Total boot time:

  • TPM2 auto-unlock: about 10-20 seconds
  • USB Key unlock: about 15-25 seconds
  • Passphrase unlock: depends on typing speed

Failover Logic

flowchart LR
    A[TPM2 token unlock] -->|Success| E[System boots]
    A -->|Failure or no TPM| B[USB Key unlock]
    B -->|Success| E
    B -->|Failure or timeout| C[Passphrase prompt]
    C -->|Correct passphrase| E
    C -->|Wrong passphrase or timeout| D[Enter Emergency Shell]
    D -->|Manual repair| E

This layered failover keeps the system unlockable in a range of situations:

  • Normal: TPM2 auto-unlock, no manual intervention
  • TPM failure: fall back to the USB key or passphrase
  • Total failure: drop into a recovery shell where an administrator can repair it manually

Deploying the Debian 13 Base System

PVE 9 is based on Debian 13 “Trixie”, so we first deploy an encrypted Debian 13 system and then install Proxmox VE on top.

Preparing the Live CD USB Drive

First, create a Debian 13 Live CD USB drive.

Download the ISO:

wget -c https://mirrors.tuna.tsinghua.edu.cn/debian-cd/current-live/amd64/iso-hybrid/debian-live-13.1.0-amd64-standard.iso

Write it to the USB device (replace /dev/sdX with your USB device):

dd if=debian-live-13.1.0-amd64-standard.iso of=/dev/sdX bs=4M status=progress

Configuring the Live Environment

Boot the target machine from the USB drive, then set up SSH for remote access:

apt install -y ssh
systemctl start ssh
passwd user

Connect over SSH from another machine (much easier to work with):

ssh user@<target-host-ip>
sudo -i

Checking for a TPM Device

Check whether the system has a TPM 2.0 chip:

dmesg | grep -i tpm
ls -l /dev/tpm*

If you see /dev/tpm0 and /dev/tpmrm0, the TPM device is available.

Installing the Required Tools

apt update
apt install debootstrap dosfstools cryptsetup lvm2 tpm2-tools gdisk -y

Verify TPM functionality:

tpm2_getcap properties-fixed
systemd-cryptenroll --tpm2-device=list

Preparing the USB Key (Optional)

If you want a USB key as a backup unlock method, prepare a USB drive:

Format the USB drive:

mkfs.ext4 -L 'USB-KEY' /dev/sdb

Generate a random key file:

dd if=/dev/urandom of=/tmp/luks_usb.key bs=4096 count=1

Copy the key file to the USB drive:

mkdir /mnt/usbkey
mount /dev/disk/by-label/USB-KEY /mnt/usbkey
cp /tmp/luks_usb.key /mnt/usbkey/
umount /mnt/usbkey

Disk Partitioning Scheme

The partition layout for this deployment:

Partition Size Filesystem Mount point Notes
/dev/sda1 500M ext4 /boot Boot partition (unencrypted)
/dev/sda2 64M vfat /boot/efi EFI partition
/dev/sda3 Remaining space - - LUKS encrypted container
/dev/mapper/cryptlvm - - - LVM physical volume
/dev/pve/root 20G ext4 / Root filesystem
/dev/pve/swap 4G swap - Swap partition

Creating the Partitions

Create the GPT partition table with fdisk:

fdisk /dev/sda

Run these steps in the fdisk interactive prompt:

fdisk /dev/sda

Run these steps in the fdisk interactive prompt:

Welcome to fdisk (util-linux 2.41).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sda: 32 GiB, 34359738368 bytes, 67108864 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 419591BB-AF1D-4722-AAA9-F0B73CF9D026

# Create the first partition (/boot, 500M)
Command (m for help): n
Partition number (1-128, default 1): 
First sector (2048-67108830, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-67108830, default 67106815): +500M

Created a new partition 1 of type 'Linux filesystem' and of size 500 MiB.

# Create the second partition (/boot/efi, 64M)
Command (m for help): n
Partition number (2-128, default 2): 
First sector (1026048-67108830, default 1026048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1026048-67108830, default 67106815): +64M

Created a new partition 2 of type 'Linux filesystem' and of size 64 MiB.

# Create the third partition (LUKS container, use the remaining space)
Command (m for help): n
Partition number (3-128, default 3): 
First sector (1157120-67108830, default 1157120): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1157120-67108830, default 67106815): 

Created a new partition 3 of type 'Linux filesystem' and of size 31.4 GiB.

# Save the partition table
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Formatting the Base Partitions

Format the /boot and /boot/efi partitions:

mkfs.ext4 /dev/sda1
mkfs.fat -F32 /dev/sda2

Configuring LUKS Encryption

Create the LUKS2 container:

# Initialize the encrypted partition with the LUKS2 format
cryptsetup luksFormat --type luks2 /dev/sda3

The system asks you to confirm. Type YES in uppercase, then set a strong passphrase. This passphrase is your main recovery method.

Adding USB Key Unlock (Optional)

If you prepared a USB key earlier, add the key file to LUKS now:

cryptsetup luksAddKey /dev/sda3 /tmp/luks_usb.key

Enter the LUKS passphrase you just set to confirm.

Testing USB Key Unlock

Verify that the USB key unlocks correctly:

cryptsetup open /dev/sda3 cryptlvm --key-file /tmp/luks_usb.key

On success, the /dev/mapper/cryptlvm device is created.

Configuring LVM

Create the LVM volume group and logical volumes on the encrypted container:

# Create the physical volume
pvcreate /dev/mapper/cryptlvm

# Create the volume group
vgcreate pve /dev/mapper/cryptlvm

# Create the logical volumes (adjust the sizes to your needs)
lvcreate -L 20G -n root pve    # Root partition
lvcreate -L 4G -n swap pve      # Swap partition

# Format the logical volumes
mkfs.ext4 /dev/pve/root
mkswap /dev/pve/swap

Mounting the Filesystems

Create the mount points and mount all partitions:

# Mount the root partition
mkdir -pv /mnt/debinst
mount /dev/pve/root /mnt/debinst

# Mount /boot
mkdir -pv /mnt/debinst/boot
mount /dev/sda1 /mnt/debinst/boot

# Mount /boot/efi
mkdir -pv /mnt/debinst/boot/efi
mount /dev/sda2 /mnt/debinst/boot/efi

Installing the Debian Base System

Install Debian 13 “Trixie” with debootstrap:

debootstrap --arch amd64 trixie /mnt/debinst https://mirrors.infra.plz.ac/debian/

This takes a few minutes while the base system packages are downloaded and installed.

Entering the chroot

Mount the necessary virtual filesystems and switch into the new system:

# Mount the virtual filesystems
mount -v -t proc none /mnt/debinst/proc
mount -v --rbind /sys /mnt/debinst/sys
mount -v --rbind /dev /mnt/debinst/dev
mount -v --make-rslave /mnt/debinst/sys
mount -v --make-rslave /mnt/debinst/dev

# Enter the chroot
chroot /mnt/debinst /bin/bash

Basic System Configuration

Setting the Time Zone

dpkg-reconfigure tzdata

Choose your time zone (for example, Asia/Shanghai).

Configuring Locales

apt-get install locales -y
dpkg-reconfigure locales

Select the locales you need; I recommend at least en_US.UTF-8 and zh_CN.UTF-8.

Installing the Kernel and Required Packages

apt-get update
apt install linux-image-amd64 grub-efi-amd64 lvm2 tpm2-tools wget \
  systemd-cryptsetup apt-transport-https ca-certificates aptitude \
  vim dosfstools cryptsetup efibootmgr dropbear-initramfs \
  initramfs-tools cryptsetup-initramfs -y

These packages include:

  • linux-image-amd64: the Linux kernel
  • grub-efi-amd64: the UEFI bootloader
  • lvm2: LVM tools
  • tpm2-tools: TPM 2.0 tools
  • cryptsetup-initramfs: encryption support in the initramfs
  • dropbear-initramfs: optional remote unlock support

Setting the Hostname and root Password

echo "debian-tpm" > /etc/hostname
passwd

Configuring Filesystem Mounts

Getting the UUIDs

First get the UUIDs of the partitions and logical volumes:

blkid /dev/pve/root
blkid /dev/pve/swap
blkid /dev/sda1
blkid /dev/sda2

Note these UUIDs; you’ll need them shortly.

Editing /etc/fstab

vi /etc/fstab

Add the following (replace the UUIDs with your own):

# <filesystem>                                 <mount point>   <type>  <options>            <dump> <pass>
UUID=c29b35e2-6d42-4444-aa03-01eb39146f87       /           ext4    errors=remount-ro   0      1
UUID=6e5fad3a-c4f9-4ec9-abad-58fe31886c7d       /boot       ext4    defaults            0      2
UUID=92A5-56AF                                  /boot/efi   vfat    umask=0077          0      1
UUID=f10a8543-a85f-425e-9100-ee8b09aa2e76       none        swap    sw                  0      0

Configuring /etc/crypttab

vi /etc/crypttab

Add the LUKS device entry (replace with the UUID of /dev/sda3):

# <target name> <source device> <key file> <options>
cryptlvm UUID=558ed1f4-cc23-4d7d-8b14-a2b2de3d0882 none luks,initramfs,discard

What these fields mean:

  • cryptlvm: the device mapper name after unlock
  • UUID=...: the UUID of the LUKS partition
  • none: no key file (TPM/passphrase are tried at boot)
  • luks,initramfs,discard: options
    • luks: decrypt with LUKS
    • initramfs: handle it during the initramfs stage
    • discard: enable SSD TRIM (optional)

Configuring the Bootloader

Configuring initramfs-tools

The TPM and USB key fallbacks require writing your own hooks.

Create and edit /etc/initramfs-tools/hooks/crypt-unlock with the following content:

#!/bin/sh
PREREQ=""

prereqs() {
    echo "$PREREQ"
}

case "$1" in
    prereqs)
        prereqs
        exit 0
        ;;
esac

. /usr/share/initramfs-tools/hook-functions

# Copy the unlock script into the initramfs
cat > "${DESTDIR}/usr/bin/unlock" <<'UNLOCK_SCRIPT'
#!/bin/sh
echo "Available encrypted devices:"
ls -l /dev/disk/by-uuid/ | grep 558ed1f4

echo ""
echo "Enter passphrase to unlock cryptlvm:"
/lib/cryptsetup/askpass "Enter passphrase: " | \
    /sbin/cryptsetup luksOpen /dev/disk/by-uuid/558ed1f4-cc23-4d7d-8b14-a2b2de3d0882 cryptlvm

if [ $? -eq 0 ]; then
    echo "Device unlocked successfully!"
    echo "Killing dropbear and continuing boot..."
    killall dropbear
    exit 0
else
    echo "Unlock failed!"
    exit 1
fi
UNLOCK_SCRIPT

chmod +x "${DESTDIR}/usr/bin/unlock"

exit 0

TPM support in /etc/initramfs-tools/hooks/tpm-support:

#!/bin/sh
PREREQ=""

prereqs() {
    echo "$PREREQ"
}

case "$1" in
    prereqs)
        prereqs
        exit 0
        ;;
esac

. /usr/share/initramfs-tools/hook-functions

echo "Adding TPM support to initramfs..."

# Copy systemd-cryptenroll
if [ -x /usr/bin/systemd-cryptenroll ]; then
    copy_exec /usr/bin/systemd-cryptenroll
    echo "  Added: systemd-cryptenroll"
fi

# Copy all TSS2 libraries
for lib in /usr/lib/x86_64-linux-gnu/libtss2-*.so*; do
    if [ -f "$lib" ]; then
        # Use copy_exec to handle symlinks and dependencies automatically
        copy_exec "$lib"
        echo "  Added: $(basename $lib)"
    fi
done

# Copy the cryptsetup token plugin directory
if [ -d /usr/lib/x86_64-linux-gnu/cryptsetup ]; then
    mkdir -p "${DESTDIR}/usr/lib/x86_64-linux-gnu/cryptsetup"
    cp -a /usr/lib/x86_64-linux-gnu/cryptsetup/* \
        "${DESTDIR}/usr/lib/x86_64-linux-gnu/cryptsetup/" 2>/dev/null || true
    echo "  Added: cryptsetup plugins"
fi

# Make sure the required libraries are present
for lib in libcrypto libssl libgcc_s libc; do
    for file in /usr/lib/x86_64-linux-gnu/${lib}.so*; do
        if [ -f "$file" ]; then
            copy_exec "$file"
        fi
    done
done

echo "TPM support added successfully"

exit 0

USB support in /etc/initramfs-tools/hooks/usb-unlock:

#!/bin/sh
PREREQ=""

prereqs() {
    echo "$PREREQ"
}

case "$1" in
    prereqs)
        prereqs
        exit 0
        ;;
esac

. /usr/share/initramfs-tools/hook-functions

# Copy the necessary binaries
copy_exec /bin/mount /bin
copy_exec /bin/umount /bin
copy_exec /sbin/cryptsetup /sbin
copy_exec /bin/mkdir /bin

# Add filesystem modules
manual_add_modules ext4
manual_add_modules vfat
manual_add_modules nls_cp437
manual_add_modules nls_iso8859_1

# Add USB drivers
manual_add_modules usb-storage
manual_add_modules uas
manual_add_modules xhci-hcd
manual_add_modules ehci-hcd
manual_add_modules ohci-hcd
manual_add_modules uhci-hcd
manual_add_modules xhci-pci
manual_add_modules ehci-pci

# Add TPM drivers
manual_add_modules tpm_tis
manual_add_modules tpm_crb
manual_add_modules tpm

exit 0

Create the unlock script /etc/initramfs-tools/scripts/local-top/cryptroot-unlock:

#!/bin/sh
PREREQ="udev"
prereqs() {
    echo "$PREREQ"
}

case "$1" in
    prereqs)
        prereqs
        exit 0
        ;;
esac

. /scripts/functions

USB_LABEL="USB-KEY"
KEYFILE="luks_usb.key"
LUKS_UUID="558ed1f4-cc23-4d7d-8b14-a2b2de3d0882"
LUKS_NAME="cryptlvm"

# Check whether the device is already unlocked
if [ -e "/dev/mapper/$LUKS_NAME" ]; then
    log_success_msg "LUKS device already unlocked"
    exit 0
fi

# Step 1: try TPM token unlock
log_begin_msg "Attempting TPM token unlock..."
if [ -e /dev/tpm0 ] || [ -e /dev/tpmrm0 ]; then
    # Unlock with the cryptsetup token feature
    if /sbin/cryptsetup open --token-only "/dev/disk/by-uuid/$LUKS_UUID" "$LUKS_NAME" 2>&1; then
        log_success_msg "LUKS unlocked with TPM token"
        exit 0
    else
        log_warning_msg "TPM token unlock failed"
    fi
else
    log_warning_msg "No TPM device found"
fi

# Step 2: try USB Key unlock
log_begin_msg "Looking for USB key..."
udevadm settle --timeout=10

for i in $(seq 1 30); do
    if [ -e "/dev/disk/by-label/$USB_LABEL" ]; then
        log_success_msg "USB key found"
        break
    fi
    sleep 1
done

if [ -e "/dev/disk/by-label/$USB_LABEL" ]; then
    mkdir -p /tmp/usbkey

    if mount -t ext4 -o ro "/dev/disk/by-label/$USB_LABEL" /tmp/usbkey 2>/dev/null; then
        if [ -f "/tmp/usbkey/$KEYFILE" ]; then
            log_success_msg "Found keyfile, attempting unlock..."
            if /sbin/cryptsetup luksOpen "/dev/disk/by-uuid/$LUKS_UUID" "$LUKS_NAME" \
                --key-file "/tmp/usbkey/$KEYFILE" 2>&1; then
                log_success_msg "LUKS unlocked with USB key"
                umount /tmp/usbkey
                exit 0
            fi
        fi
        umount /tmp/usbkey
    fi
fi

log_warning_msg "All automatic unlock methods failed"
exit 0

Updating the initramfs

update-initramfs -u -k all

This builds an initramfs that includes encryption support.

Installing GRUB

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Debian

Configuring GRUB

Edit the GRUB defaults:

vi /etc/default/grub

Change the kernel command line:

GRUB_CMDLINE_LINUX="root=/dev/mapper/pve-root"

Generate the GRUB configuration:

grub-mkconfig -o /boot/grub/grub.cfg

Configuring TPM2 Auto-Unlock

Enroll the LUKS key with the TPM chip:

systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/sda3

Enter the LUKS passphrase you set earlier. The output looks like this:

 Please enter current passphrase for disk /dev/sda3: ••••••••••••••••
Warning: keyslot operation could fail as it requires more than available memory.
New TPM2 token enrolled as key slot 2.

This means the TPM key was added to key slot 2.

Verifying the Key Slot Configuration

Inspect the current LUKS configuration:

cryptsetup luksDump /dev/sda3

Example output:

LUKS header information
Version:        2
Epoch:          6
Metadata area:  16384 [bytes]
Keyslots area:  16744448 [bytes]
UUID:           558ed1f4-cc23-4d7d-8b14-a2b2de3d0882

Keyslots:
  0: luks2                    # User passphrase
     Key:        512 bits
     ...
  1: luks2                    # USB Key
     Key:        512 bits
     ...
  2: luks2                    # TPM2
     Key:        512 bits
     PBKDF:      pbkdf2
     ...
Tokens:
  0: systemd-tpm2
     tpm2-hash-pcrs:   0+7
     tpm2-pcr-bank:    sha256
     ...
     Keyslot:    2

You can see three key slots:

  • Slot 0: user passphrase
  • Slot 1: USB key file
  • Slot 2: TPM2 auto-unlock

Configuring Networking and SSH

Installing SSH

apt-get install ssh -y

Allowing root Login over SSH

Edit the SSH configuration:

vi /etc/ssh/sshd_config

Change or add this line:

PermitRootLogin yes

Enable SSH at boot:

systemctl enable ssh

Configuring the Network Interface

Edit the network configuration:

vi /etc/network/interfaces

Add a static IP configuration (adjust to your environment):

auto ens18
iface ens18 inet static
    address 10.31.0.119
    network 10.31.0.0
    netmask 255.255.255.0
    broadcast 10.31.0.255
    gateway 10.31.0.254

Configuring DNS

echo "nameserver 10.31.0.252" > /etc/resolv.conf

Configuring /etc/hosts

echo "10.31.0.119 debian-tpm" >> /etc/hosts

Configuring APT Sources

Edit the source list:

vi /etc/apt/sources.list

Use the following (a China mirror is used here for speed):

deb https://mirrors.infra.plz.ac/debian/ trixie main contrib non-free non-free-firmware
# deb-src https://mirrors.infra.plz.ac/debian/ trixie main contrib non-free non-free-firmware

deb https://mirrors.infra.plz.ac/debian/ trixie-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.infra.plz.ac/debian/ trixie-updates main contrib non-free non-free-firmware

deb https://mirrors.infra.plz.ac/debian/ trixie-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.infra.plz.ac/debian/ trixie-backports main contrib non-free non-free-firmware

deb https://mirrors.infra.plz.ac/debian-security trixie-security main contrib non-free non-free-firmware
# deb-src https://mirrors.infra.plz.ac/debian-security trixie-security main contrib non-free non-free-firmware

Finishing the Base Installation

Exiting the chroot

exit

Unmounting All Partitions

umount -R /mnt/debinst

Shutting Down LVM and LUKS

vgchange -an pve
cryptsetup close cryptlvm

Rebooting

reboot

You can now remove the Live CD, but leave the USB key plugged in if you configured one.

After the reboot, if the TPM is configured correctly, the encrypted partition should unlock automatically and boot to the login screen.

Installing Proxmox VE 9

With the base system installed, Proxmox VE 9 can go on top of the encrypted Debian 13.

Adding the Proxmox Repository

Create and edit the Proxmox repository file:

vi /etc/apt/sources.list.d/proxmox.sources

Add the following:

Types: deb
URIs: http://download.proxmox.com/debian/pve
Suites: trixie
Components: pve-no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg

For a China mirror, use:

Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve
Suites: trixie
Components: pve-no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg

Adding the Proxmox GPG Key

wget https://enterprise.proxmox.com/debian/proxmox-release-trixie.gpg \
  -O /usr/share/keyrings/proxmox-archive-keyring.gpg

Updating and Installing Proxmox VE

apt-get update
apt-get full-upgrade -y
apt-get install proxmox-ve -y

Accessing the Web UI

After the install finishes and the system reboots, open the Proxmox VE web UI in a browser:

https://your-server-ip:8006

Log in as root with the root password you set earlier.

Verifying the Unlock Methods

Once deployed, let’s verify that each unlock method works.

Verifying TPM2 Auto-Unlock

Reboot:

reboot

Watch the boot process:

  • [Success] Success: the system boots straight to the login screen without any passphrase
  • [Failure] Failure: it stops at the passphrase prompt, which means TPM unlock failed

If TPM unlock fails, possible causes:

  1. PCR values changed (BIOS update, Secure Boot state change)
  2. The TPM chip is disabled or cleared
  3. An initramfs configuration problem

Verifying USB Key Unlock

If you configured a USB key:

  1. Unplug the USB key and reboot
  2. The system should stop at the passphrase prompt
  3. Plug the USB key in
  4. The system should detect it and unlock automatically (depending on the initramfs configuration)

Note: standard systemd-cryptsetup does not watch for USB key hotplug, so you may still need to type the passphrase or add extra initramfs script support.

Verifying Passphrase Unlock

This is the most basic method and always works:

  1. Disable the TPM in the BIOS or delete the TPM key
  2. Remove the USB key
  3. Reboot
  4. Enter the LUKS passphrase at boot
  5. The system should unlock and boot normally

Recovery Procedures

When the system won’t boot or needs maintenance, you can use a Debian Live CD to enter recovery mode. This section covers the complete troubleshooting and repair flow.

Recovery Flow Overview

flowchart TD
    A[System fails to boot] --> B{Identify the failure type}
    
    B -->|TPM unlock failure| C[BIOS update / PCR change]
    B -->|Forgotten passphrase| D[Reset or recovery needed]
    B -->|Boot corruption| E[GRUB/kernel problem]
    B -->|Partition corruption| F[Filesystem error]
    
    C --> G[Prepare a Live CD]
    D --> G
    E --> G
    F --> G
    
    G --> H[Boot into the live environment]
    H --> I[Install recovery tools]
    I --> J{Can LUKS be unlocked?}
    
    J -->|Passphrase available| K[Unlock with the passphrase]
    J -->|USB Key available| L[Unlock with the USB Key]
    J -->|Neither| M[Attempt brute-force recovery or accept data loss]
    
    K --> N[Activate LVM]
    L --> N
    
    N --> O[Mount the filesystems]
    O --> P[Enter the chroot environment]
    
    P --> Q{Perform repair actions}
    
    Q -->|TPM problem| R[Re-enroll TPM]
    Q -->|Boot problem| S[Reinstall GRUB]
    Q -->|initramfs problem| T[Rebuild initramfs]
    Q -->|Key management| U[Modify key slots]
    Q -->|System update| V[Upgrade/downgrade packages]
    
    R --> W[Verify the repair]
    S --> W
    T --> W
    U --> W
    V --> W
    
    W --> X[Clean up and exit chroot]
    X --> Y[Unmount filesystems]
    Y --> Z[Close LUKS and LVM]
    Z --> AA[Reboot and verify]
    
    AA --> AB{Boot successful?}
    AB -->|Yes| AC["Recovery complete ✓"]
    AB -->|No| AD[Diagnose again]
    AD --> B
    
    M --> AE[Consider professional data recovery]

Detailed Recovery Steps

1. Boot into the Live Environment

Boot the system from the Debian Live CD or USB drive you made earlier.

Set up SSH for remote access (recommended):

# Install and start the SSH service
apt install -y ssh
systemctl start ssh

# Set a temporary passphrase
passwd user

Connect from another machine:

ssh user@<target-host-ip>
sudo -i

2. Install the Recovery Tools

apt update
apt install -y debootstrap dosfstools cryptsetup lvm2 tpm2-tools gdisk vim

Tool notes:

  • cryptsetup: LUKS management
  • lvm2: LVM volume management
  • tpm2-tools: TPM diagnostics and management
  • gdisk: GPT partition table tool

3. Unlock the Encrypted Partition

Pick the method you have available:

Method 1: Unlock with the passphrase (most common)

cryptsetup open /dev/sda3 cryptlvm

The system prompts for the passphrase. After you enter it, the /dev/mapper/cryptlvm device is created.

Method 2: Unlock with the USB key

First make sure the USB key is plugged in and detected:

# List USB devices
lsblk
# Or
ls -l /dev/disk/by-label/

# Unlock with the key file
cryptsetup open /dev/sda3 cryptlvm --key-file /dev/disk/by-label/USB-KEY/luks_usb.key

Method 3: Inspect LUKS information

# Show LUKS header information
cryptsetup luksDump /dev/sda3

# List available key slots
cryptsetup luksDump /dev/sda3 | grep "Keyslots:" -A 30

# Inspect TPM tokens
cryptsetup luksDump /dev/sda3 | grep "Tokens:" -A 20

4. Activate the LVM Volume Group

Once LUKS is unlocked, activate LVM:

# Scan for and activate all volume groups
vgscan
vgchange -ay

# List logical volumes
lvs
lvscan

You should see output like this:

ACTIVE            '/dev/pve/root' [20.00 GiB] inherit
ACTIVE            '/dev/pve/swap' [4.00 GiB] inherit

5. Mount the Filesystems

Mount all partitions in the correct order:

# Create the mount points
mkdir -pv /mnt/debinst

# Mount the root partition
mount /dev/pve/root /mnt/debinst

# Mount /boot
mkdir -pv /mnt/debinst/boot
mount /dev/sda1 /mnt/debinst/boot

# Mount the EFI partition
mkdir -pv /mnt/debinst/boot/efi
mount /dev/sda2 /mnt/debinst/boot/efi

# Verify the mounts
df -h | grep debinst

6. Enter the chroot Environment

Mount the virtual filesystems and switch into the target system:

# Mount the necessary virtual filesystems
mount -v -t proc none /mnt/debinst/proc
mount -v --rbind /sys /mnt/debinst/sys
mount -v --rbind /dev /mnt/debinst/dev
mount -v --make-rslave /mnt/debinst/sys
mount -v --make-rslave /mnt/debinst/dev

# Optional: mount /run (some operations need it)
mount -v --rbind /run /mnt/debinst/run
mount -v --make-rslave /mnt/debinst/run

# Enter the chroot
chroot /mnt/debinst /bin/bash

# Set an environment variable (optional)
export PS1="(chroot) $PS1"

You are now inside the target system’s environment.

Common Repair Scenarios

Scenario 1: TPM Unlock Fails After a BIOS Update

Symptoms:

  • The system stops at the passphrase prompt
  • It used to boot automatically, but no longer does
  • The BIOS was just updated

Cause: the BIOS update changed PCR 0, so the TPM refuses to unseal the key.

Repair steps:

# Inside the chroot

# 1. Check the current TPM state
tpm2_pcrread sha256:0,7

# 2. Remove the old TPM key slot
systemd-cryptenroll --wipe-slot=tpm2 /dev/sda3

# 3. Re-enroll the TPM (with the new PCR values)
systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/sda3

# 4. Verify the enrollment
cryptsetup luksDump /dev/sda3 | grep -A 15 "systemd-tpm2"

Scenario 2: Corrupted GRUB Boot

Symptoms:

  • The system can’t find the bootloader
  • It shows “No bootable device” or “GRUB rescue”
  • The EFI boot entry is gone

Repair steps:

# Inside the chroot

# 1. Reinstall GRUB
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Debian

# 2. Regenerate the GRUB configuration
grub-mkconfig -o /boot/grub/grub.cfg

# 3. Verify the EFI boot entry
efibootmgr -v

# 4. Create a boot entry manually if needed
efibootmgr -c -d /dev/sda -p 2 -L "Debian" -l '\EFI\debian\grubx64.efi'

Scenario 3: Broken or Misconfigured initramfs

Symptoms:

  • Kernel panic at boot
  • Root device not found
  • Encryption modules not loaded
  • TPM or USB key auto-unlock doesn’t work

Repair steps:

# Inside the chroot

# 1. Check that the initramfs hooks exist
ls -la /etc/initramfs-tools/hooks/
# You should see: crypt-unlock, tpm-support, usb-unlock

# 2. Check that the unlock script exists
ls -la /etc/initramfs-tools/scripts/local-top/
# You should see: cryptroot-unlock

# 3. Verify that the hooks are executable
chmod +x /etc/initramfs-tools/hooks/*
chmod +x /etc/initramfs-tools/scripts/local-top/*

# 4. Check that the LUKS UUID is correct
blkid /dev/sda3
# Make sure the UUID matches LUKS_UUID in the hook script

# 5. Update the UUID in the scripts if needed
ACTUAL_UUID=$(blkid -s UUID -o value /dev/sda3)
echo "Actual UUID: $ACTUAL_UUID"
# Edit the scripts by hand to update the UUID
vi /etc/initramfs-tools/hooks/crypt-unlock
vi /etc/initramfs-tools/scripts/local-top/cryptroot-unlock

# 6. Rebuild the initramfs for all kernels
update-initramfs -u -k all

# 7. Verify the initramfs contents
lsinitramfs /boot/initrd.img-$(uname -r) | grep -E 'cryptsetup|unlock|tpm|usb'

# 8. Check that the required libraries are included
lsinitramfs /boot/initrd.img-$(uname -r) | grep tss2

Scenario 4: Forgotten Passphrase or a Reset

Repair steps:

# Inside the chroot (you must be able to unlock LUKS another way)

# 1. Add a new passphrase in a new key slot
cryptsetup luksAddKey /dev/sda3
# Enter a currently working passphrase, then the new one

# 2. Or change the passphrase of an existing key slot
cryptsetup luksChangeKey /dev/sda3 -S 0
# -S 0 selects the key slot number

# 3. Remove the forgotten passphrase slot (optional)
cryptsetup luksKillSlot /dev/sda3 1
# Be careful! Make sure at least one usable key slot remains

Scenario 5: Lost USB Key, Recreate It

Repair steps:

# Inside the chroot

# 1. Prepare a new USB key
mkfs.ext4 -L 'USB-KEY-NEW' /dev/sdb1

# 2. Generate a new key file
dd if=/dev/urandom of=/tmp/new_usb.key bs=4096 count=1

# 3. Add the new key to LUKS
cryptsetup luksAddKey /dev/sda3 /tmp/new_usb.key

# 4. Copy the key to the new USB drive
mkdir /mnt/newusb
mount /dev/disk/by-label/USB-KEY-NEW /mnt/newusb
cp /tmp/new_usb.key /mnt/newusb/luks_usb.key
chmod 400 /mnt/newusb/luks_usb.key
umount /mnt/newusb

# 5. Remove the old USB key slot (if needed)
cryptsetup luksDump /dev/sda3  # Check the slot number first
cryptsetup luksKillSlot /dev/sda3 <old-slot-number>

# 6. Clean up the temporary file
shred -vfz -n 3 /tmp/new_usb.key

Scenario 6: Problems After a System Update

Repair steps:

# Inside the chroot

# 1. Check the system logs
journalctl -xb -1  # View the previous boot's log

# 2. Downgrade the problem package (example)
apt install <package>=<old-version>

# 3. Or upgrade to the latest version
apt update
apt full-upgrade

# 4. Rebuild initramfs and GRUB
update-initramfs -u -k all
update-grub

Key Slot Management

Viewing the Current Key Slots

cryptsetup luksDump /dev/sda3

Example output:

Keyslots:
  0: luks2        ← password unlock
     Key:        512 bits
     PBKDF:      argon2id
     ...
  1: luks2        ← USB Key unlock
     Key:        512 bits
     PBKDF:      argon2id
     ...
  2: luks2        ← TPM2 unlock
     Key:        512 bits
     PBKDF:      pbkdf2
     ...

Key Slot Best Practices

# Recommended: keep at least two unlock methods

# Slot 0: primary passphrase (strong, stored safely)
# Slot 1: backup passphrase (stored in a safe place)
# Slot 2: TPM2 (daily use)
# Slot 3: USB Key (backup)

# Test all unlock methods periodically
for slot in 0 1 2 3; do
    echo "Testing slot $slot..."
    cryptsetup luksDump /dev/sda3 | grep -A 5 "^  $slot:"
done

Finishing the Repair and Exiting

After all repairs are done, clean up in this order:

# 1. Exit the chroot
exit

# 2. Unmount all filesystems (order matters!)
umount -v /mnt/debinst/run  # If mounted
umount -v /mnt/debinst/dev
umount -v /mnt/debinst/sys
umount -v /mnt/debinst/proc
umount -v /mnt/debinst/boot/efi
umount -v /mnt/debinst/boot
umount -v /mnt/debinst

# Or use a recursive unmount
umount -R /mnt/debinst

# 3. Deactivate the LVM volume group
vgchange -an pve

# 4. Close the LUKS encrypted device
cryptsetup close cryptlvm

# 5. Verify the cleanup
lsblk
dmsetup ls

# 6. Reboot
echo "Repair complete; rebooting to verify..."
reboot

Verifying the Repair

After the system reboots, watch the boot process:

flowchart LR
    A[System reboots] --> B{TPM auto-unlock}
    B -->|Success| C["Normal boot ✓"]
    B -->|Failure| D{USB Key unlock}
    D -->|Success| C
    D -->|Failure| E{Passphrase unlock}
    E -->|Success| C
    E -->|Failure| F["Repair again ✗"]
    
    C --> G[Log in and verify]
    G --> H{Check logs}
    H -->|No errors| I["Repair successful ✓"]
    H -->|Warnings| J[Investigate further]
    
    F --> K[Restart the recovery process]

Post-boot verification checklist:

# 1. Check the systemd service status
systemctl status [email protected]

# 2. Review the boot log
journalctl -b | grep -i crypt
journalctl -b | grep -i tpm

# 3. Verify that all partitions are mounted
df -h
lsblk

# 4. Check the LVM status
vgs
lvs

# 5. Test TPM functionality
tpm2_pcrread sha256:0,7

# 6. Verify the LUKS configuration
cryptsetup status cryptlvm

Troubleshooting Toolbox

Diagnostic Command Cheat Sheet

# ===== LUKS diagnostics =====
cryptsetup luksDump /dev/sda3                    # Show LUKS header information
cryptsetup isLuks /dev/sda3 && echo "LUKS device confirmed"   # Verify that this is a LUKS device
cryptsetup status cryptlvm                       # Show the unlock status

# ===== TPM diagnostics =====
tpm2_getcap properties-fixed                     # Basic TPM information
tpm2_pcrread                                     # Read all PCR values
systemd-cryptenroll --tpm2-device=list          # List TPM devices

# ===== LVM diagnostics =====
pvs                                              # Physical volume overview
vgs                                              # Volume group overview
lvs                                              # Logical volume overview
vgdisplay pve                                    # Detailed volume group information

# ===== Partition diagnostics =====
lsblk -f                                         # Show filesystems and UUIDs
blkid                                            # Show all block device UUIDs
fdisk -l /dev/sda                                # Partition table information
gdisk -l /dev/sda                                # GPT partition table details

# ===== Boot diagnostics =====
efibootmgr -v                                    # EFI boot entries
ls -la /boot/efi/EFI/                           # EFI partition contents
grub-install --version                           # GRUB version

Preventive Maintenance

1. Back Up the LUKS Header Regularly

# Back up the LUKS header (very important!)
cryptsetup luksHeaderBackup /dev/sda3 \
    --header-backup-file /secure/backup/luks-header-$(date +%Y%m%d).img

# Verify the backup
file /secure/backup/luks-header-*.img

# Restore the header (emergencies only!)
# cryptsetup luksHeaderRestore /dev/sda3 \
#     --header-backup-file /secure/backup/luks-header-YYYYMMDD.img

2. Document Your Configuration

Create a recovery document and store it safely:

# Record the important information
cat > /secure/recovery-info.txt << EOF
=== Encrypted System Recovery Information ===
Created: $(date)
Hostname: $(hostname)

LUKS device: /dev/sda3
UUID: $(blkid -s UUID -o value /dev/sda3)

Key slots:
- Slot 0: primary passphrase
- Slot 1: backup passphrase
- Slot 2: TPM2 (PCR 0+7)
- Slot 3: USB Key (label: USB-KEY)

LVM layout:
- VG: pve
- LV root: /dev/pve/root (20G)
- LV swap: /dev/pve/swap (4G)

TPM PCR values:
$(tpm2_pcrread sha256:0,7)

Last updated: $(date)
EOF

3. Test the Recovery Process

Test the full recovery process periodically (for example, every quarter):

# Test checklist
□ Live CD boots normally
□ The passphrase unlocks LUKS
□ The USB Key unlocks LUKS  
□ Can enter the chroot environment
□ Can rebuild the initramfs
□ Can reinstall GRUB
□ TPM re-enrollment works

Advanced Configuration

Remote Unlock (Dropbear SSH)

If the server sits in a remote data center, you can configure Dropbear SSH to allow remote unlock during the initramfs stage. This is very useful when automatic unlock fails.

Installing and Configuring Dropbear

# Install dropbear-initramfs
apt install -y dropbear-initramfs

# Configure the Dropbear listen port and options
vi /etc/dropbear/initramfs/dropbear.conf

Add the configuration:

# Dropbear configuration inside the initramfs
DROPBEAR_OPTIONS="-p 2222 -s -j -k -I 60"
# -p 2222: listen on port 2222 (avoids conflicting with the normal SSH)
# -s: disable password login (key authentication only)
# -j: disable local port forwarding
# -k: disable remote port forwarding
# -I 60: disconnect after 60 seconds of inactivity

Add the authorized SSH public keys:

# Copy the public key from your management machine
cat ~/.ssh/id_rsa.pub | ssh root@target-server \
    'cat >> /etc/dropbear/initramfs/authorized_keys'

# Or edit the file directly on the target server
vi /etc/dropbear/initramfs/authorized_keys
# Paste your SSH public key

Configure the network (the initramfs needs to know the network settings):

vi /etc/initramfs-tools/initramfs.conf

Add or change:

# Network format: IP address:server IP:gateway:netmask:hostname:interface:off
IP=10.31.0.119::10.31.0.254:255.255.255.0:debian-tpm:ens18:off

The /etc/initramfs-tools/hooks/crypt-unlock file created earlier already includes the unlock command, which kills dropbear automatically after a successful unlock:

# The unlock command does the following:
# 1. Show the encrypted device information
# 2. Prompt for the passphrase
# 3. Try to unlock the LUKS device
# 4. On success, run killall dropbear and continue booting

Update the initramfs to apply the configuration:

update-initramfs -u -k all

Remote Unlock Workflow

When the server reboots and neither TPM nor the USB key can unlock it automatically, the system:

  1. Loads the network configuration from the initramfs
  2. Starts the Dropbear SSH service on port 2222
  3. Waits for the administrator to connect

Connect from the management machine:

# Connect to the initramfs environment over SSH
ssh -p 2222 [email protected]

# You land in a minimal shell environment

Unlock the disk:

# Method 1: use the preinstalled unlock script (recommended)
unlock

# The script prints:
# Available encrypted devices:
# lrwxrwxrwx 1 root root 10 Nov 17 08:30 558ed1f4-cc23-4d7d-8b14-a2b2de3d0882 -> ../../sda3
#
# Enter passphrase to unlock cryptlvm:
# Enter passphrase: 

# After the correct passphrase:
# Device unlocked successfully!
# Killing dropbear and continuing boot...

# The SSH connection drops and the system continues booting
# Method 2: unlock manually (if the unlock script is unavailable)
cryptsetup luksOpen /dev/disk/by-uuid/558ed1f4-cc23-4d7d-8b14-a2b2de3d0882 cryptlvm

# Kill dropbear manually after a successful unlock
killall dropbear
# Or just exit and the system continues booting

Testing Remote Unlock

Before deploying to production, test remote unlock:

# 1. Temporarily remove the TPM token (test only)
systemd-cryptenroll --wipe-slot=tpm2 /dev/sda3

# 2. Remove or disconnect the USB key

# 3. Reboot
reboot

# 4. Connect and unlock from another machine
ssh -p 2222 [email protected]
unlock

# 5. After a successful test, add the TPM token back
systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/sda3

Security Recommendations

  1. Network isolation: make sure the initramfs network is reachable only from a trusted management network
  2. Key management: use SSH key authentication only; disable password login (the -s option)
  3. Firewall rules: restrict port 2222 to specific source IPs
  4. Regular testing: test the remote unlock flow at least once a quarter

Troubleshooting

If remote unlock does not work:

# Inspect the initramfs contents from recovery mode
lsinitramfs /boot/initrd.img-$(uname -r) | grep dropbear
lsinitramfs /boot/initrd.img-$(uname -r) | grep authorized_keys

# Check whether the network configuration is included in the initramfs
lsinitramfs /boot/initrd.img-$(uname -r) | grep -E 'ip|network'

# Show the dropbear configuration
cat /etc/dropbear/initramfs/dropbear.conf

# Verify the public key file
cat /etc/dropbear/initramfs/authorized_keys

Security Recommendations

Layered Protection

  1. Physical security: encryption only protects data if the disk is stolen; it does not stop attacks with physical access
  2. Key management:
    • The LUKS passphrase should be complex enough (20+ characters recommended)
    • Keep the USB key safe, ideally with a backup
    • Rotate the passphrase regularly
  3. TPM limitations:
    • TPM binds only to the boot path and cannot prevent memory attacks (cold boot attacks)
    • If you need higher security, consider disabling TPM auto-unlock and keeping only the passphrase
  4. Backups:
    • Always keep a LUKS header backup: cryptsetup luksHeaderBackup /dev/sda3 --header-backup-file luks-header.img
    • Record all passphrases and recovery methods

Secure Boot

To get the most out of the TPM, enable UEFI Secure Boot:

  1. Enable Secure Boot in the BIOS
  2. Use a signed kernel and bootloader
  3. Consider tpm2-pcrs=0+2+7 to include more PCRs

Audit Logs

Enable systemd journal persistence to record all unlock attempts:

mkdir -p /var/log/journal
systemd-tmpfiles --create --prefix /var/log/journal

View the unlock log:

journalctl -u [email protected]

Performance Considerations

The performance impact of LUKS encryption:

  • CPU: modern CPUs support AES-NI, so the encryption overhead is small (usually < 5%)
  • Latency: almost none
  • Throughput: negligible on an SSD

Check whether AES-NI is enabled:

grep -m1 -o aes /proc/cpuinfo
cryptsetup benchmark

Conclusion

This post walked through deploying full disk encryption on Proxmox VE 9 with three unlock methods:

  1. Passphrase unlock: the most basic method, for recovery and emergencies
  2. TPM2 auto-unlock: the most convenient method for daily use
  3. USB Key unlock: a physical token, suitable as a backup

This layered unlock strategy keeps data secure while staying practical to operate, and it fits edge data centers or scenarios that need to recover automatically after a reboot.

Remember the golden rule of encryption: encryption protects data at rest on the disk, not the running system. Once the system is unlocked and running, the data is in plaintext in memory. Physical security, access control, and other safeguards matter just as much.