KVM

Topics: Virtual Machine

Kernel-based Virtual Machine (KVM) is a Linux virtualization technology that lets the kernel run virtual machines using hardware virtualization.

Subtopics

Permanent user access

To avoid having to authenticate for every interaction with libvirt, add your user account to the libvirt group:

sudo usermod -aG libvirt $USER

This might require adding the entry to the groups file first:

sudo getent group | grep libvirt | sudo tee -a /etc/group

Backup disk image

When doing a backup of a VM disk image, we need to make sure that the sparse image file doesn’t get blown up to its full filesystem size. (If that happens, we can revert it using qemu-img; see below).

cd mybackupdir
virsh dumpxml myvm > myvm.xml
cp --sparse=always /var/lib/libvirt/images/myvm.qcow2 .

Compress disk image size

qemu-img convert -c -O qcow2 vmdisk.qcow2 vmdisk-comp.qcow2

Bookmarks

Questions