Archival Notice
This guide was written for legacy Xen 4 and KVM hypervisor deployments on Enterprise Linux 6. Please note that Enterprise Linux 6 has reached End of Life (EOL), and modern hypervisor deployments utilize updated libvirt and virt-install CLI syntax. Please refer to official vendor documentation for current virtualization specifications.
When managing standalone Xen or KVM hypervisors in enterprise data centers, relying on graphical virtual machine managers is highly inefficient during large-scale deployments. Mastering the command-line virt-install utility allows sysadmins to script and provision virtual machines instantly.
In this guide, I will walk you through configuring Linux network bridges (ifcfg-br0), provisioning Hardware Virtual Machine (HVM) and paravirtualized guests using virt-install, allocating raw storage disks, and mounting installation media over local directories and HTTP trees.
Prerequisites
You will need an Enterprise Linux hypervisor with root privileges, configured with libvirt and virt-install utilities, alongside available ISO installation media.
Step 1: Configuring Hypervisor Network Bridging (ifcfg-br0)
Before launching virtual machines, configure a dedicated network bridge (br0) on your hypervisor to allow guest VMs to attach directly to your local subnet.
# Backup existing interface configuration
cp /etc/sysconfig/network-scripts/ifcfg-bond0 /etc/sysconfig/network-scripts/ifcfg-br0
Update /etc/sysconfig/network-scripts/ifcfg-br0:
# /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Bridge"
BOOTPROTO="none"
IPADDR="192.168.0.50"
PREFIX="24"
GATEWAY="192.168.0.1"
Restart networking to activate the bridge:
service network restart
brctl show
Step 2: Provisioning HVM Guests via ISO Media
To launch a full Hardware Virtual Machine (HVM) guest booting from a local ISO image, execute the following virt-install command. This allocates 16 GB of RAM, provisions a 360 GB raw disk, attaches to our bridge, and exposes a VNC console.
# Launch HVM Guest VM from ISO
virt-install --name fmcivragpvm22 \
--ram 16384 \
--cdrom /root/CentOS-6.5-x86_64-bin-DVD1.iso \
--disk path=/VirtualMachines/fmcivragpvm22/disk.img,size=360,format=raw,sparse=false \
--network bridge=br1 \
--graphics vnc,listen=0.0.0.0 \
--os-type=linux --os-variant=rhel6 \
--hvm \
--boot cdrom,hd
Step 3: Provisioning Paravirtualized Guests via Local Directory
If mounting installation media over a local directory (/mnt/centos/), provision a lightweight paravirtualized guest without graphical overhead (--graphics none):
# Launch Paravirtualized Guest from local directory tree
virt-install --name agent \
--ram 4096 \
--location=/mnt/centos \
--disk path=/VirtualMachines/agent/disk.img,size=20,format=raw \
--network bridge=br0 \
--graphics none \
--os-type=linux --os-variant=rhel6
Step 4: Provisioning Enterprise VMs via HTTP Installation Trees
When provisioning enterprise servers across multiple data centers, you can direct virt-install to pull OS installation trees over HTTP, assigning dual vCPUs and attaching directly to Spice graphical consoles.
# Launch VM pulling installation media over HTTP
virt-install \
--name=guest1-rhel5-64 \
--file=/var/lib/libvirt/images/guest1-rhel5-64.dsk \
--file-size=8 \
--nonsparse --graphics spice \
--vcpus=2 --ram=2048 \
--location=http://example1.com/installation_tree/RHEL5.6-Server-x86_64/os \
--network bridge=br0 \
--os-type=linux \
--os-variant=rhel5.4
VM Provisioning Active
Your Xen/KVM virtual machines are now successfully provisioned and initializing! You can connect to their VNC or Spice displays to complete operating system configurations.