I need to install the latest LTS Ubuntu (22.04) in KVM. Few years ago I installed 18.04 in this way and it worked:
sudo virt-install --name new_server --ram=2048 --vcpus=1 --cpu host --hvm --disk path=/var/lib/libvirt/images/new_server,size=20 --location http://gb.archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/ --graphics none --console pty,target_type=serial --extra-args 'console=ttyS0,115200n8 serial' --os-type linux --os-variant ubuntu18.04 --network network:default --hvm --force --debug
But now I got this error:
ValueError: Could not find an installable distribution at 'http://gb.archive.ubuntu.com/ubuntu/dists/jammy/main/installer-amd64/'
How I could install Ubuntu 22.04 on KVM in console mode?
I found this solution:
Download the ISO image
wget https://releases.ubuntu.com/jammy/ubuntu-22.04.2-live-server-amd64.iso
Create mount point folder and mount the image:
Run virt-install with ISO image custom kernel path (it's required to pass console=ttyS0 arg, without this arg there is no console output and installation process is impossible):
Install Ubuntu as usual
Stop the VM
virsh destroy myvm
Remove boot options from VM configuration:
sudo virsh edit myvm
Following lines should be removed:
Start the VM:
virsh start myvm
Now use it as usual.
It seems there is a possibility to use --install option in newer versions of virsh-manager. Also I saw the kernel and the initrd params in the --location path. Maybe it also could work. But I have virsh-manager 1.5.1 and these options are unavailable.