14

This command:

virt-install   \
   --name bla  \
   --ram=1024  \
   --disk path=/home/me/libvirt/images/bla.qcow2,bus=virtio,size=10  \
   --location /home/me/Downloads/ubuntu-18.10-desktop-amd64.iso

Reports:

ERROR    Couldn't find hvm kernel for Ubuntu tree.

How can I fix this?

(Since there are many duplicate posts and answers with regard to this issue, I am answering it, too.)

6 Answers 6

17

Instead of using

 --location /home/me/Downloads/ubuntu-18.10-desktop-amd64.iso

use

 --cdrom /home/me/Downloads/ubuntu-18.10-desktop-amd64.iso

The difference is (from the man page):

-c CDROM , --cdrom=CDROM
File or device use as a virtual CD-ROM device for fully virtualized guests. It can
be path to an ISO image, or to a CDROM device. It can also be a URL from which to 
fetch/access a minimal boot ISO image. The URLs take the same format as described
for the "--location" argument. If a cdrom has been specified via the "--disk" 
option, and neither "--cdrom" nor any other install option is specified, the 
"--disk" cdrom is used as the install media.

-l LOCATION , --location=LOCATION
Distribution tree installation source. virt-install can recognize certain 
distribution trees and fetches a bootable kernel/initrd pair to launch the 
install. 

So the correct command in this case is:

virt-install   \
   --name bla  \
   --ram=1024  \
   --disk path=/home/me/libvirt/images/bla.qcow2,bus=virtio,size=10  \
   --cdrom /home/me/Downloads/ubuntu-18.10-desktop-amd64.iso
2
  • 1
    This advice makes it impossible to pass --initrd-inject any longer. Apr 29, 2020 at 21:10
  • @0xC0000022L: Noted, but please also observe that StackExchange is about a specific problem (Q) and the corresponding specific solution (A). The initial problem did not require use of --initrd-inject, and the given answer solves the described problem.
    – TFuto
    Nov 21, 2021 at 19:52
7

Technically, you can use --location with an updated virt-install 1.5+ and args explained here from Cole Robinson. I tested it and it was true.

However getting a Ubuntu working with --location in my opinion is a pain in the a$$. I finally got it working with the following --location and full command:

virt-install \
    -n ubuntu -r 2048 \
    --os-variant=ubuntu19 \
    --location http://us.archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/ \
    --disk /var/lib/libvirt/images/ubuntu20.img,size=10,device=disk,bus=virtio \
    --graphics none -w bridge=br0,model=virtio \
    --extra-args 'console=ttyS0,115200n8 serial' \
    --force \
    --debug

Make sure you explore the URL in --location to get the proper release of Ubuntu you want. I'm sure you'll have some trial and error to do...

With a CentOS .iso image I did not have this problem and used --location and it worked fine.

1
  • the location thing didn't work for me but used the legacy iso of Ubuntu as suggested in another answer in combination with the syntax provided here. The interactive installation now is available via the host terminal from where I fired the virt-install command
    – vvs
    Jun 20, 2022 at 7:56
6

I have been struggling with this problem while trying to install Ubuntu 20.04.1 server with virt-install. I have found some of answers helpful, but found a different solution.

First. The original question references a "Desktop" iso file. Though, the solution in regards to a "live-server-amd64.iso" where mounting the ISO to /mnt, was actually helpful for me in getting my install to kick start.

However, my install ended up moving way to slowly. I'm not entirely certain why it was so slow. The install ultimately crashed when I tried to cancel the updates that were taking forever. There is another solution though, that doesn't involve mounting the ISO and providing those kernel boot options.

There is a legacy (non-live) version of Ubuntu 20.04.1 server available.

http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/

Found it on this thread over here.

Non-live Ubuntu Server 20.04 release

With the Legacy version of 20.04.1 server, it will actually run with the --location parameter instead of the --cdrom parameter, thereby enabling the --extra-args console=ttyS0 options.

0
4

I found a solution:

mount -o ro /images/ubuntu-20.04-live-server-amd64.iso /mnt

cd /mnt

virt-install \
    --name myguest\
    --memory 4096 \
    --disk /vms/myguest.disk,size=40 \
    --cdrom /images/ubuntu-20.04-live-server-amd64.iso \
    --nographics \
    --os-type linux \
    --boot kernel=casper/vmlinuz,initrd=casper/initrd,kernel_args="console=ttyS0"

at the end of installation: virsh edit myguest (and remove kernel,initrd and args lines) virsh start myguest

3

If you use --cdrom in replace of --location you will loose some options like --extra-args ! This useful parameter could not be used in cooperation with --cdrom ! If you want to use --extra-args you must use --location !

If you like this parameter you must overcome to this problem such a different way!

If you want to overcome to this problem, you must know that .iso files are a type of compressed files, first of all! Yes! They are some special type of compressed files like .zip or .rar, .tar.gz and so etc.

You could learn how to extract them by following this link.

The reason that you got ERROR: Couldn't find hvm kernel for Ubuntu tree. is that your image(.iso file) doesn't include install/vmlinux file(vmlinuz file is not available directly in your root install folder)! Check the existence of this file by extracting .iso file( It must have vmlinuz file exactly within your root install folder).

If you couldn't find that, you must find other related .iso from ubuntu website which includes this desired file at this specific path!

It's remarkable that Ubuntu provides different .iso files like live iso, minimal iso and so etc for each distro and version and platform! You need just to look for much appropriate one.

Do your best and have fun.

3

Tested solution for Ubuntu 20.04 Server with my extra args for autoinstall:

virt-install \
  --name=$VMNAME \
  --os-variant=ubuntu20.04 \
  --memory=2048 \
  --vcpus=1 \
  --network network=default \
  --disk=${IMG_PATH},cache=none,format=qcow2,bus=virtio \
  --location=/home/user/Downloads/ubuntu-20.04.3-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \
  --extra-args "autoinstall ds=nocloud-net;s=http://192.168.122.1:3003/" \
  --noreboot

From man virt-install:

Additionally, --location can take 'kernel' and 'initrd' sub options. These paths relative to the specified location URL/ISO that allow selecting specific files for kernel/initrd
           within the install tree. This can be useful if virt-install/ libosinfo doesn't know where to find the kernel in the specified --location.

           For example, if you have an ISO that libosinfo doesn't know about called my-unknown.iso, with a kernel at 'kernel/fookernel' and initrd at 'kernel/fooinitrd', you can make this
           work with:

             --location my-unknown.iso,kernel=kernel/fookernel,initrd=kernel/fooinitrd
3
  • What does 192.168.122.1:3003 represent? Is this the IP and port of the VM or ?
    – mr.zog
    Mar 30, 2022 at 0:51
  • 2
    I just start simple web server with python3 -m http.server 3003 and it will listen on all local IP addresses. This particular IP is usually default network in QEMU/KVM. So the web server will also be available on that IP. Ubuntu installer will connect to that IP and fetch file user-data for full auto installation.
    – Tarik
    Mar 31, 2022 at 12:42
  • 1
    --location=<iso_file>,kernel=casper/vmlinuz,initrd=casper/initrd does the trick for me with ubuntu-22.04-live-server-amd64.iso
    – pansen
    Aug 9, 2022 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.