When provisioning Ubuntu Linux instances on AWS EC2, engineers face a fundamental architectural choice between two virtualization paradigms:
// Example showing instance launch parameters
aws ec2 run-instances \
--image-id ami-0abcdef1234567890 \
--instance-type t2.micro \
--virtualization-type hvm # or "paravirtual"
HVM provides complete hardware abstraction through:
- Full virtualization of CPU instructions (Intel VT-x/AMD-V)
- Hardware-assisted memory management (EPT/NPT)
- Native device drivers via virtio
The boot process in HVM:
1. BIOS/UEFI firmware initialization
2. GRUB2 bootloader execution
3. Linux kernel launch with HVM-specific modules
4. Virtio drivers initialization
PV operates through hypercalls rather than hardware emulation:
- Modified kernel with hypervisor awareness
- Frontend/backend driver architecture
- Shared memory rings for I/O
Performance-critical sectors where PV excels:
# Disk I/O benchmark comparison
pv: 4500 IOPS (avg)
hvm: 3800 IOPS (avg)
Critical factors for choosing in 2023:
Feature | HVM | PV |
---|---|---|
NVMe Support | Yes | No |
ENA Networking | Yes | Limited |
Converting PV AMI to HVM:
# Using AWS CLI tools
aws ec2 modify-image-attribute \
--image-id ami-0oldpvimage \
--virtualization-type hvm
When launching Ubuntu Linux instances on AWS EC2, you'll encounter two virtualization types:
- PV (Paravirtual): Uses modified OS kernels that communicate directly with hypervisor through hypercalls
- HVM (Hardware Virtual Machine): Provides full hardware virtualization with unmodified OS kernels
The fundamental architectural differences can be visualized:
# PV Architecture
Host Hardware → Hypervisor → PV Drivers → Guest OS
# HVM Architecture
Host Hardware → Hypervisor → Virtualized Hardware → Guest OS
Performance varies significantly between the two types:
Metric | PV | HVM |
---|---|---|
CPU Performance | Higher (direct hypercalls) | Lower (hardware emulation) |
I/O Performance | Depends on PV drivers | Better with EBS-optimized |
Boot Time | Faster | Slower |
Here's how to specify virtualization type when launching instances:
# AWS CLI example for PV
aws ec2 run-instances \
--image-id ami-12345678 \
--instance-type m1.small \
--virtualization-type paravirtual
# AWS CLI example for HVM
aws ec2 run-instances \
--image-id ami-87654321 \
--instance-type t2.micro \
--virtualization-type hvm
Current best practices suggest:
- Use HVM for most workloads (better hardware support)
- PV may be preferable for legacy applications
- Always check instance type compatibility
Watch for these virtualization-specific problems:
# Check virtualization type of running instance
aws ec2 describe-instances \
--instance-ids i-1234567890abcdef0 \
--query 'Reservations[].Instances[].VirtualizationType'
Remember that some newer instance types (like t3) only support HVM.