Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Build a Hardened Kernel for IONOS CLOUD Confidential VMs

Note: Validated on Debian 13 (Trixie), kernel 6.12.101, using a standard IONOS CLOUD VM in August 2026.

When running a Confidential VM (CVM) using AMD SEV-SNP, attestation proves what software is running within the VM. However, attestation alone does not prevent an untrusted or curious hypervisor from interacting with the guest through exposed virtual devices, such as serial consoles, USB controllers, and host-guest sockets that the guest operating system (OS) has drivers to support.

The stronger guarantee is that the guest kernel contains no driver code that can use the interfaces. It isn't about the hypervisor promising not to attach a serial port; even if a serial port is presented, no code path exists in the guest to interact with it. When an attestation verifier checks the SEV-SNP measurement, it validates a kernel image that enforces this boundary at compile time.

This guide walks through building a hardened kernel for a IONOS CLOUD VM. The same approach applies to standard (non-CVM) VMs where you want an auditable, minimal attack surface without relying on runtime configuration.

Guest isolation guarantees

  • Dark console: The display remains blank after the EFI handoff. The VM runs, the network operates, and SSH functions, but no local console output is rendered.

  • Dead keyboard: No keyboard or input drivers exist in the kernel. Even if the hypervisor presents a virtual keyboard, the guest lacks the code paths to receive keystrokes.

  • No management channels: Serial ports, virtio-console, and vsock interfaces are removed. Unnecessary and potentially dangerous drivers are removed at compile time; only the drivers the guest needs to operate (networking and storage) stay active. See What this does not protect against below for the full list of residual bound drivers.

  • API-based shutdown: As interactive input is disabled, stop the VM using the IONOS CLOUD API or the stop option in the DCD. ACPI support stays enabled in the kernel so the guest can handle an ACPI power event if the host sends one, allowing systemd to initiate a clean shutdown. IONOS CLOUD does not guarantee ACPI delivery on every stop or reset — this is a best-effort clean shutdown path, not a guaranteed one.

A snapshot in time: Validated on Debian 13 (Trixie) with kernel 6.12.101 in August 2026. These concepts apply to other Linux distributions and kernel versions. Specific configuration options, defaults, and dependencies vary by platform — re-validate them for your target environment. Treat it as a starting point, not a copy-paste recipe.

Architecture

Building a hardened kernel happens on a system that is separate from the Confidential VM (CVM) that will eventually run it.

  • Kernel build system: A standard Compute instance — not a Confidential VM, and not necessarily an IONOS VM at all. Use a VM created just for this purpose, or an existing system you already use for kernel builds. This guide uses a standard IONOS CLOUD Compute Engine VM running Debian 13 (Trixie) as the build system; the resulting kernel and configuration approach are not specific to that choice.

  • Transfer: Once the hardened kernel package and its initrd are built, transfer both to the image factory that produces confidential images for your environment.

  • Attestation / image factory (for example, snp-guard): The image factory incorporates the kernel and initrd into the artifacts partition of a new confidential image, alongside the other components that make up the attestation measurement (firmware, kernel command line).

  • Deployment: The resulting confidential image is imported into IONOS CLOUD as a standard IaaS image, ready to start as a Confidential VM.

Architecture: building and deploying a hardened kernel for Confidential VMs

Scope of this guide: The build, configuration, and verification steps below (GRUB, grub-reboot, in-guest restart) run on the build system described above — a standard Compute VM, not a CVM. The CVM-specific deployment path (the artifacts partition, kernel command line measurement, and image import) is covered by your image factory's own documentation (for example, snp-guard) and is referenced but not duplicated here.

Overview

The kernel acts as a hardware allowlist. Even if the hypervisor presents unexpected devices, the guest kernel ignores them and prevents communication unless explicit drivers and configurations exist.

The framework approach

Completely disabling kernel subsystems (CONFIG_VT=n, CONFIG_INPUT=n) causes the standard Debian initramfs to stop responding during startup. Its udevadm settle process waits indefinitely for PNP events from the i8042 PS/2 controller that never complete because no drivers exist to process them.

A more surgical approach keeps the core kernel frameworks (Virtual Terminal (VT), Input Subsystem (INPUT), Human Interface Device (HID), Frame Buffer (FB)) intact for initialization coherence while removing every concrete hardware driver. Retaining a single console driver, CONFIG_VGA_CONSOLE=y in text mode, allows systemd to successfully open /dev/console at startup without exposing display output or accepting input on the KVM interface.

Before you begin

You need a standard IONOS CLOUD VM, also called the build VM, to compile the kernel. This is separate from your target VM. The build VM:

  • Runs a Debian 13 (Trixie), matching the target OS

  • Has at least 4 GB RAM and 2 vCPUs (more CPUs = faster build; 16 vCPUs takes approximately 6 minutes)

  • Has at least 20 GB free disk space for kernel source and build artifacts

The resulting .deb packages are installed on your target VM or fed into your image factory pipeline.

Procedure

1

Install build dependencies

linux-source-6.12 provides the kernel source tarball. linux-config-6.12 provides the Debian cloud kernel configuration as a starting point.

2

Extract the kernel source

The source tree unpacks to roughly 1.5 GB.

3

Start from the Debian cloud config

Debian's official cloud-amd64 kernel configuration is already stripped of most desktop and legacy hardware drivers. Using this configuration provides a sensible, production-ready starting point rather than building a kernel configuration from scratch.

4

Apply the hardening configuration

Create and run the hardening script:

Resolve any dependency changes automatically:

Note: If the build fails with unmet build dependencies: debhelper-compat (= 12), fix it using the following:

5

Verify the configuration

Before building, confirm key options are correct.

Management channels removed:

Expected — all # CONFIG_... is not set:

Input and HID drivers removed:

Expected — all # CONFIG_... is not set.

Console drivers — exactly as required:

Expected:

FRAMEBUFFER_CONSOLE is absent or not set.

Required drivers and CVM support:

Expected — all =y.

Note: Disabling CONFIG_DEBUG_FS against the default Debian cloud configuration will fail because the memory management subsystem selects it regularly. It does not present a meaningful attack surface without root access to mount or read the debug filesystem.

6

Build the kernel

Build time is approximately 6 minutes on 16 vCPUs, or 20–30 minutes on 2–4 vCPUs. Upon completion, packages appear in the parent directory:

7

Install

8

Configure startup hardening

Add a Grand Unified Bootloader (GRUB) configuration snippet in /etc/default/grub.d/ to suppress residual console output while preserving a functional menu timeout during testing.

Mask the getty services to prevent login prompts from appearing on the dark console:

Note: IONOS CLOUD images ship with /etc/default/grub.d/15_timeout.cfg containing GRUB_TIMEOUT=0. The 20_hardening.cfg file above overrides this during development. Reduce or eliminate the GRUB menu timeout once your build is validated for production.

Note: IONOS CLOUD images may include console=ttyS0 for serial access. With CONFIG_SERIAL_8250=n set in the hardened kernel, this argument is ignored. Leave it in place; it does no harm and allows stock recovery kernels started from GRUB to retain serial access.

9

Restart and verify

Use grub-reboot to start the new kernel exactly once. It reverts to the previous default if something fails:

After the VM comes back (30–60 seconds), verify:

Once confirmed, set the hardened kernel as the permanent default:

10

Verify the DCD console behaviour

Open the DCD console for the VM during a restart to confirm the expected output:

  1. GRUB Menu (Visible): GRUB has its own display support, independent of the Linux kernel.

  2. Loading Linux or initial ramdisk: GRUB is loading the kernel.

  3. EFIstub: Loaded initrd from...: Kernel EFI stub confirms initrd handoff.

  4. Black screen: Kernel starts. Video Graphics Array (VGA) text-mode console is registered but produces no output; loglevel=0 suppresses everything else.

The screen stays black for the remainder of the VM's life. The VM runs normally, SSH works, and the network is up, but the console is silent and non-interactive.

Note: This step applies to a standard IONOS CLOUD VM used for testing. For Confidential VMs, remote console access is not currently available from the DCD.

Note: To diagnose a startup failure, temporarily remove quiet loglevel=0 from the kernel command line by editing the GRUB menu entry with e at startup. This exposes complete kernel startup messages on the DCD console. Restore the parameters once troubleshooting is complete.

Optional: Remove kernel modules

For maximum assurance on a production CVM, disable loadable kernel modules:

Add this to harden.sh before make olddefconfig.

Implications:

  • Every required driver must be compiled into the kernel (=y). For a CVM in general, CONFIG_SEV_GUEST works as either =y or =m — the kernel only fails to function as a CVM if it's disabled entirely. Once loadable modules are disabled (CONFIG_MODULES=n, this section), it must be =y, since a =m driver could never load. This guide uses =y throughout for that reason.

  • modprobe, insmod, and lsmod are non-functional because runtime driver loading is disabled in the kernel.

  • The full driver set is determined at build time and fixed. The attestation measurement proves that the kernel actually running is the exact kernel you built and supplied in the artifacts partition — not a substituted or modified one. Without CONFIG_MODULES=n, this identity proof only covers the kernel binary itself: modules loaded later from the (unmeasured) root file system are outside what the measurement verifies, so the built-in driver set it attests to would not be the complete picture. With CONFIG_MODULES=n, confirming the kernel's identity confirms its entire driver set, because nothing can be added afterward.

After adding CONFIG_MODULES=n, always perform a test restart before deploying to production.

Alternative: firmware-verified signed modules. Disabling CONFIG_MODULES=n is not the only way to close the unmeasured-module gap. Depending on your build process, your environment, and your CVM firmware, you can instead supply firmware that cryptographically verifies your kernel's signature before allowing it to run. The Linux kernel also supports the use of signed modules. Your approach to ensure code integrity can go far beyond this how-to.

Optional: Remove hypervisor capability

A CVM operates as a guest running inside a hypervisor; it does not require nested virtualization capabilities. Removing KVM support from the CVM kernel eliminates this capability at compile time. Even if the CVM is compromised, an attacker cannot instantiate nested VMs. With CONFIG_MODULES=n also in place, this becomes a cryptographically verifiable guarantee: an attestation verifier checking the kernel measurement can confirm KVM is absent from the running kernel, not just from the image you built. Without CONFIG_MODULES=n, the measurement only covers the kernel binary itself, so it cannot rule out a KVM-capable module loaded later from the unmeasured root file system.

Note: AMD SEV-SNP does not support nested virtualisation. Removing KVM from a CVM kernel is therefore not just a security choice. It correctly reflects what the platform supports.

Add to harden.sh:

Retain the guest-side features that improve the performance of the guest on a hypervisor:

Option

Action

Reason

CONFIG_KVM

Remove

Hypervisor host capability

CONFIG_KVM_AMD

Remove

AMD-specific host capability

CONFIG_KVM_INTEL

Remove

Intel-specific host capability (irrelevant on AMD; remove)

CONFIG_HYPERVISOR_GUEST

Keep

Tells the kernel it is running inside a hypervisor and enables paravirt optimisations.

CONFIG_KVM_GUEST

Keep

Guest-side paravirt clock and KVM guest hooks; improves performance.

CONFIG_VIRT_DRIVERS

Keep

Required by CONFIG_SEV_GUEST. Do not disable.

After make olddefconfig, verify:

Security properties and limitations

What this achieves

Property

Mechanism

No serial console

CONFIG_SERIAL_8250=n. No Universal Asynchronous Receiver-Transmitter (UART) driver.

No virtio-console or vsock channel

CONFIG_VIRTIO_CONSOLE=n CONFIG_VSOCKETS=n

No USB interaction

CONFIG_USB=n. No USB stack.

No keyboard input

CONFIG_INPUT_KEYBOARD=n CONFIG_SERIO=n. No keyboard driver.

No Ctrl-Alt-Del

Keyboard input cannot reach the kernel.

Screen dark at runtime

VGA_CONSOLE in text mode, loglevel=0; no framebuffer console.

No runtime kernel replacement

CONFIG_KEXEC=n

Shutdown without keyboard (best effort)

Advanced Configuration and Power Interface (ACPI) power button, if delivered by the API or DCD stop action — not guaranteed on every stop or reset.

What this does not protect against

  • Network traffic metadata — the hypervisor observes packet sizes, timing, and IP addresses. SEV-SNP encrypts RAM but not network metadata. Use TLS or mTLS for all traffic.

  • Storage integrity — the hypervisor controls what blocks virtual storage returns. Use LUKS2 dm-crypt with a key obtained using attestation, not stored on the image.

  • PCI device enumeration — the guest kernel can still list PCI devices it has no driver for. This is harmless and expected.

  • AHCI SATA driver — the emulated SATA controller has a driver bound in this configuration (CONFIG_ATA is not disabled). No SATA disk is attached in a standard IONOS CLOUD virtio VM, so it is inert in practice. For stricter builds, add CONFIG_ATA=n to harden.sh.

  • virtio-balloon, virtio-rng, and other Debian cloud-config defaults — harden.sh above only disables the drivers listed in this guide (input, HID, USB, DRM, serial/console transports). It does not audit every driver the Debian cloud base config (config.amd64_none_cloud-amd64) enables by default. Check your own build's .config for additional bound virtio-* drivers beyond virtio-blk/virtio-net, and disable any you don't need.

Attestation integration

For a CVM, the kernel command line is part of the cryptographic measurement that the platform takes when the VM starts. Place it in the mandatory kernel-params.txt file in the /artifacts/ directory of the LAUNCH_ARTIFACTS partition — see Prepare a Confidential VM image for the full partition layout and file requirements:

kernel-params.txt must stay a single line and under 4 KB. The AMD Secure Processor includes its contents in this measurement alongside firmware-code.fd, vmlinuz, and initrd.img — no separate hashing step is needed. An altered command line produces a different measurement, and attestation fails.

Troubleshooting

VM does not come back after restart

  1. The hardened kernel may have failed to start. If you have used grub-reboot, the previous kernel will start on the next attempt.

  2. Before building, verify that CONFIG_VIRTIO_NET=y is in .config.

  3. Run update-initramfs -u before restarting to ensure the initramfs includes virtio-net.

SSH fails but VM is running

  • Verify CONFIG_VIRTIO_NET=y and CONFIG_VIRTIO_PCI=y.

  • Run update-initramfs -u on the installed kernel to ensure the initramfs includes the virtio-net module.

Unexpected options re-enabled by make olddefconfig

After harden.sh and olddefconfig, re-run the verification greps. If an option comes back enabled, it has an unsatisfied dependency pulling it in. Add an explicit $SC --disable for that option to harden.sh and re-run.

Unable to shut down the VM

Verify CONFIG_ACPI=y. The IONOS CLOUD API and DCD stop action can deliver an ACPI power button event, but this is not guaranteed on every stop; without ACPI support, the VM can only be hard-reset.

Summary checklist

Error

Config or action

Base: Debian cloud-amd64 config

config.amd64_none_cloud-amd64.xz

kexec / hibernation / SysRq disabled

CONFIG_KEXEC=n HIBERNATION=n MAGIC_SYSRQ=n

No serial UART

CONFIG_SERIAL_8250=n

No virtio-console or vsock

CONFIG_VIRTIO_CONSOLE=n VSOCKETS=n

No USB

CONFIG_USB=n

No DRM

CONFIG_DRM=n

No keyboard / mouse / SERIO

INPUT_KEYBOARD=n INPUT_MOUSE=n SERIO=n

No HID drivers

HID_GENERIC=n HIDRAW=n USB_HID=n

No framebuffer console

CONFIG_FRAMEBUFFER_CONSOLE=n

VGA text console retained

CONFIG_VGA_CONSOLE=y VT_CONSOLE=y

ACPI retained

CONFIG_ACPI=y

virtio-blk / virtio-net retained

CONFIG_VIRTIO_BLK=y VIRTIO_NET=y

SEV_GUEST built-in

CONFIG_SEV_GUEST=y

Hypervisor capability removed (optional)

CONFIG_KVM=n CONFIG_KVM_AMD=n CONFIG_KVM_INTEL=n

Built with make bindeb-pkg

quiet loglevel=0 in GRUB cmdline

/etc/default/grub.d/20_hardening.cfg

getty services masked

systemctl mask getty.target serial-getty.target

Start verified through SSH

DCD console dark and non-interactive (standard VM test)

ACPI power button handling verified (best effort, not guaranteed by IONOS)

DCD stop / API stop

Last updated

Was this helpful?