Build kernel in one machine, install in another
The 'best' way to do this, is building it as a package. You can then distribute and install it to any Ubuntu machine running the same (major) version.
For building vanilla kernels from source, there's a tool make-kpkg
which can build the kernel as packages. Other major advantages: easy reverting by just removing the package, automatic triggers by the package management such as rebuilding DKMS, etc.
The Ubuntu community wiki on Kernel/Compile Alternate Build Method provides a few steps on how to do that.
Basically, it's just the same as building the kernel from upstream documentation, but instead of having make
blindly installing it on your system, have it build in a 'fake root' environment and make a package out of it, using
fakeroot make-kpkg --initrd --append-to-version=-some-string-here \
kernel-image kernel-headers
This should produce binary .deb
files which you will be able to transfer to other machines and install it using
dpkg -i mykernelfile-image.deb mykernelfile-headers.deb ...
I would comment on gertvdijk's answer but I don't have enough rep to comment.
I don't know if any of that is necessary now that rpm-pkg, deb-pkg, snap-pkg are viable targets for make.
So with Ubuntu, I'd imagine you'd like to use
make bindeb-pkg
(use make deb-pkg
if you need to include source)
on RPM distros (RHEL, Fedora, CentOS) you'd use rpm-pkg/binrpm-pkg
see the Kernel Packaging section of make help
for all options
Kernel packaging:
rpm-pkg - Build both source and binary RPM kernel packages
binrpm-pkg - Build only the binary kernel RPM package
deb-pkg - Build both source and binary deb kernel packages
bindeb-pkg - Build only the binary kernel deb package
snap-pkg - Build only the binary kernel snap package (will connect to external hosts)
tar-pkg - Build the kernel as an uncompressed tarball
targz-pkg - Build the kernel as a gzip compressed tarball
tarbz2-pkg - Build the kernel as a bzip2 compressed tarball
tarxz-pkg - Build the kernel as a xz compressed tarball
perf-tar-src-pkg - Build perf-5.2.0.tar source tarball
perf-targz-src-pkg - Build perf-5.2.0.tar.gz source tarball
perf-tarbz2-src-pkg - Build perf-5.2.0.tar.bz2 source tarball
perf-tarxz-src-pkg - Build perf-5.2.0.tar.xz source tarball