KVM
Introduction
How To Use
# Check hardware virtualization support
lscpu | grep Virtualization
# Install
dnf install qemu-kvm qemu-img
dnf install libvirt libvirt-python libvirt-client virt-install virt-manager
# Start libvirtd
systemctl start libvirtd
systemctl enable libvirtd
lsmod | grep kvm
# Option: Install bridge-utils
dnf install -y bridge-utils
vim /etc/sysconfig/network-scripts/ifcfg-ens192
vim /etc/sysconfig/network-scripts/ifcfg-br0
systemctl restart network
ip addr show br0
# Create vm
# option1: install initial vm by UI
virt-manager
# option2: install initial vm by iso
osinfo-query os # search os variant
virt-install \
--name=template-ubuntu-22.04-base \
--vcpus=2 \
--ram=4096 \
--disk path=/var/lib/libvirt/images/template-ubuntu-22.04-base.qcow2,size=20 \
--cdrom=/tmp/ubuntu-22.04.iso \
--os-variant=ubuntu22.04 \
--network network=default \
--graphics spice
qemu-img convert -O qcow2 -c template-ubuntu-22.04-base.qcow2 template-ubuntu-22.04.qcow2
qemu-img info template-ubuntu-22.04.qcow2
# option3: install vm by qcow2 template
virt-install \
--name=vm-test \
--import \
--vcpus=2 \
--ram=4096 \
--disk path=/var/lib/libvirt/images/rockylinux9.5.qcow2 \
--os-variant=ubuntu22.04 \
--graphics spice \
--network network=default \
--noautoconsole
# Manager
virsh net-list --all
virsh list --all
virsh start vm_name
virsh autostart vm_name
virsh shutdown vm_name
virsh destroy vm_name
virsh undefine vm_name --remove-all-storage
virsh console vm_name
virsh edit vm_nameLast updated