🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

🔮 Virtualization March 7, 2026 4

Linux Command: virt-install

Create and install KVM virtual machines

Terminal — Virtualization
Command
$ virt-install --name webserver --ram 2048 --vcpus 2 --disk size=20,format=qcow2 --cdrom /iso/ubuntu-22.04-server.iso --os-variant ubuntu22.04 --network bridge=br0 --graphics vnc
Output
Create a 2GB RAM, 2 vCPU VM with 20GB disk. Boots from Ubuntu ISO with VNC console for installation.

The virt-install command creates new KVM/QEMU virtual machines and begins the guest OS installation process. It provisions VM resources (CPU, memory, disk, network), connects installation media (ISO, network, PXE), and starts the installer — all from the command line. virt-install is the standard way to create VMs on Linux KVM hosts. It generates the libvirt XML domain definition and handles the complexities of QEMU command-line arguments, making VM creation straightforward. It supports a wide range of installation methods: local ISO files, network installs (HTTP/FTP), PXE boot, existing disk images (cloud images), and import from other hypervisors. For cloud and automation workflows, virt-install supports cloud-init, unattended installations (preseed/kickstart), and headless operation — enabling fully automated VM provisioning without interactive installers. Combined with virsh for lifecycle management and qemu-img for disk management, virt-install completes the KVM administration toolkit.

Syntax

virt-install [OPTIONS]

Common Examples

  • virt-install --name webserver --ram 2048 --vcpus 2 --disk size=20,format=qcow2 --cdrom /iso/ubuntu-22.04-server.iso --os-variant ubuntu22.04 --network bridge=br0 --graphics vnc — Create a 2GB RAM, 2 vCPU VM with 20GB disk. Boots from Ubuntu ISO with VNC console for installation.
  • virt-install --name cloudvm --ram 2048 --vcpus 2 --import --disk path=/images/ubuntu-cloud.qcow2 --os-variant ubuntu22.04 --network bridge=br0 --cloud-init root-password-generate=on --noautoconsole — Import a pre-built cloud image with cloud-init for initial configuration. No installation needed.
  • virt-install --name dbserver --ram 4096 --vcpus 4 --disk size=50 --location https://mirror.example.com/ubuntu/dists/jammy/main/installer-amd64/ --os-variant ubuntu22.04 --network bridge=br0 --graphics none --console pty,target_type=serial --extra-args "console=ttyS0" — Network install with serial console only — fully headless. Perfect for server VMs.
  • virt-install --name rhelvm --ram 2048 --vcpus 2 --disk size=30 --location /iso/RHEL-9.iso --os-variant rhel9.0 --initrd-inject /path/ks.cfg --extra-args "inst.ks=file:/ks.cfg console=ttyS0" --noautoconsole — Unattended RHEL installation using a kickstart file. VM installs itself without user interaction.

Pro Tips

    Master this and 230+ other Linux commands with our comprehensive eBooks and cheat sheets.

    Share this tip