Build a Hardened Kernel for IONOS CLOUD Confidential VMs
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, andvsockinterfaces 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
systemdto 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.
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.

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
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.
Verify the DCD console behaviour
Open the DCD console for the VM during a restart to confirm the expected output:
GRUB Menu (Visible): GRUB has its own display support, independent of the Linux kernel.
Loading Linux or initial ramdisk: GRUB is loading the kernel.
EFIstub: Loaded initrd from...: Kernel EFI stub confirms initrd handoff.Black screen: Kernel starts. Video Graphics Array (VGA) text-mode console is registered but produces no output;
loglevel=0suppresses 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.
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_GUESTworks as either=yor=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=mdriver could never load. This guide uses=ythroughout for that reason.modprobe,insmod, andlsmodare 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. WithCONFIG_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.
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.
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_ATAis not disabled). No SATA disk is attached in a standard IONOS CLOUD virtio VM, so it is inert in practice. For stricter builds, addCONFIG_ATA=ntoharden.sh.virtio-balloon, virtio-rng, and other Debian cloud-config defaults —
harden.shabove 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.configfor additional boundvirtio-*drivers beyondvirtio-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
The hardened kernel may have failed to start. If you have used
grub-reboot, the previous kernel will start on the next attempt.Before building, verify that
CONFIG_VIRTIO_NET=yis in.config.Run
update-initramfs -ubefore restarting to ensure the initramfs includesvirtio-net.
SSH fails but VM is running
Verify
CONFIG_VIRTIO_NET=yandCONFIG_VIRTIO_PCI=y.Run
update-initramfs -uon the installed kernel to ensure the initramfs includes thevirtio-netmodule.
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?