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(orlinux-image-cloud-arm64for 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.cfgincludes the relevant hyperscaler datasources:datasource_list: [ Ec2, Azure, None ]Azure Integration: Modern Azure images can use standard
cloud-initnatively for provisioning. If using the legacy Azure Linux Agent (walinuxagent), ensure it does not conflict withcloud-initby properly disabling user provisioning inside/etc/waagent.conf(Provisioning.UseCloudInit=y).Disk Expansion: Install
cloud-guest-utilsto automatically expand root partitions on boot when assigning custom volume sizes. Ensure thegrowpartandresizefsmodules are enabled in thecloud_init_moduleslist.
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
enadriver 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-networkdor standard/etc/network/interfacesusing predictable network interface names, or rely oncloud-initto 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/fstabusing UUIDs or filesystem labels rather than device nodes like/dev/xvdaor/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-clipackage 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/grubto 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-grubto apply changes. This configuration guarantees that system logs and emergency shells remain accessible directly through cloud management consoles.