Master KVM on CentOS: A Complete Step‑by‑Step Tutorial with Images
This guide walks you through the fundamentals of KVM virtualization on CentOS 7, covering its advantages and drawbacks, preparing YUM repositories, installing required packages, configuring networking, creating storage pools and volumes, importing ISO images, and finally building and launching a fully functional virtual machine.
Overview
KVM (Kernel‑based Virtual Machine) turns the Linux kernel into a bare‑metal hypervisor, allowing multiple isolated virtual machines to run on a single physical host, improving hardware utilization and reducing cost.
Key Advantages
High performance : leverages hardware virtualization extensions for near‑native speed.
Open‑source & low cost : GPL‑licensed, free to use and modify.
Flexibility : supports many guest OSes (Linux, Windows, BSD) and integrates with tools like QEMU and libvirt.
Security : benefits from SELinux, cgroups and kernel‑level isolation.
Scalable resource management : dynamic CPU, memory, network and storage adjustments.
Drawbacks
Hardware dependency : requires CPUs with VT‑x/AMD‑V support.
Management complexity : command‑line heavy and steeper learning curve compared with commercial solutions.
Performance overhead : occasional I/O penalty and resource contention under heavy load.
Deployment Guide on CentOS 7
1. Prepare YUM repositories
If default repositories are unavailable, configure a local or Alibaba Cloud mirror.
2. Install required packages
yum install -y qemu-kvm qemu-kvm-tools virt-install qemu-img bridge-utils libvirt virt-manager3. Verify CPU virtualization support
cat /proc/cpuinfo | grep vmx # Intel cat /proc/cpuinfo | grep svm # AMD4. Load and enable KVM modules
lsmod | grep kvm5. Start and enable libvirtd service
systemctl start libvirtd
systemctl enable libvirtd6. Configure a bridge network (br0)
Edit /etc/sysconfig/network-scripts/ifcfg-br0 with:
TYPE=Bridge
BOOTPROTO=static
NAME=br0
ONBOOT=yes
DEVICE=br0
PREFIX=24
IPADDR=192.168.180.139
GATEWAY=192.168.180.254
DNS1=202.96.134.133Then modify the physical interface (e.g., ens33) to use the bridge:
TYPE=Ethernet
BOOTPROTO=none
NAME=ens33
DEVICE=ens33
ONBOOT=yes
BRIDGE=br07. Create storage pool and volume
Using virt-manager, create a pool named bdqn (path /data_kvm) and an ISO pool bdqn_iso (path /data_kvm/iso). Then create a storage volume for the VM.
8. Import ISO and create the VM
Drag the desired ISO into the bdqn_iso pool, start a new VM wizard, select the ISO, allocate CPU and memory according to host capacity, and finish the installation.
9. Allocate resources
Adjust CPU, memory, and storage based on your hardware specifications.
10. Complete installation
After the installer finishes, you will have a functional CentOS 7 virtual machine running under KVM.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
