Skip to content

Booting an Encrypted Custom OS

Everything in Booting a Custom OS applies here too, with one addition: the OS volume itself is LUKS2-encrypted, and it only unlocks after the instance proves, via the same SEV-SNP attestation chain described above, that it is genuine, unmodified hardware running exactly the boot chain you built. This pairs data-at-rest protection with the data-in-use protection CC already gives you, closing the gap between the two.

Warning

Confidential Computing instances cannot reboot from inside the guest. Each step that "restarts" the VM means: Shutdown (or force_shutdown) and then Start through the Verda console or API, never from inside the guest. Additionally, after every future restart of this instance, not just the first one, you must run the attest-and-unlock step below again before the OS will boot.

How it works

  • Same rescue/flash mechanism as Booting a Custom OS, but the image built here has an encrypted root: everything except /boot and the EFI partition lives inside a LUKS2 container.
  • After flashing, every boot lands in a purpose-built initramfs that generates a fresh, one-time SSH key in RAM, produces a SEV-SNP report bound to that key, and waits: the disk stays locked until this step passes.
  • A script on your local machine fetches that report, verifies AMD's signature chain, recomputes the expected launch measurement, and confirms the report is bound to the key it's talking to. Only if all of that checks out does it send the disk passphrase.
  • Because nothing about an unlock is remembered across a power cycle, this repeats on every boot: each restart re-proves the machine is genuine before the OS can start, not just the first time.
File What it does
encrypted_00_build_image.sh Local, run as root. Downloads and customizes an Ubuntu 26.04 image, then builds the encrypted disk: an unencrypted /boot (kernel + a special unlock initramfs) and a LUKS2-encrypted root. Also sets up a first-boot step that grows the encrypted root to fill the disk.
encrypted_attested_initramfs.sh Called by the build script (you don't run it yourself). Installs the attestation + unlock logic into the initramfs: the fresh per-boot SSH key, the SEV-SNP report server, and the logic that swaps in the decrypted root once unlocked.
encrypted_01_setup_initramfs_ssh.sh Local. Same rescue-mode step as Booting a Custom OS: pauses the instance in a RAM-only initramfs so its disk can be safely overwritten.
encrypted_02_flash.sh Local. Streams the encrypted image onto the instance's disk, then powers it off.
encrypted_03_attest_and_unlock.sh Local. Run after every boot: verifies the AMD signature and the launch measurement, confirms the report is bound to the SSH key it's talking to, and only then sends the disk passphrase so the encrypted OS can boot.

Prerequisites

  • A Verda CVM instance with SSH access as root.
  • On your local machine:
$ sudo apt-get install -y libguestfs-tools qemu-utils cryptsetup gdisk rsync pv

Download the helper scripts and sample env file into a working directory:

$ chmod +x *.sh

1. Configure

$ cp encrypted_env_sample.txt .env
$ # Edit .env: set REMOTE (root@<instance-ip>); SSH_KEY defaults to your ed25519 key; set LUKS_PASS

2. Build the encrypted OS image

$ sudo ./encrypted_00_build_image.sh
$ scp "$REMOTE":/boot/OVMF.amdsev.fd verify/OVMF.amdsev.fd
This builds Ubuntu 26.04 specifically. The tool relies on Debian/Ubuntu's own package manager and initramfs mechanism (apt, initramfs-tools), so it doesn't generalize to other distro families (Fedora, RHEL, and similar).

Adding your own customization: the script installs the base image via a single virt-customize call. Add more flags to that same call to bake in anything else you need.

It also produces the encrypted raw image plus a verify/ folder (kernel, initrd, cmdline) used by the attestation step later. The second command copies the instance's current firmware so the expected measurement can be computed; do this before flashing overwrites the instance.

3. Boot into the rescue initramfs

$ ./encrypted_01_setup_initramfs_ssh.sh

Same as Booting a Custom OS: installs the pause hook and rebuilds the initramfs. When prompted, Shutdown and then Start the instance through the Verda console or API.

4. Flash the new OS

$ ./encrypted_02_flash.sh

Streams the encrypted image onto the disk. When prompted, force-stop the instance (console Force shutdown or API force_shutdown: the paused initramfs does not answer a normal Shutdown) and Start it; it boots into the attested unlock initramfs and waits.

5. Attest and unlock

$ ./encrypted_03_attest_and_unlock.sh

Verifies the AMD signature chain, checks the launch measurement against what you built, confirms the SEV-SNP report is bound to the SSH key it's talking to, and, only if everything checks out, sends the disk passphrase. The instance then boots into your encrypted OS. Run this same command again after every future restart to unlock it.

6. Confirm the encryption

$ cryptsetup status cryptroot

/dev/mapper/cryptroot is active.
  type:    LUKS2
  cipher:  aes-xts-plain64
  keysize: 512 bits
  key location: keyring
  device:  /dev/vda4

type: LUKS2 and a real cipher/keysize confirm / is genuinely backed by an encrypted LUKS volume, not a plain partition. If you ever see is inactive here, the unlock in step 5 didn't actually succeed.