We suppose you already have KVM installed. If not, please see this article on installing KVM first.
To install an Ubuntu 22.04 virtual machine on KVM:
1. Download the Ubuntu 22.04 Image
sudo su cd /var/lib/libvirt/images wget https://releases.ubuntu.com/22.04.1/ubuntu-22.04.1-live-server-amd64.iso
2. Create the Virtual Machine
Run in the terminal:
sudo virt-install --name vm61 \ --os-variant ubuntu22.04 \ --vcpus 1 \ --memory 2048 \ --location /var/lib/libvirt/images/ubuntu-22.04.1-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \ --network bridge=br0,model=virtio \ --disk size=20 \ --graphics none \ --extra-args='console=ttyS0,115200n8 --- console=ttyS0,115200n8' \ --debug
--name– is the name of the virtual machine (VM).
(normally I name VMs after their static IP addresses. So the name vm61 will correspond to the IP 192.168.1.61)
--vcpus– number of vCPUs
--memory– RAM allocated to the VM
--location– path to the local .iso file (or a distro install URL). Also, we set
initrdhere (we got values for them in section 1).
--disk– hard disk allocated to the VM (20GB in our case).
--extra-args– extra arguments. In our case, we are setting the console configuration. But, for example, you can configure a static IP for the VM with this.
--debug– debugging information will be output during the installation. Remove this option if you do not need it.
--os-variant– is an operating system installed on the VM. For the full list of supported values, run:
virt-install --osinfo list
Or you could get more information like this ( but it would require installing an additional package
apt install libosinfo-bin osinfo-query os
For detailed help on
or you could see it online here.
For brief help run:
Also, you could find this discussion on
virt-install usage useful.
After you’ve started
virt-install, it could be that the installer will not be able to configure the network automatically.
In my case: I was on the network 192.168.1.0/24. My router (=gateway) IP was 192.168.1.1. And I wanted my VM to have the static IP 192.168.1.61.
So when I was asked to configure the network, I entered those details manually:
Also, I’ve chosen to install the OpenSSH server during the installation:
If you are installing the virtual machine on KVM which is, in turn, running on VirtualBox with nested virtualization, the installation process could take pretty long (it took more than 1 hour for me).
Later, you’ll be able to edit the virtual machine’s initial configuration parameters with
sudo virsh edit vm61
vm61 with your virtual machine name)
If your virtual machine was shut down, you can start it with
virsh start vm61 --console
Right after the installation, the file
/etc/netplan/00-installer-config.yaml on the my nested virtual machine (
vm61) looked like this:
# This is the network config written by 'subiquity' network: ethernets: enp1s0: addresses: - 192.168.1.61/24 gateway4: 192.168.1.1 nameservers: addresses: - 126.96.36.199 - 188.8.131.52 search:  version: 2
So the nested VM was on the same network as the KVM machine. It had access to the Internet. And was accessible by IP on the network.