Fastest way to install custom kernel in virtual machine

4

I have a custom kernel that needs to be installed on multiple virtual machines.

One way to do it transfer the source to each VM and then compile and install.

I would like to know if there is a faster way where I could compile on host and simply transfer some file or install kernel through host files.

Both host and guest OS are ubuntu 14.04 and I am using KVM as a hypervisor.

I used this link for compile and install kernel.

Nofel Yaseen

Posted 2017-03-21T18:51:47.697

Reputation: 41

Answers

0

I'd recommend using your distribution's packaging system. Create your custom kernel package, and then you can distribute it to your VMs in whatever way is easiest. Many distributions provide instructions for how to do this with their preferred package manager (see below for Ubuntu's).

If you find yourself rebuilding the kernel (and/or other software) often, you could create a local package repository (eg on the host) to add to the guests' repository list. Then the guests will be able to pull any new packages as soon as they're available.

If you only have a few packages to distribute, putting them on the host in an ad-hoc local package cache works just as well. Share this location with the guests with Samba, or simply rsync the packages manually when needed.


On Ubuntu, building a custom kernel package boils down to:

  1. Get the source

    • apt-get source linux-image-$(uname -r) OR
    • git clone git://kernel.ubuntu.com/ubuntu/ubuntu-<releasename>.git
  2. Prepare your build environment

    • sudo apt-get build-dep linux-image-$(uname -r)
  3. Modify your kernel config

    • chmod a+x debian/rules debian/scripts/* debian/scripts/misc/*
    • fakeroot debian/rules clean
    • fakeroot debian/rules editconfigs (go through each)
    • Add a local version identifier (eg +myVer1) to the end of the first version number in debian.master/changelog so apt recognizes it as a newer kernel than the official repository's version.
  4. Build the kernel

    • fakeroot debian/rules clean
    • fakeroot debian/rules binary-headers binary-generic binary-perarch (quick build) OR
    • fakeroot debian/rules binary (slower, if linux-tools or lowlatency needed)

If the build succeeds, your custom .deb packages will be in the directory above the build root.

quixotic

Posted 2017-03-21T18:51:47.697

Reputation: 659