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

Interactive

This example uses a fixed MAC address.

#! /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,mac=02:00:c0:a8:00:6e \
--graphics none \
--console pty,target_type=serial \
--location "${DVD}" \
--extra-args 'console=ttyS0'

Non interactive

Append the following to the interactive script above

--initrd-inject preseed.cfg --noautoconsole --wait

This preseed file uses a fixed IP address.

preeseed.cfg

List
virsh list --all
Start
virsh start debian12
Auto start
virsh autostart debian12
Console
virsh console debian12
Stop
virsh shutdown debian12

NB there are optional modes

Force stop
virsh destroy debian12
Delete
virsh undefine debian12

Resources

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information