#!/bin/bash
wget https://releases.ubuntu.com/jammy/ubuntu-22.04.4-live-server-amd64.iso
mount -o loop ubuntu-22.04.4-live-server-amd64.iso /mnt
cp /mnt/casper/vmlinuz /root/vmlinuz
cp /mnt/casper/initrd /root/initrd
chmod o+x /root/vmlinuz
chmod o+x /root/initrd
virt-install --ram=4096 --vcpus=4 --os-variant ubuntu22.04 --name ubuntu-22-04 --cdrom /root/ubuntu-22.04.4-live-server-amd64.iso --disk size=50 --import --network bridge=virbr0 --boot uefi,loader_secure=no,kernel=/root/vmlinuz,initrd=/root/initrd,kernel_args="console=ttyS0" --graphics none
virsh destroy ubuntu22.04
virsh edit ubuntu22.04
# Remove the following
<kernel>/root/vmlinuz</kernel>
<initrd>/root/initrd</initrd>
<cmdline>console=ttyS0</cmdline>
virsh start ubuntu22.04

Updated: