Qemu, Libvirt and Virt-Manager can all be installed using the below command:
sudo apt install virt-managerDownload ubuntu-22.04.3-live-server-amd64.iso and move to /var/lib/libvirt/images/
Elevate your session:
sudo su then:
cd /var/lib/libvirt/images && wget https://learn.acuitservices.com/download/ubuntu/jammy/ubuntu-22.04.3-live-server-amd64.iso && exitCreate a network bridge in your /etc/netplan/00-installer-config.yaml:
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s31f6:
      dhcp4: no
  bridges:
    br0:
      dhcp4: yes
      interfaces:
      - enp0s31f6then restart netplan:
sudo netplan applyCreate a new .sh script in your home directory:
cd ~ && vi createvm.shPaste in the below contents:
#!/bin/sh
echo "Enter name for VM (no spaces):"
read name
echo "Enter CPU core count (ex 2):"
read cpu
echo "Enter memory allocation, in MBs, numbers only (ex 2048 for 2 GB):"
read memory
echo "Enter disk size, in GBs, numbers only (ex 120 for 120 GB):"
read disk
virt-install --name $name --os-variant ubuntu22.04  --vcpus $cpu  --memory $memory  --location /var/lib/libvirt/images/ubuntu-22.04.3-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd  --network network=bridged-network,model=virtio  --disk size=$disk  --graphics none  --extra-args='console=ttyS0,115200n8 --- console=ttyS0,115200n8'  --debugRun the above script using:
sudo bash createvm.shAn interactive session will begin to create the virtual machine with Ubuntu 22.04.3.
Screen can be used to launch the above script so the session can run in the background and be detached to continue other work during install.
If you are new to Screen, check out the full article on using Screen.
Create a new .sh script in your home directory:
cd ~ && vi screen_createvm.shPaste in the below contents:
#!/bin/sh
screen -t screencreatevm sh createvm.shRun the above script using:
sudo bash screen_createvm.shA new screen window will appear and the same interactive session will begin to create the virtual machine with Ubuntu 22.04.3.