Deploy Debian Seamlessly on AWS and Azure

Deploying the Debian operating system inside cloud environments like Amazon Web Services (AWS) and Microsoft Azure requires specific configurations to ensure high performance, reliable automation, and platform integration. This article outlines the essential components needed for seamless deployment, focusing on the cloud-optimized kernel, cloud-init provisioning, storage and networking drivers, and serial console management.

Use the Cloud-Optimized Kernel

Debian provides specialized kernel packages designed specifically for virtualized hyperscaler environments. Instead of standard generic kernels, install the cloud-tailored package:

  • Package: linux-image-cloud-amd64 (or linux-image-cloud-arm64 for Graviton and Ampere instances).
  • Benefits: This kernel strips out legacy bare-metal device drivers, substantially reducing image size, speeding up boot times, and pre-compiling critical paravirtualization modules required by hypervisors (such as KVM on AWS Nitro and Hyper-V on Azure).

Standardize Automated Provisioning with Cloud-Init

cloud-init is the industry standard for handling early instance initialization, user provisioning, and metadata discovery.

  • Datasource Configuration: Ensure /etc/cloud/cloud.cfg includes the relevant hyperscaler datasources:

    datasource_list: [ Ec2, Azure, None ]
  • Azure Integration: Modern Azure images can use standard cloud-init natively for provisioning. If using the legacy Azure Linux Agent (walinuxagent), ensure it does not conflict with cloud-init by properly disabling user provisioning inside /etc/waagent.conf (Provisioning.UseCloudInit=y).

  • Disk Expansion: Install cloud-guest-utils to automatically expand root partitions on boot when assigning custom volume sizes. Ensure the growpart and resizefs modules are enabled in the cloud_init_modules list.

Configure Drivers and Networking

Both AWS and Azure rely on platform-specific hardware acceleration for networking and storage throughput.

  • AWS ENA (Elastic Network Adapter): The cloud kernel includes the ena driver out of the box. Verify that the AMI attribute for enhanced networking is enabled (enaSupport=true).
  • Azure Accelerated Networking: To utilize SR-IOV for near-line-rate networking on Azure, ensure the Mellanox drivers (mlx4_core, mlx5_core) are loaded.
  • Persistent Naming: Configure network interfaces through systemd-networkd or standard /etc/network/interfaces using predictable network interface names, or rely on cloud-init to render valid network configurations via metadata.

Storage and Partition Alignment

Predictable disk mapping prevents boot failures during cloud migrations or instance resizing:

  • UUID-based Mounts: Always mount storage in /etc/fstab using UUIDs or filesystem labels rather than device nodes like /dev/xvda or /dev/sda, as block device assignments can change between cloud instance types.
  • NVMe Compatibility: Modern AWS Nitro and Azure instances expose storage via NVMe interfaces. Include the nvme-cli package to map NVMe device names to standard volume identifiers.

Enable Serial Console and Remote Diagnostics

Headless cloud environments require alternative out-of-band debugging methods when SSH fails.

  • GRUB Configuration: Configure /etc/default/grub to direct console output to the serial port, enabling the AWS EC2 Serial Console and Azure Serial Console:

    GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200n8 earlyprintk=ttyS0,115200"
    GRUB_TERMINAL="serial console"
    GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
  • Run update-grub to apply changes. This configuration guarantees that system logs and emergency shells remain accessible directly through cloud management consoles.