How to Deploy Multiple Virtual Machines using Network Install (HTTP, FTP and NFS) under KVM Environment Introduction

Virtual machines (VMs) are a powerful tool for creating and managing multiple operating systems on a single physical machine. They allow you to run different operating systems, applications, and services without the need for additional hardware. Through network installation methods using HTTP, FTP, and NFS servers, you can deploy multiple VMs efficiently using centralized installation media accessed over the network.

Instead of having multiple physical computers with their own dedicated resources, VMs share the resources of the host machine. This approach enables you to create isolated environments that can simulate different computing scenarios or test new software without interfering with other processes.

Setting up the KVM Environment

Installing KVM on the Host Machine

Before deploying multiple virtual machines, you need to have a host machine that can run the KVM environment. Installing KVM on your host machine is straightforward using your operating system's package manager. For Debian-based distributions like Ubuntu

sudo apt-get install qemu-kvm libvirt-bin virtinst bridge-utils virt-manager

Once installed, you will have access to the virt-manager tool which provides a graphical interface for managing virtual machines.

Creating a Virtual Network

To deploy multiple virtual machines using network install, create a virtual network that acts as a bridge between your host machine and the VMs. All traffic going in and out of these VMs will pass through this virtual network.

Using virt-manager, go to Edit ? Connection Details ? Virtual Networks ? Add Network and follow the wizard. You can choose NAT or bridged networking depending on your requirements.

Configuring DHCP and DNS Services

Configure DHCP and DNS servers so VMs can obtain IP addresses and resolve domain names. We'll use dnsmasq as it is lightweight and easy to configure

sudo apt-get install dnsmasq

Edit the dnsmasq configuration file at /etc/dnsmasq.conf

interface=virbr0
dhcp-range=192.168.122.50,192.168.122.100,255.255.255.0,12h
dhcp-option=option:router,192.168.122.1

This configuration tells dnsmasq to listen on the virtual network interface virbr0, assign IP addresses in the range 192.168.122.50 to 192.168.122.100, and set the default gateway to 192.168.122.1.

Restart dnsmasq to apply changes

sudo systemctl restart dnsmasq

Preparing Network Installation Servers

Setting up HTTP Server

Install and configure an HTTP server to host installation files

sudo apt-get install apache2
sudo mkdir -p /var/www/html/centos
# Copy ISO contents to /var/www/html/centos/
sudo systemctl start apache2

Setting up FTP Server

For FTP-based installations, install vsftpd

sudo apt-get install vsftpd
sudo mkdir -p /srv/ftp/centos
# Copy ISO contents to /srv/ftp/centos/
sudo systemctl start vsftpd

Setting up NFS Server

Network File System (NFS) allows sharing files between hosts over a network

sudo apt-get install nfs-kernel-server
sudo mkdir -p /srv/nfs/centos
# Copy ISO contents to /srv/nfs/centos/
echo "/srv/nfs/centos *(ro,sync,no_root_squash)" | sudo tee -a /etc/exports
sudo systemctl start nfs-server

Creating Kickstart Files

A kickstart file contains instructions for automated OS installation without human intervention. Create a basic kickstart file

# Basic kickstart configuration
install
url --url="http://192.168.122.1/centos"
lang en_US.UTF-8
keyboard us
network --bootproto=dhcp
rootpw --plaintext password123
firewall --enabled --ssh
selinux --enforcing
timezone America/New_York
bootloader --location=mbr
clearpart --all --initlabel
autopart

Deploying Virtual Machines

Creating VMs with Network Boot

Create virtual machines configured to boot from the network using virt-install

virt-install \
  --name vm1 \
  --ram 2048 \
  --disk path=/var/lib/libvirt/images/vm1.qcow2,size=20 \
  --vcpus 2 \
  --os-type linux \
  --os-variant centos7.0 \
  --network bridge=virbr0 \
  --graphics vnc \
  --console pty,target_type=serial \
  --location http://192.168.122.1/centos \
  --extra-args "ks=http://192.168.122.1/kickstart.cfg"

This command creates a VM named vm1 that will boot from the HTTP server and use the specified kickstart file for automated installation.

Network Installation Methods

Method Location Parameter Advantages Use Cases
HTTP --location http://server/path Fast, widely supported Most common deployments
FTP --location ftp://server/path Good for large files Legacy systems
NFS --location nfs:server:/path Native Linux sharing High-performance networks

Monitoring Installation Progress

Monitor the installation progress using virt-manager's console view or by connecting to the VNC display. You can also check installation logs

# View VM console
virsh console vm1

# Check VM status
virsh list --all

# View installation logs
tail -f /var/log/libvirt/qemu/vm1.log

Ensure each virtual machine has a unique hostname and IP address to prevent conflicts during deployment. The automated installation will proceed according to the kickstart file specifications.

Post-Installation Management

After successful deployment, manage your VMs using libvirt commands

# Start VM
virsh start vm1

# Shutdown VM
virsh shutdown vm1

# Get VM info
virsh dominfo vm1

# Clone VM
virt-clone --original vm1 --name vm2 --file /var/lib/libvirt/images/vm2.qcow2

Conclusion

Deploying multiple virtual machines using network installation methods (HTTP, FTP, NFS) in a KVM environment provides an efficient and scalable approach to VM management. This method significantly reduces deployment time through automated installations and ensures consistency across all deployed systems using kickstart files.

Updated on: 2026-03-17T09:01:38+05:30

540 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements