The following document should help users build their own kernel from the latest stable kernel from kernel.org. Please note that the following steps are targeted towards Ubuntu users, though they will also work on Ubuntu deratives (including Mint, Elementary, Deepin etc.) and may also work on Debian and non-Ubuntu, Debian deratives.
PrerequisitesThere are a few tools that are necessary in order to build your own kernel(s). The ‘kernel-package’ provides the make-kpkg utility which automatically build your kernel and generate the linux-image and linux-header .deb files which can be installed. You will need to install the following packages:
sudo apt-get install build-essential kernel-package fakeroot libncurses5-dev
Kernel Build and Installation
- Change to the directory where you want to download the kernel source. In this example we will use ~/src:
- Download the kernel:
v3.x/linux-3.15.8.tar.xzwith the kernel version you want to download. 3.15.8 was the latest stable version at the time of writing.
- Extract the files:
Again, make sure to change the filename to be the same as the file you downloaded. You can also remove the original tar.xz file once all the files have been extracted.
tar xf linux-3.15.8.tar.xz
- Change the directory:
The directory name will be the same as the filename of the tar.xz you downloaded, except without the
- Copy the kernel config file from your existing system to the kernel tree:
cp /boot/config-`uname -r` .config
- Bring the config file up to date. In cases where your kernel source is significantly newer than the existing config file, you’ll be presented with all of the new config options for which there is no existing config file setting. You can either sit there and keep hitting Enter to take the default (generally safe), or you can just run:
which emulates exactly the same thing and saves you all that time. Otherwise, run:
yes '' | make oldconfig
- (optional) If you need to make any kernel config changes, do the following and save your changes when prompted:
- Clean the kernel source directory:
- Build the linux-image and linux-header .deb files using a thread per core + 1. This process can take a lot of time - it took about 17 hours on my old laptop with a Celeron processor, but it should take between 20 minutes and 3 hours on a modern computer:
With this command the package names will be something like linux-image-3.15.8-custom and linux-headers-3.15.8-custom, and in that case the version will be 3.15.8-custom-10.00.Custom. You may change the string “custom” into something else by changing the LOCALVERSION option.
make -j `getconf _NPROCESSORS_ONLN` deb-pkg LOCALVERSION=-custom
- Change to one directory level up (this is where the linux-image and linux-header .deb files were put):
- Now install the .deb files. Replace the filenames in this example to match your filenames:
sudo dpkg -i linux-firmware-image-3.15.8-custom_3.15.8-custom-1_i386.deb
sudo dpkg -i linux-headers-3.15.8-custom_3.15.8-custom-1_i386.deb
sudo dpkg -i linux-image-3.15.8-custom_3.15.8-custom-1_i386.deb
sudo dpkg -i linux-image-3.15.8-custom-dbg_3.15.8-custom-1_i386.deb
sudo dpkg -i linux-libc-dev_3.15.8-custom-1_i386.deb
- Reboot to your new kernel! Just make sure you select it when you boot: