KVM virtualization environment deployment

System Initial Disk Space

Windows XP

  • CPU: 1 core or higher
  • Recommended Memory: 512MB or higher
  • Recommended Disk Space: 15GB-25GB or higher
  • System Occupied Space: 4GB

Windows 7

  • CPU: 2 cores or higher
  • Recommended Memory: 2GB or higher
  • Recommended Disk Space: 25GB-30GB or higher
  • System Occupied Space: 10GB

Windows 10

  • CPU: 2 cores or higher
  • Recommended Memory: 2GB or higher
  • Recommended Disk Space: 34-39GB or higher / Enterprise Edition 75-81GB or higher / LTSB Version 21-30GB or higher
  • System Occupied Space: 19GB (18.5GB) (Standard Professional Edition)
  • System Occupied Space: 61GB (Standard Enterprise Edition)
  • System Occupied Space: 9GB (LTSB Edition)
  • System Occupied Space: 17.2GB (LTSC Edition 2021)
  • System Occupied Space: 9.54GB (LTSC Edition 2022)

Windows 11

  • CPU: 2 cores or higher (1GHz or faster processor or System on a Chip (SoC) that supports 64-bit)
  • Recommended Memory: 4GB or higher
  • Recommended Disk Space: 64GB or higher
  • System Occupied Space: 56GB (55.7GB) (Professional Workstation Edition)

Windows 2008 R2 Datacenter Edition

  • CPU: 1 core or higher
  • Recommended Memory: 1GB or higher
  • Recommended Disk Space: 23-28GB or higher / WEB Edition 28-38GB or higher
  • System Occupied Space: 8GB (7.96GB) (Datacenter Edition)
  • System Occupied Space: 13GB (12.4GB) (WEB Edition)

Windows 2012 R2 Datacenter Edition

  • CPU: 1 core or higher
  • Recommended Memory: 1GB or higher
  • Recommended Disk Space: 24-29GB or higher
  • System Occupied Space: 9GB (Datacenter Edition)

Windows 2019 Datacenter Edition

  • CPU: 1 core or higher
  • Recommended Memory: 2GB or higher
  • Recommended Disk Space: 25GB-35GB or higher
  • System Occupied Space: 10GB (9.97GB) (Datacenter Edition)

CentOS 5.8/6.5

  • CPU: 1 core or higher
  • Recommended Memory: 512MB or higher
  • Recommended Disk Space: 10GB or higher

CentOS 7.2

  • CPU: 1 core or higher
  • Recommended Memory: 512MB or higher
  • Recommended Disk Space: 10GB or higher

CentOS 8

Debian(ParrotSec)

  • CPU: 1 core or higher
  • Memory: 1GB or higher
  • Recommended Disk Space: 14GB or higher

KVM Install

CentOS

1
yum -y install qemu-kvm qemu-kvm-tools virt-install bridge-utils novnc

yum groupinstall -y “GNOME Desktop” // Install GNOME desktop environment
yum -y install qemu-kvm // KVM module
yum -y install qemu-kvm-tools // KVM debugging tools, optional
yum -y install virt-install // Command-line tool to build virtual machines
yum -y install qemu-img // qemu component, create disk, start virtual machine, etc.
yum -y install bridge-utils // Network support tools
yum -y install libvirt // Virtual machine management tools
yum -y install virt-manager // Graphical interface to manage virtual machines

Install libvirt

1
yum -y install libvirt

Set to start

1
2
systemctl start libvirtd
systemctl enable libvirtd

Check if the CPU supports virtualization

1
grep -c vmx /proc/cpuinfo

Debian

with UI
1
apt install virt-manager qemu-system libvirt-daemon-system qemu-utils
UI
1
apt install qemu-system libvirt-daemon-system virtinst qemu-utils

Start the libvirt management daemon (libvirtd)

1
systemctl enable --now libvirtd

Check the running status

1
systemctl status libvirtd

Create Disk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
CentOS5.8
qemu-img create -f qcow2 ./centos5.qcow2 10G

CentOS6.5
qemu-img create -f qcow2 ./centos6.qcow2 10G

CentOS7
qemu-img create -f qcow2 ./centos7.qcow2 10G

ParrotSec-Debian
qemu-img create -f qcow2 ./ParrotSec.qcow2 30G

WindowsXP
qemu-img create -f qcow2 ./winxp.qcow2 15G

Windows7
qemu-img create -f qcow2 ./win7.qcow2 25G

Windows10(Standard Professional Edition)
qemu-img create -f qcow2 ./win10zy.qcow2 34G
Windows10(Enterprise Standard Edition)
qemu-img create -f qcow2 ./win10qy.qcow2 75G
Windows10(LTSB Version)
qemu-img create -f qcow2 ./win10ltsb.qcow2 21G
Windows10(LTSC Version)
qemu-img create -f qcow2 ./win10ltsc.qcow2 21G

Windows11
qemu-img create -f qcow2 ./win11.qcow2 75G

Windows2003
Windows2008 r2 Datacenter Edition
qemu-img create -f qcow2 ./win2008r2.qcow2 23G
Windows2012 r2 Datacenter Edition
qemu-img create -f qcow2 ./win2012r2.qcow2 24G
Windows2019 Datacenter Edition
qemu-img create -f qcow2 ./win2019.qcow2 25G
# KVM Virtual Machine Disk Formats
# RAW: Raw format. Occupies more space, better performance, but does not support snapshot function;
# qcow2: Occupies less space, performance is slightly worse than RAW, but it supports snapshot function;

Load System Files

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Load for Linux systems:
# Create bridge network
virt-install --name netsec --vcpus 4 --memory 8192 --import --disk path=/path/netsec.qcow2,bus=virtio --network type=direct,source=eno1,source_mode=bridge,model=virtio --force --import --autostart
#--network type=direct,source=eno1,source_mode=bridge,model=virtio

CentOS7
virt-install --virt-type kvm --name c7 --ram 1024 --vcpus 1 --cdrom=/path/Linux/CentOS/CentOS-7-x86_64-Minimal-2009.iso --disk path=/path/centos7.qcow2 --network=default --graphics vnc,listen=0.0.0.0 --noautoconsole

Ubuntu18
virt-install --name u18 --memory 1024 --vcpus 2 --cdrom=/path/Linux/ubuntu-22.04.4-live-server-amd64.iso --disk path=/path/range.qcow2,format=raw,bus=virtio --network=default --graphics vnc,listen=0.0.0.0,port=6001 --noautoconsole

debain11
virt-install --name scan1 --memory 12288 --vcpus 8 --cdrom=/path/Linux/Debian/debian-12.6.0-amd64-DVD-1.iso --os-type linux --disk path=/path/scan1.qcow2,format=raw,bus=virtio --network type=direct,source=eno1,source_mode=bridge,model=virtio --graphics vnc,listen=0.0.0.0,port=5902 --noautoconsole

Windows10
virt-install --virt-type kvm --os-type windows --name win10_Ru --vcpus 4 --features hyperv_relaxed=on,hyperv_vapic=on,hyperv_spinlocks=on,hyperv_spinlocks_retries=8191 --memory 4096 --disk path=/path/win10_Ru.qcow2,device=disk,bus=virtio --disk path=/path/Windows/Win10/ru-ru_windows_10_enterprise_ltsc_2021_x64_dvd_5044a1e7.iso,device=cdrom,bus=virtio --disk path=/path/drive/virtio-win-0.1.248.iso,device=cdrom,bus=virtio --network network=default,model=virtio --graphics vnc,listen=0.0.0.0,port=6000 --noautoconsole

Windows11
virt-install --virt-type kvm --name win11 --ram 4096 --vcpus=2 --os-type=windows --os-variant=win10 --cdrom=/path/Windows/win11/ru_windows_11_consumer_editions_x64.iso --disk path=/path/win11.qcow2,format=qcow2,bus=virtio --boot cdrom --disk path=/path/drive/virtio-win-0.1.204.iso,device=floppy --network=default --graphics vnc,listen=0.0.0.0 --noautoconsole
# Because Windows 11 is relatively new, "--os-variant=win10" can be selected.

Windows2019
virt-install --virt-type kvm --os-type windows --name win19_test --vcpus 2 --features hyperv_relaxed=on,hyperv_vapic=on,hyperv_spinlocks=on,hyperv_spinlocks_retries=8191 --memory 2048 --disk path=/path/win19_test.qcow2,device=disk,bus=virtio --disk path=/path/ru_windows_server_2019_updated_july_2020_x64_dvd_2c9b67da.iso,device=cdrom,bus=ide --disk path=/path/to/virtio-win-0.1.248.iso,device=cdrom,bus=ide --network network=default,model=virtio --graphics vnc,listen=0.0.0.0,port=6030 --noautoconsole

Operation Instructions

View running virtual machines

1
virsh list --all

Start virtual machine

1
virsh start <virtual machine name>

Start virtual machine and enter

1
virsh start <virtual machine name> --console

View the current disk used by the virtual machine

1
virsh domblklist <virtual machine name> --details

Shut down virtual machine

1
virsh shutdown <virtual machine name>

Suspend virtual machine

1
virsh suspend <virtual machine name>

Resume suspended virtual machine

1
virsh resume <virtual machine name>

Start the virtual machine with the host machine (mother machine)

1
virsh autostart <virtual machine name>

Cancel automatic startup

1
virsh auotstart --disable <virtual machine name>

View snapshots related to a virtual machine

1
virsh snapshot-list centos7-2

Modify virtual machine password

1
virt-edit <virtual machine name> /etc/shadow

Delete virtual machine

1
2
3
virsh destroy <virtual machine name>
virsh undefine <virtual machine name>
virsh list --all

Expand virtual machine disk space (increase by 50G in the following example)

1
qemu-img resize /path/<virtual machine file>.qcow2 +50G

Increase CPU and memory

1
2
3
4
5
6
cd /etc/libvirt/qemu
vi <virtual machine name>.xml

<memory unit='KiB'>1048576</memory> # Memory expansion
<currentMemory unit='KiB'>1048576</currentMemory> # Memory expansion
<vcpu placement='static'>1</vcpu> # CPU expansion

Save and execute

1
virsh create /etc/libvirt/qemu/<virtual machine name>.xml

View virtual machine configuration

1
virsh dominfo <virtual mahine name>