This is a record of how I set up an encrypted Proxmox VE deployment.

Install an encrypted Debian first, then install PVE on top of it. Partition with a Debian LiveCD, install the system with debootstrap, set up LUKS and dropbear remote unlock, and only install PVE once the machine boots normally.

/boot is an unencrypted ESP, so anyone with access to the disk can still tamper with the kernel or initramfs. Defending against that requires Secure Boot or encrypting the boot chain too.

Installing Debian

Preparation

Boot the Debian 12 LiveCD standard ISO, then start SSH:

apt install -y ssh
systemctl start ssh
passwd user

After that we can connect over SSH:

ssh user@ip
sudo -i

Install the necessary tools for encryption, FAT32 and bootloader support:

apt install dosfstools cryptsetup efibootmgr

Partitioning

The partitioning scheme:

Partition Filesystem Mount point
/dev/sdc1 fat32 (ESP) /boot
/dev/sdc2 LUKS /dev/mapper/cryptlvm
/dev/pve/root ext4 /
/dev/pve/swap swap none

Initialize the boot partition:

mkfs.fat -F32 /dev/sdc1

Initialize LUKS

cryptsetup luksFormat /dev/sdc2

Open the LUKS partition:

cryptsetup luksOpen /dev/sdc2 cryptlvm

Create the matching PV and VG:

pvcreate /dev/mapper/cryptlvm
vgcreate pve /dev/mapper/cryptlvm

Create the LVs:

lvcreate -L 60G pve -n root
lvcreate -L 8G pve -n swap

Create the filesystems:

# Format swap
mkswap /dev/pve/swap
# Format root drive
mkfs.ext4 /dev/pve/root

Create the mount point:

mkdir -pv  /mnt/debinst

Mount:

mount /dev/pve/root /mnt/debinst

Create the boot mount point:

mkdir -pv /mnt/debinst/boot

Mount:

mount /dev/sdc1 /mnt/debinst/boot

Debian debootstrap

Install debootstrap

apt-get install debootstrap

Run debootstrap

debootstrap --arch amd64 bookworm \
     /mnt/debinst https://mirrors.tuna.tsinghua.edu.cn/debian/

Mount the necessary 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:

LANG=C.UTF-8 chroot /mnt/debinst /bin/bash

Installing Software

Install the necessary packages

apt install apt-transport-https ca-certificates aptitude vim dosfstools cryptsetup efibootmgr lvm2  -y

fstab

Edit /etc/fstab. Both root and /boot need entries:

UUID=e355fefa-2699-42a4-af4d-0f6edb04f854  /      ext4  rw,relatime  0 1
UUID=<esp-uuid>                            /boot  vfat  umask=0077   0 1

Look up the /boot UUID with blkid /dev/sdc1. With the ESP mounted at /boot, GRUB’s --efi-directory must point at /boot as well.

Timezone

Reconfigure the tzdata package and follow the prompts:

dpkg-reconfigure tzdata

Network Configuration

Edit /etc/network/interfaces:

auto enp5s4f0
iface enp5s4f0 inet static
    address 192.168.100.254
    network 192.168.100.0
    netmask 255.255.255.0
    broadcast 192.168.100.255
    gateway 192.168.100.1

The matching DNS configuration:

echo nameserver 192.168.100.1 > /etc/resolv.conf

Hostname:

echo pve.plz.ac > /etc/hostname

The hosts file, /etc/hosts

127.0.0.1 localhost
192.168.100.254 pve pve.plz.ac

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Note that this line is required: 192.168.100.254 pve pve.plz.ac

The format has to be the IP, then pve, then pve’s hostname; otherwise installing pve-manager later will break.

APT Mirror Configuration (China)

Switch to the Tsinghua mirror in China:

# Source mirrors are commented out by default to speed up apt update; uncomment if needed
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

Locale Configuration

Configure it to your needs:

aptitude install locales
dpkg-reconfigure locales

Kernel Installation

Just install the stable kernel:

apt-get install linux-image-amd64

Bootloader

Install GRUB:

aptitude install grub-efi

Install GRUB to the boot partition:

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

Edit the GRUB defaults in /etc/default/grub:

GRUB_CMDLINE_LINUX="root=/dev/pve/root"

Debian’s initramfs unlocks LUKS via /etc/crypttab; it doesn’t need genkernel’s crypt_root= parameter. root_trim=yes and rhgb are options from other distributions too, so don’t copy them over.

Generate the config:

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

SSH Service

Install SSH:

apt install ssh -y

Set the root password:

passwd

Configure root to allow key-only logins. Edit /etc/ssh/sshd_config:

PermitRootLogin prohibit-password

dropbear initramfs Configuration

Install the packages:

apt install cryptsetup-initramfs dropbear-initramfs

Configure the encrypted device:

vi /etc/crypttab

Contents:

cryptlvm UUID=ba8ae089-3095-44d6-bf09-c8f1bc3946de none luks,discard

cryptlvm is the mapping name and the UUID is that of the LUKS partition (/dev/sdc2), looked up with blkid. discard passes TRIM through to the SSD.

Add the corresponding SSH key to /etc/dropbear/initramfs/authorized_keys

ssh-ed25519 AAAA... your-key-comment

Edit the dropbear configuration /etc/dropbear/initramfs/dropbear.conf and add:

DROPBEAR_OPTIONS="-I 180 -j -k -p 2222 -s -c cryptroot-unlock"

To configure a static IP, edit /etc/initramfs-tools/initramfs.conf:

IP=192.168.100.254::192.168.100.1:255.255.255.0:pve.plz.ac

Update the initramfs:

update-initramfs -u -v

Update GRUB:

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

Cleanup

Clear apt’s cache and downloaded packages:

apt clean

Exit the live CD

exit
umount -R /mnt/debinst

Reboot:

reboot -f 

After rebooting, you can test unlocking over SSH.

Installing PVE

Installing Proxmox

Add the repository:

echo "deb [arch=amd64] https://download.proxmox.com/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list
wget https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg
apt update && apt full-upgrade

Install the PVE kernel package, then reboot:

apt install proxmox-default-kernel
systemctl reboot

Install PVE:

apt install proxmox-ve postfix open-iscsi chrony -y

After installation, reboot the machine and open this in a browser:

https://<pve-ip>:8006

Enter the root password and you’ll see the PVE login page.

LVM Thin Volume

When creating the volumes earlier, I didn’t allocate the remaining space to LVM thin data. Configure it here.

Create the LVM thin pool:

lvcreate --type thin-pool -l 100%FREE -n data pve

Edit /etc/pve/storage.cfg and add:

lvmthin: local-lvm
        thinpool data
        vgname pve
        content rootdir,images

Refresh the web UI and it will show up.

Troubleshooting

If something breaks and you need to boot the live CD to repair it, do the following:

After booting the live CD

apt install dosfstools cryptsetup efibootmgr lvm2

Open the disk (use the device names lsblk reports):

cryptsetup luksOpen /dev/sda2 cryptlvm
vgchange -ay pve

Mount:

mount /dev/pve/root /mnt
mount /dev/sda1 /mnt/boot

Mount the other necessary filesystems:

mount -v -t proc none /mnt/proc
mount -v --rbind /sys /mnt/sys
mount -v --rbind /dev /mnt/dev
mount -v --make-rslave /mnt/sys
mount -v --make-rslave /mnt/dev

Enter the chroot:

chroot /mnt

When maintenance is done:

exit 
umount -R /mnt
reboot

What You Can Do Next

  • Hook PVE into the existing backup scheme
  • Remote unlock still relies on typing the passphrase; later this could move to a separate key service or TPM2

References