KVM Installation and Configuration Guide
This article provides a step‑by‑step tutorial on installing and configuring KVM on a Linux server, covering CPU virtualization enablement, package installation, module loading, network setup, virtual disk creation, VM deployment, firewall rules, and VNC access.
1. Introduction to KVM KVM (kernel‑based virtual machine) is an open‑source, hardware‑assisted full virtualization solution integrated into Linux kernels since 2.6.20, using the Linux scheduler and becoming a mainstream VMM in academia.
2. KVM Installation and Configuration
2.1 CPU Virtualization Ensure virtualization support is enabled in BIOS; verify with commands:
cat /proc/cpuinfo | grep 'vmx' // Intel CPU
cat /proc/cpuinfo | grep 'svm' // AMD CPU
2.2 Install KVM packages
yum install qemu-kvm qemu-kvm-tools virt-manager libvirt virt-viewer -y
Explanation of key packages: kvm (kernel module), qemu (userspace virtualization), qemu‑kvm (manages KVM devices), virt‑viewer (VNC client).
2.3 Load KVM module
modprobe kvm-intel // load Intel KVM module
lsmod | grep kvm // verify module is loaded
2.4 Configure network interfaces Create a bridge (br0) and adjust eth0 as a switch‑like interface (no IP). Images illustrate the configuration.
2.5 Modify VNC server configuration
vim /etc/libvirt/qemu.conf – uncomment vnc_listen = "0.0.0.0" on line 12.
2.6 Restart services
/etc/init.d/libvirtd restart // restart libvirtd
/etc/init.d/messagebus restart // restart message bus
2.7 Create virtual disk
qemu-img create -f raw /opt/CentOS-6.5-x86_64.raw 10G
2.8 Copy installation ISO
dd if=/dev/cdrom1 of=/opt/Centos-6.5-x86_64.iso
2.9 Install the virtual machine
virt-install -n centos6.5 -r 512 -vcpus=1 -s 50 -c /opt/Centos6.5-x86_64.iso --hvm --os-type=linux -f /opt/CentOS-6.5-x86_64.raw --graphics vnc,listen=0.0.0.0,port=7789 --force --autostart
Parameters: name, 512 MB RAM, 1 CPU, 50 GB disk, ISO path, full virtualization, Linux OS type, VNC on port 7789, auto‑start.
2.10 Set iptables rule for VNC
iptables -I INPUT -p tcp --dport 7789 -j ACCEPT
service iptables save
2.11 Connect via VNC client Use a VNC viewer (or Xshell) to connect to the VM’s IP and port 7789; screenshots show the connection process.
2.12 Configure the guest VM Example: install Apache web server, set IP address, and verify access from a browser. Images demonstrate Xshell usage, httpd service start, and successful web page access.
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.