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:
Get the source
apt-get source linux-image-$(uname -r)
OR
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-<releasename>.git
Prepare your build environment
sudo apt-get build-dep linux-image-$(uname -r)
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.
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.