How to create and install a KVM guest

Feb 12, 2020

Download CentOS 7

# mkdir /kvm-pool/iso
# cd /kvm-pool/iso
# wget

Create the virtual machine with a local ISO image

Run osinfo-query os command to find out what to use for --os-variant

# virt-install --name vm01 \
  --ram 1024 \
  --vcpus=1 \
  --os-variant=centos7.0 \
  --cdrom=/kvm-pool/iso/CentOS-7-x86_64-DVD-1908.iso \
  --graphics vnc \
  --disk size=10

Create the virtual machine with a remote kickstart file

# virt-install --name vm02 \
  --ram 2048 \ 
  --vcpus=1 \
  --os-variant=centos7.0 \
  --location= \
  --graphics vnc \
  --disk size=10 \
  --extra-args "ks="

Create the virtual machine with a local kickstart and ISO image

# virt-install --name vm02 \
  --ram 2048 \
  --vcpus=1 \
  --os-variant=centos7.0 \
  --location=/kvm-pool/iso/CentOS-7-x86_64-DVD-1908.iso \
  --graphics vnc \
  --disk size=10 \
  --extra-args "ks=file:/vm02.cfg"
Kickstart file
# mkdir /kvm-pool/ks
# vi /kvm-pool/ks/vm02.cfg
# System authorization information
auth --enableshadow --passalgo=sha512
# Use text install
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=vda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=static --device=eth0 --gateway= --ip= --nameserver= --netmask= --noipv6 --activate
network  --hostname=vm02

# Root password
rootpw --iscrypted $6$8JIXoeyEi1YdMCtv$8MZ3ccZMjl4Bmf/uKIYBvlHJFOHBgVJja6ydDn4E5rUvjYcvz6Q7ZTa0nOWTqDbCgTcKhnmY3FKWlqzyEXOKS1
# System services
services --disabled="chronyd"
# System timezone
timezone Europe/Bucharest --isUtc --nontp
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=vda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel



%addon com_redhat_kdump --enable --reserve-mb='auto'


pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty

Install the OS via VNC

Find out the VNC port
# virsh dumpxml vm01 | grep vnc
    <graphics type='vnc' port='5900' autoport='yes' listen=''>
Forward the port on Windows 10
C:\Users\Daniel>ssh root@ -L 5900:

Downnload VNC Viewer and connect to 127:0.0.1:5900

Install the OS via virt-manager

Follow this tutorial


Booting from ISO file on KVM guest

How to Install KVM on RHEL 7

comments powered by Disqus