This is an old revision of the document!


KVM

KVM on Debian 12, tested on the N100 Mini PC.

Install

Some of these tools will require an X11 server which can be VxSrv on Windows, for example.

apt install --no-install-recommends qemu-system libvirt-clients libvirt-daemon-system virt-viewer virtinst virt-manager qemu-utils

User

Add login to group(s).

Debian says add your login to group libvirt and other guides recommend group kvm as well. The latter group requirement is unknown.

adduser `login' libvirt
adduser `login' kvm

Test

Export the hostname of your X11 server and on that host allow access via xhost.

setenv DISPLAY excellent:0.0
virt-manager

Directories

VM storage

mkdir -p /opt/VM
chown 0:0 /opt/VM
chmod 1777 /opt/VM

ISO storage

mkdir -p /opt/ISO
cd /opt/ISO
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-12.4.0-amd64-DVD-1.iso
sha256sum debian-12.4.0-amd64-DVD-1.iso
3a85e04f0bbdf7ba0cdd7537dd781c583f70754db67e5a757f113442cade56ea  debian-12.4.0-amd64-DVD-1.iso

VM

Create
#! /bin/sh

export PATH=/bin:/sbin

NAME="debian12"
DVD="/opt/ISO/debian-12.4.0-amd64-DVD-1.iso"
DISK="/opt/VM/${NAME}.qcow2,size=20,format=qcow2"

virsh destroy ${NAME}
virsh undefine ${NAME}
rm -f $DISK

virt-install \
--name "${NAME}" \
--ram 1024 \
--disk path="${DISK}" \
--vcpus 1 \
--os-variant debian11 \
--network bridge=br0 \
--graphics none \
--console pty,target_type=serial \
--location "${DVD}" \
--initrd-inject preseed.cfg \
--extra-args 'ks=file:/preseed.cfg console=ttyS0,115200n8 serial'

preeseed.cfg

List
virsh list --all
Console
virsh console debian12
Stop
virsh destroy debian12
Delete
virsh undefine debian12

Resources

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies