How to install Ubuntu 22.04 as GUEST in KVM

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 --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 ''

How I could install Ubuntu 22.04 on KVM in console mode?

Asked By: user12125591


I found this solution:

  1. Download the ISO image


  2. Create mount point folder and mount the image:

    mkdir mnt
    sudo mount -o loop ubuntu-22.04.2-live-server-amd64.iso mnt
  3. 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):

    sudo virt-install --name myvm --ram=4096 --vcpus=1 --cpu host --hvm --disk path=/virt1/machines/myvm/myvm,size=40 --cdrom ubuntu-22.04.2-live-server-amd64.iso --graphics none --console pty,target_type=serial --os-type linux --network network:default --hvm --force --debug --boot kernel=mnt/casper/vmlinuz,initrd=mnt/casper/initrd,kernel_args="console=ttyS0"
  4. Install Ubuntu as usual

  5. Stop the VM

    virsh destroy myvm

  6. Remove boot options from VM configuration:

    sudo virsh edit myvm

Following lines should be removed:

  1. 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.

Answered By: user12125591
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.