This repo describes how to auto install debain12 and debian13 with virsh-install and cloud-init. Which images you can use, and which images you should not use. How to add user passwords with hashes and how to create harddisk images from templates.
Do not use genericcloud images, they do not contain sata ahci drivers for cloud init.
cd /isos
wget https://cdimage.debian.org/cdimage/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
wget https://cdimage.debian.org/cdimage/cloud/trixie/latest/debian-13-generic-amd64.qcow2
This python script asks for username, password, list all public ssh keys to select one. It uses this information to update the cloud-init.yml template. It needs mkpasswd (packaged with whois) to create the hash for the user password.
sudo apt-get install whois # to get mkpasswd binary
python3 update-cloud-init.py
mkpasswd -m sha-512 # to generate hash for your user password
cp cloud-init.yml /isos # copy cloud-init.yaml with inserted values
virt-install --os-variant list
virsh net-start host-bridge # check if host-bridge is running
# create disk image for vm
qemu-img create -f qcow2 -o backing_file=/isos/debian-12-generic-amd64.qcow2,backing_fmt=qcow2 /isos/debian-12.qcow2 30G
virt-install \
--name debian12 \
--memory 4096 \
--vcpus 4\
--disk /isos/debian-12.qcow2,device=disk,bus=virtio \
--os-variant debian12 \
--virt-type kvm \
--graphics none \
--console pty,target_type=serial \
--network network=default,model=virtio \
--network bridge=virbr0,model=virtio \
--cloud-init user-data=/isos/cloud-init.yml \
--import
# create disk image for vm
qemu-img create -f qcow2 -o backing_file=/isos/debian-13-generic-amd64.qcow2,backing_fmt=qcow2 /isos/debian-13.qcow2 30G
virt-install \
--name debian13 \
--memory 4096 \
--vcpus 4\
--disk /isos/debian-13.qcow2,device=disk,bus=virtio \
--os-variant debian13 \
--virt-type kvm \
--graphics none \
--console pty,target_type=serial \
--network network=default,model=virtio \
--cloud-init user-data=/isos/cloud-init.yml \
--boot uefi \
--import
virt-install \
...
--noautoconsole \
virsh shutdown debian12
virsh destroy debian12
virsh undefine debian12
virsh shutdown debian13
virsh destroy debian13
virsh undefine debian13
sudo journalctl -u cloud-init
sudo cat /var/log/cloud-init.log
sudo cloud-init clean
sudo cloud-init init
sudo cloud-init modules --mode=config
sudo cloud-init modules --mode=final