====KVM====
KVM on Debian 12, tested on the [[:boards:n100|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.
[[:tools:preseed|preeseed.cfg]]
==List==
virsh list --all
==Start==
virsh start debian12
==Auto start==
virsh autostart debian12
== No auto start==
virsh autostart --disable debian12
== Information ==
virsh dominfo debian12
==Console==
virsh console debian12
==Stop==
virsh shutdown debian12
NB there are optional modes
== Force stop==
virsh destroy debian12
==Delete==
virsh undefine debian12
==Export==
virsh dumpxml debian12 > debian12.xml
==Import==
virsh define debian12.xml
===Resources===
[[https://wiki.debian.org/KVM|Debian KVM]]
[[https://www.golinuxcloud.com/virt-install-examples-kvm-virt-commands-linux/|virt-install examples]]
[[https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/|DVD ISO Debian Current]]
[[https://cloud.debian.org/cdimage/archive/11.10.0/amd64/iso-dvd/|DVD ISO Debian Bullseye 11.10]]
[[https://cloud.debian.org/cdimage/archive/10.13.0/amd64/iso-dvd/|DVD ISO Debian Buster 10.13]]