virt-install Command
Advanced Virtualization man(1)Create and install KVM virtual machines
📅 Updated: Mar 16, 2026
SYNTAX
virt-install [OPTIONS]
What Does virt-install Do?
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.
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.
Options & Flags
| Option | Description | Example |
|---|---|---|
| --name NAME | Set the VM name | --name webserver |
| --ram SIZE | Set memory in MB (or --memory) | --ram 2048 |
| --vcpus N | Set number of virtual CPUs | --vcpus 2 |
| --disk | Define storage (size, path, format) | --disk size=20,format=qcow2 |
| --cdrom FILE | Attach ISO for installation | --cdrom /iso/ubuntu-22.04.iso |
| --os-variant NAME | Optimize for specific OS | --os-variant ubuntu22.04 |
| --network | Configure network (bridge, NAT, etc.) | --network bridge=br0 |
| --graphics | Set display type (vnc, spice, none) | --graphics vnc,listen=0.0.0.0 |
| --noautoconsole | Do not automatically open console | --noautoconsole |
| --import | Import existing disk (skip installation) | --import --disk path=/images/cloud.qcow2 |
Practical Examples
#1 Create VM from ISO
Create a 2GB RAM, 2 vCPU VM with 20GB disk. Boots from Ubuntu ISO with VNC console for installation.
$ 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#2 Create from cloud image
Import a pre-built cloud image with cloud-init for initial configuration. No installation needed.
$ 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#3 Minimal headless server VM
Network install with serial console only — fully headless. Perfect for server VMs.
$ 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"#4 Automated install with kickstart
Unattended RHEL installation using a kickstart file. VM installs itself without user interaction.
$ 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#5 VM with multiple disks
Create VM with two disks: 20GB for OS and 100GB for data storage.
$ virt-install --name fileserver --ram 4096 --vcpus 2 --disk size=20 --disk path=/images/data.qcow2,size=100 --cdrom /iso/ubuntu.iso --os-variant ubuntu22.04 --network bridge=br0#6 List available OS variants
Find the correct --os-variant value. The variant optimizes virtio drivers, disk bus, and other settings.
$ osinfo-query os | grep -i ubuntuTips & Best Practices
Always use --os-variant: os-variant optimizes VM hardware for the guest OS (virtio drivers, bus types, timer settings). List options: osinfo-query os or virt-install --osinfo list
Cloud images save time: Use pre-built cloud images with --import instead of installing from ISO. Download from cloud-images.ubuntu.com or similar. Combined with cloud-init, VMs are ready in seconds.
Bridge vs NAT networking: Use --network bridge=br0 for VMs that need to be accessible from the network. Default NAT (--network default) only allows outbound connections from the VM.
Use --noautoconsole for scripting: Add --noautoconsole when running virt-install in scripts. Otherwise the command blocks waiting for you to interact with the console.
Frequently Asked Questions
How do I create a VM in Linux from command line?
virt-install --name myvm --ram 2048 --vcpus 2 --disk size=20 --cdrom /path/to.iso --os-variant generic --network bridge=br0. This creates and starts installation.
How do I create a VM from a cloud image?
Download the cloud image, then: virt-install --name vm --import --disk path=cloud-image.qcow2 --ram 2048 --vcpus 2 --cloud-init root-password-generate=on --noautoconsole
How do I install Ubuntu on KVM?
virt-install --name ubuntu --ram 2048 --vcpus 2 --disk size=25 --cdrom ubuntu-22.04.iso --os-variant ubuntu22.04 --network bridge=br0 --graphics vnc. Connect via virt-viewer or VNC client.
How do I automate VM installation?
Use kickstart (RHEL/CentOS) or preseed (Debian/Ubuntu) with --initrd-inject and --extra-args. Or use cloud images with cloud-init for instant provisioning.
Related Commands
More Virtualization Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →