Deploy Ubuntu 24.04 Server on KVM: A Complete Enterprise Guide for Modern Infrastructure

admineci

admineci

Auteur

1263 mots
Deploy Ubuntu 24.04 Server on KVM: A Complete Enterprise Guide for Modern Infrastructure

In today's rapidly evolving IT landscape, virtualization has become the cornerstone of modern infrastructure deployment. This comprehensive guide demonstrates how to deploy Ubuntu 24.04 Server on KVM using advanced command-line techniques, focusing on production-ready configurations. Learn how to leverage KVM's enterprise-grade capabilities, implement multiple network configurations with Open vSwitch, optimize performance, and integrate with cloud platforms like OpenStack...

Introduction

In today's rapidly evolving IT landscape, virtualization has become the cornerstone of modern infrastructure deployment. As organizations across Africa and beyond seek to modernize their IT systems, KVM (Kernel-based Virtual Machine) stands out as a robust, open-source virtualization solution that delivers enterprise-grade performance without the licensing costs of proprietary alternatives.

This comprehensive guide demonstrates how to deploy Ubuntu 24.04 Server on KVM using advanced command-line techniques, focusing on production-ready configurations that align with ECINTELLIGENCE's commitment to delivering reliable, performant, and sustainable infrastructure solutions.

Why KVM for Enterprise Virtualization?

KVM has emerged as the virtualization technology of choice for organizations prioritizing:

  • Cost Efficiency: Zero licensing fees with enterprise-grade capabilities
  • Performance: Near-native performance with hardware acceleration
  • Flexibility: Support for multiple operating systems and architectures
  • Integration: Seamless integration with OpenStack and cloud platforms
  • Security: Built into the Linux kernel with SELinux/AppArmor support

Prerequisites

Before beginning the deployment, ensure your host system meets these requirements:

  • Ubuntu 20.04+ or RHEL-based distribution
  • CPU with virtualization extensions (Intel VT-x or AMD-V)
  • Minimum 16GB RAM (for hosting multiple VMs)
  • 500GB+ storage space
  • KVM, QEMU, and libvirt packages installed
  • Open vSwitch (optional, for advanced networking)

Verify Virtualization Support

 

# Check CPU virtualization support
egrep -c '(vmx|svm)' /proc/cpuinfo

# Verify KVM modules are loaded
lsmod | grep kvm

Step 1: Download Ubuntu 24.04 Server ISO

First, download the latest Ubuntu 24.04 Server ISO image to your KVM host:

 

sudo wget -O /var/lib/libvirt/images/ubuntu-24.04-live-server-amd64.iso \
   https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-live-server-amd64.iso

This command downloads the ISO directly to the libvirt images directory, ensuring proper permissions and accessibility for the virtualization stack.

Step 2: Understanding virt-install Parameters

The virt-install command offers extensive customization options. Here's a breakdown of the key parameters we'll use:

  • --name: VM identifier used by libvirt
  • --memory: RAM allocation in MB
  • --vcpus: Number of virtual CPUs
  • --disk: Storage configuration with virtio drivers for optimal performance
  • --network: Network interface configuration
  • --graphics none: Headless installation via serial console
  • --console: Serial console configuration for remote access
  • --location: ISO location with kernel/initrd paths
  • --extra-args: Kernel parameters for serial console

Step 3: Create the Virtual Machine

Execute the following command to create a production-ready Ubuntu 24.04 Server VM:

 

sudo virt-install \
    --name ubuntu-server \
    --description "Ubuntu 24.04 Production Server" \
    --memory 8192 \
    --vcpus 4 \
    --disk path=/var/lib/libvirt/images/ubuntu-server.qcow2,size=100,bus=virtio,format=qcow2 \
    --os-variant ubuntu20.04 \
    --network network=management,model=virtio \
    --network bridge=baremetal,virtualport_type=openvswitch,model=virtio,driver.name=vhost \
    --network bridge=isolated01,virtualport_type=openvswitch,model=virtio,driver.name=vhost \
    --graphics none \
    --console pty,target_type=serial \
    --location /var/lib/libvirt/images/ubuntu-24.04-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \
    --extra-args 'console=ttyS0,115200n8 serial'

Key Configuration Highlights:

  1. Multiple Network Interfaces: Three network adapters for management, production, and isolated traffic
  2. VirtIO Drivers: Maximum performance for disk and network I/O
  3. Open vSwitch Integration: Enterprise-grade SDN capabilities
  4. Serial Console: Remote management without VNC overhead
  5. QCOW2 Format: Thin provisioning with snapshot support

Step 4: Ubuntu Server Installation Process

Once the VM starts, you'll be connected to the Ubuntu installer via serial console. Follow these steps:

1. Language and Keyboard Configuration

  • Select your preferred language (English recommended)
  • Choose appropriate keyboard layout

2. Network Configuration

Configure the primary network interface (enp1s0):

 

IP Address: 10.10.201.10/16
Gateway: 10.10.0.1
DNS: 8.8.8.8, 8.8.4.4

3. User Account and Hostname

  • Server name: ubuntu-server
  • Username: admin (or your preferred admin user)
  • Set a strong password
  • Enable SSH key authentication (recommended)

4. Storage Configuration

  • Accept the default LVM configuration
  • The installer will create:
    • /boot: 2GB ext4 partition
    • LVM volume group with root filesystem
    • Swap partition (optional)

5. Software Selection

  • Install OpenSSH server (essential for remote management)
  • Skip additional packages (install later as needed)

6. Complete Installation

After installation completes, select "Reboot Now"

Step 5: Post-Installation Verification

Once the system reboots, log in via serial console and verify the configuration:

Check Network Configuration

 

# Display network interfaces
sudo ip addr show

# Verify routing table
ip route

# Test connectivity
ping -c 4 google.com

Expected output:

 

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP
    inet 10.10.201.10/16 brd 10.10.255.255 scope global enp1s0
3: enp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
4: enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN

Verify Storage Configuration

 

# Check disk usage
df -h

# Display LVM configuration
sudo lvdisplay
sudo vgdisplay

Enable Remote SSH Access

From your KVM host:

 

ssh admin@10.10.201.10

Step 6: Optimization and Best Practices

1. Update the System

 

sudo apt update && sudo apt upgrade -y

2. Configure Additional Network Interfaces

Edit /etc/netplan/00-installer-config.yaml:

 

network:
  version: 2
  ethernets:
    enp1s0:
      addresses: [10.10.201.10/16]
      gateway4: 10.10.0.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
    enp2s0:
      addresses: [192.168.100.10/24]
    enp3s0:
      addresses: [172.16.0.10/24]

Apply configuration:

 

sudo netplan apply

3. Install Essential Tools

 

sudo apt install -y qemu-guest-agent htop net-tools

4. Enable Automatic Updates

 

sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades

Advanced Configurations

Implementing CPU Pinning for Performance

For mission-critical workloads, pin vCPUs to physical cores:

 

virsh vcpupin ubuntu-server 0 4
virsh vcpupin ubuntu-server 1 5
virsh vcpupin ubuntu-server 2 6
virsh vcpupin ubuntu-server 3 7

Storage Performance Tuning

Optimize disk I/O with cache settings:

virsh edit ubuntu-server

Add to the disk section:

 

<driver name='qemu' type='qcow2' cache='writeback' io='threads'/>

Network Performance Optimization

Enable multi-queue virtio for better network performance:

 

<interface type='network'>
  <driver name='vhost' queues='4'/>
</interface>

Integration with Cloud Platforms

OpenStack Integration

KVM serves as the default hypervisor for OpenStack deployments. To prepare VMs for OpenStack:

  1. Install cloud-init:

sudo apt install cloud-init

  1. Configure cloud-init for metadata service:

echo "datasource_list: [ OpenStack ]" | sudo tee /etc/cloud/cloud.cfg.d/90_dpkg.cfg

Ansible Automation

Create an Ansible playbook for automated deployments:

 

---
- name: Deploy Ubuntu VM on KVM
  hosts: kvm_hosts
  tasks:
    - name: Create VM using virt-install
      command: |
        virt-install --name {{ vm_name }} \
        --memory {{ vm_memory }} \
        --vcpus {{ vm_cpus }} \
        --disk path=/var/lib/libvirt/images/{{ vm_name }}.qcow2,size={{ vm_disk }},bus=virtio,format=qcow2 \
        --network network=management,model=virtio \
        --graphics none \
        --console pty,target_type=serial \
        --location {{ iso_path }} \
        --extra-args 'console=ttyS0,115200n8 serial'

Monitoring and Management

1. Resource Monitoring with virt-top

sudo apt install virt-top virt-top

2. Performance Metrics Collection

virsh domstats ubuntu-server --cpu-total --balloon --vcpu --interface --block

3. Backup Strategies

Create VM snapshots:

virsh snapshot-create-as ubuntu-server snapshot1 \ --description "Before system updates"

Export VM for backup:

virsh dumpxml ubuntu-server > ubuntu-server.xml

Security Considerations

1. SELinux/AppArmor Configuration

Ensure security modules are properly configured:

# For Ubuntu (AppArmor) sudo aa-status # For RHEL-based (SELinux) getenforce

2. Firewall Rules

Configure UFW for the management network:

sudo ufw allow from 10.10.0.0/16 to any port 22 sudo ufw enable

3. Regular Security Updates

Enable automatic security updates:

sudo dpkg-reconfigure -plow unattended-upgrades

Troubleshooting Common Issues

Serial Console Not Responding

  1. Verify console parameters in VM configuration
  2. Check kernel command line arguments
  3. Ensure serial-getty service is running

Network Connectivity Issues

  1. Verify bridge configuration on host
  2. Check firewall rules
  3. Validate Open vSwitch configuration

Performance Problems

  1. Monitor CPU steal time
  2. Check memory ballooning
  3. Analyze disk I/O patterns

Conclusion

Deploying Ubuntu 24.04 Server on KVM provides a robust foundation for modern infrastructure needs. This approach combines the stability of Ubuntu LTS with the flexibility and performance of KVM virtualization, creating an ideal platform for enterprise workloads.

The techniques demonstrated in this guide—from advanced networking configurations to performance optimization—reflect real-world production requirements. By leveraging open-source technologies like KVM and Open vSwitch, organizations can build scalable, efficient infrastructure without vendor lock-in.

As the IT landscape continues to evolve, mastering these virtualization techniques becomes increasingly valuable. Whether deploying application servers, development environments, or production workloads, the principles covered here provide a solid foundation for infrastructure modernization.

For organizations seeking to transform their IT infrastructure with reliable, performant, and sustainable solutions, KVM virtualization represents a strategic choice that aligns with both current needs and future growth.


ECINTELLIGENCE specializes in cloud, virtualization, and distributed storage solutions across Africa. Contact us at infos@ecintelligence.ma for expert consultation on your infrastructure modernization journey.

Partager cet article

Twitter LinkedIn

Vous avez un projet similaire ?

Nos experts sont là pour vous accompagner dans vos projets cloud et infrastructure.

Articles similaires

Nathan

Assistant virtuel ECINTELLIGENCE