← Back to list

Creating a KVM Virtual Machine Using an Ubuntu ISO

This guide walks you through creating a KVM virtual machine using an ISO image from the Linux terminal — no GUI required.

Chelsy Ratnawat · 2026-05-05 11:41 · 0 claps · 2.4 min read
#kvm-qemu #kvm #virtualization #virsh #kernel
Open on Medium ↗
Wiki topics: 🔓 · Open Source

Creating a KVM Virtual Machine Using an Ubuntu ISO

This guide walks you through creating a KVM virtual machine using an ISO image from the Linux terminal — no GUI required.

We will use Ubuntu 26.04 (Resolute Raccoon) beta server ISO as an example and explain every technical term along the way.

What is Virtualization?

Virtualization lets one physical computer run multiple virtual computers.

Each virtual machine (VM):

  • Has its own CPU, RAM and disk
  • Runs its own operating system
  • Is isolated from the host

This is how cloud providers like AWS/Azure work internally.

What is KVM?

KVM (Kernel-based Virtual Machine) is a feature built into the Linux kernel that turns Linux into a hypervisor.

Hypervisor = software that runs virtual machines.

KVM uses hardware virtualization (Intel VT-x / AMD-V) to run VMs at near-native speed.

What is libvirt?

Managing VMs manually using QEMU is complex.

libvirt is a management layer that:

  • Starts/stops VMs
  • Creates virtual networks
  • Manages storage
  • Provides CLI tools like virsh and virt-install

Think of libvirt as the VM manager service.

What is a Headless VM?

A headless VM runs with no graphical interface.

No window. No mouse. No desktop.

Instead, we control it using a serial console in the terminal.

This is how real servers run in:

  • Datacenters
  • Cloud platforms
  • DevOps environments
  • Kubernetes clusters

Headless VMs are:

  • Faster
  • Use less memory
  • Easier to automate

What is an ISO?

An ISO file is a bootable image of an operating system.

It is the virtual equivalent of a DVD installer.

We boot the VM from the ISO to install Ubuntu.

Step 1 — Download Ubuntu Server ISO

Ubuntu 26.04 will release soon, but beta images are available.

Download it:

wget https://releases.ubuntu.com/26.04/ubuntu-26.04-beta-live-server-amd64.iso

Step 2 — Install Virtualization Packages

Install required software:

apt update
apt install -y qemu-kvm libvirt-daemon-system libvirt-clients virtinst

Package explanation:

qemu-kvm — Runs the virtual machine libvirt-daemon-system — VM management service libvirt-clients — Tools like virsh virtinst — Tool used to create VMs

Step 3 — Start the Virtualization Service

Check service status:

systemctl status libvirtd

If not running:

systemctl enable --now libvirtd

This ensures VMs start automatically after reboot.

Step 4 — Move the ISO to the Correct Directory

Move the ISO:

mv /root/ubuntu-26.04-beta-live-server-amd64.iso /var/lib/libvirt/images/

Why this step is important:

Virtual machines run as a restricted user called libvirt-qemu.

For security reasons, this user cannot access /root.

The directory /var/lib/libvirt/images/ is the default VM storage location.

Step 5 — Create the Headless Virtual Machine

Run this command:

virt-install \
 --name ubuntu2604 \
 --ram 4096 \
 --vcpus 4 \
 --disk path=/var/lib/libvirt/images/ubuntu2604.qcow2,size=40 \
 --os-variant ubuntu24.04 \
 --location /var/lib/libvirt/images/ubuntu-26.04-beta-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \
 --network network=default \
 --graphics none \
 --console pty,target_type=serial \
 --extra-args 'console=ttyS0,115200n8'

Breaking Down the Command

— name ubuntu2604 Name of the VM — ram 4096 Assign 4GB RAM — vcpus 4 Assign 4 CPU cores — disk size=40 Create 40GB virtual hard disk — os-variant Helps optimize VM settings — location Boot installer from ISO — network defaultNAT internet access — graphics none Headless mode — console serial Terminal-based display — console=ttyS0 Send installer to terminal

Important concept:

We are redirecting the installer to a serial port, which allows it to appear in the terminal.

Step 6 — Connect to the VM Installer

Connect to console:

virsh console ubuntu2604

Your terminal is now the VM monitor.

Follow the Ubuntu installer:

  • Choose language
  • Create user/password
  • Select defaults
  • Wait for installation

When installation finishes, the VM reboots.

Managing the VM After Installation

List VMs:

virsh list --all

Start VM:

virsh start ubuntu2604

Connect to console:

virsh console ubuntu2604

Exit console safely:

CTRL + ]

You now have a fully functional headless Ubuntu server VM.

Happy virtualizing!


메타데이터
post_id
29d210a9f291
slug
creating-a-kvm-virtual-machine-using-an-ubuntu-iso-29d210a9f291
url
https://medium.com/@chelsyratnawat/creating-a-kvm-virtual-machine-using-an-ubuntu-iso-29d210a9f291
canonical_url
https://medium.com/@chelsyratnawat/creating-a-kvm-virtual-machine-using-an-ubuntu-iso-29d210a9f291
author_url
https://medium.com/@chelsyratnawat
status
ok
fetched_at
2026-07-19 15:11:09