Score:1

How to install Ubuntu 22.04 as GUEST in KVM

to flag

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?

Terrance avatar
id flag
I think you are looking for the Ubuntu Live Installer. https://ubuntu.com/download/alternative-downloads and https://discourse.ubuntu.com/t/netbooting-the-live-server-installer/14510
user12125591 avatar
to flag
There is a link to 20.04, but the same link for 22.04 does not exist. I found another solution
Terrance avatar
id flag
Good find! +1 +1 :)
Score:1
to flag

I found this solution:

  1. Download the ISO image

    wget https://releases.ubuntu.com/jammy/ubuntu-22.04.2-live-server-amd64.iso

  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:

<kernel>/home/user/mnt/casper/vmlinuz</kernel>
<initrd>/home/user/mnt/casper/initrd</initrd>
<cmdline>console=ttyS0</cmdline>
  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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.