04. Run the kvm command line in ubuntu to install 64-bit ubuntu. & quot; Couldn & #39; t find hvm kernel for Ubuntu tree. & quot;, kvmhvm

Source: Internet
Author: User

04. Run the kvm command line in ubuntu to install 64-bit ubuntu and report "Couldn't find hvm kernel for Ubuntu tree.", kvmhvm

1. The configuration of virt-install used for ubuntu installation:


virt-install \
--name test4 \
--ram 1024 \
--disk path=/data/01_ubuntu/ubuntu4.img,size=6 \
--vcpus 1 \
--hvm \
--os-type linux \
--network network=default \
--os-variant ubuntuquantal \
--graphics none \
--console pty,target_type=serial \
--location /data/00_osfile/ubuntu-16.04.1-server-amd64.iso \
--extra-args 'console=ttyS0,115200n8 serial'

The following error is reported:


ERROR Couldn't find hvm kernel for Ubuntu tree.Domain installation does not appear to have been successful.


By checking the information, we found that virt-install can enable the debug mode and add the -- debug option.

 

2. The result of the debug mode of virt-install is as follows:


[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:268) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.xPL9y1/current/images/MANIFEST
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:89) Fetching URI: /var/lib/libvirt/boot/virtinstmnt.xPL9y1/install/netboot/version.info
Retrieving file version.info...                                                                                                                      |   58 B  00:00:00     
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:1164) Didn't find any known codename in the URL string
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:511) Detected distro name=Ubuntu osvariant=linux
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:268) local hasFile: Couldn't find /var/lib/libvirt/boot/virtinstmnt.xPL9y1/install/netboot/ubuntu-installer/i386/linux

Here we can see that the problem is clearly a 64-bit operating system, why find the path of./install/netboot/ubuntu-install/i386/linux?

Let's take a look at the correct path in the iso file:

[root@11.102 01_ubuntu]$mount /data/00_osfile/ubuntu-16.04.1-server-amd64.iso /mntmount: /dev/loop2 is write-protected, mounting read-only
[root@11.102 01_ubuntu]$ls /mnt/install/netboot/ubuntu-installer/amd64/linux /mnt/install/netboot/ubuntu-installer/amd64/linux

Basically, if you change i386 in the path to amd64, virt-install installation will be fine.

Remaining logs in debug mode:


[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (urlfetcher:320) Cleaning up mount at /var/lib/libvirt/boot/virtinstmnt.xPL9y1
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (cli:305)   File "/usr/share/virt-manager/virt-install", line 1077, in <module>
    sys.exit(main())
  File "/usr/share/virt-manager/virt-install", line 1071, in main
    start_install(guest, continue_inst, options)
  File "/usr/share/virt-manager/virt-install", line 775, in start_install
    fail(e, do_exit=False)
  File "/usr/share/virt-manager/virtinst/cli.py", line 305, in fail
    logging.debug("".join(traceback.format_stack()))

[Wed, 30 Nov 2016 11:16:07 virt-install 26900] ERROR (cli:306) Couldn't find hvm kernel for Ubuntu tree.
[Wed, 30 Nov 2016 11:16:07 virt-install 26900] DEBUG (cli:308) 
Traceback (most recent call last):
  File "/usr/share/virt-manager/virt-install", line 747, in start_install
    dom = guest.start_install(meter=meter, noboot=options.noreboot)
  File "/usr/share/virt-manager/virtinst/guest.py", line 491, in start_install
    self._prepare_install(meter, dry)
  File "/usr/share/virt-manager/virtinst/guest.py", line 304, in _prepare_install
    self.installer.prepare(self, meter)
  File "/usr/share/virt-manager/virtinst/installer.py", line 200, in prepare
    self._prepare(guest, meter)
  File "/usr/share/virt-manager/virtinst/distroinstaller.py", line 451, in _prepare
    self._prepare_kernel_url(guest, fetcher)
  File "/usr/share/virt-manager/virtinst/distroinstaller.py", line 360, in _prepare_kernel_url
    kernel, initrd, args = store.acquireKernel(guest)
  File "/usr/share/virt-manager/virtinst/urlfetcher.py", line 603, in acquireKernel
    {"distro": self.name, "type" : self.type})
RuntimeError: Couldn't find hvm kernel for Ubuntu tree.

 

 

3. Modify virt-manager Code:

Through the above error, we found that virt-manager was written in python! I just want to see what source code comes from. This is exactly the case!

Debug the virt-manager project step by step to find the problem:


[root@11.102 ~]$grep -n -A22 "class DebianDistro" /usr/share/virt-manager/virtinst/urlfetcher.py
1076:class DebianDistro(Distro):
1077-    # ex. http://ftp.egr.msu.edu/debian/dists/sarge/main/installer-i386/
1078-    # daily builds: http://d-i.debian.org/daily-images/amd64/
1079-    name = "Debian"
1080-    urldistro = "debian"
1081-    os_variant = "linux"
1082-
1083-    def __init__(self, *args, **kwargs):
1084-        Distro.__init__(self, *args, **kwargs)
1085-
1086-        # Pull the tree's arch out of the URL text
1087-        self._treeArch = 'i386'
1088-        for pattern in ["^.*/installer-(\w+)/?$",
1089-                        "^.*/daily-images/(\w+)/?$"]:
1090-            arch = re.findall(pattern, self.uri)
1091-            if arch:
1092-                self._treeArch = arch[0]
1093-                break
1094-
1095-        self._url_prefix = 'current/images'
1096-        self._installer_dirname = self.name.lower() + "-installer"
1097-        self._set_media_paths()

We found the Debian-based system in the __init _ method self. _ treeArch is i386 during initialization. It is estimated that virt-manager is reading the ubuntu iso file. What is the problem? The system is x86_64 and the value is changed to amd64, you can.

Run virt-install again. The ubuntu installation page is displayed!

 

Appendix: Solution for installing 64-bit ubuntu with KVM through CentOS command line "Couldn't find hvm kernel for Ubuntu tree ."

Grep-n-A21 'class Debian distro'/usr/lib/python2.6/site-packages/systinst/OSDistro. py command to view the _ init _ method of the Debian class

[root@2 virtinst]$grep -n -A21 'class DebianDistro' /usr/lib/python2.6/site-packages/virtinst/OSDistro.py
892:class DebianDistro(Distro):
893-    # ex. http://ftp.egr.msu.edu/debian/dists/sarge/main/installer-i386/
894-    # daily builds: http://people.debian.org/~joeyh/d-i/
895-
896-    name = "Debian"
897-    os_type = "linux"
898-
899-    def __init__(self, uri, arch, vmtype=None, scratchdir=None):
900-        Distro.__init__(self, uri, arch, vmtype, scratchdir)
901-        if uri.count("installer-i386"):
902-            self._treeArch = "i386"
903-        elif uri.count("installer-amd64"):
904-            self._treeArch = "amd64"
905-        else:
906-            self._treeArch = "i386"
907-
908-        if re.match(r'i[4-9]86', arch):
909-            self.arch = 'i386'
910-
911-        self._installer_name = self.name.lower() + "-" + "installer"
912-        self._prefix = 'current/images'
913-        self._set_media_paths()

Change the else in the _ init _ method: Change "i386" to "amd64" in the row below the condition.

- self._treeArch = 'i386'+ self._treeArch = 'amd64'

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.