Installing a new kernel in Ubuntu

Installing a new kernel in Ubuntu

A guide on how to install a new kernel in your Ubuntu OS.

NOTE: THIS IS NOT A COPY / PASTE TUTORIAL – READ THE WHOLE GUIDE BEFORE INSTALLING ANYTHING!

This guide is taking base in a 64 bit system – if you have a 32 bit you should i386.deb instead.

I currently had an issue with my Ubuntu box, after upgrading to Ubuntu Xenial Xerus. Actually I probably had the issue longer, but as a part of the upgrade I saw that I was running an older version of the linux kernel, than the one that was shipped with Ubuntu Xenial Xerus. I decided to go all the way and get the newest – more on that later. First I will show you all how to install / upgrade or download your kernel in Ubuntu. I won’t go into detail about what a kernel is but you could read more about it here:

http://www.howtogeek.com/howto/31632/what-is-the-linux-kernel-and-what-does-it-do

First you need to know what version you are currently running. You can get that by typing:

$: uname -r

You will probably get an output similar to this one (except the version might differ):

3.19.8-22-generic

This is the kernel you are currently running. You can have multiple kernels installed and you can get a complete list of all installed kernels by typing:

$: dpkg -l | grep linux-image

This will give you a list like the one showed below:

ii linux-image-3.19.0-22-generic 3.19.0-22.22 amd64 Linux kernel image for version 3.19.0 on 64 bit x86 SMP
ii linux-image-3.19.8-031908-generic 3.19.8-031908.201505110938 amd64 Linux kernel image for version 3.19.8 on 64 bit x86 SMP
ii linux-image-extra-3.19.0-22-generic 3.19.0-22.22 amd64  Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP

As you can see I have currently installed version 3.19.0-22 and 3.19.8-031908.201505110938. Because I have 2 kernels installed, I’m able to boot into which ever kernel I want in the Grub menu, when I boot my computer. I have Ubuntu as my primary system and Windows 7 as a secondary. In my boot menu I can choose which OS to boot into, but also if I want “Advanced options for Ubuntu”. If you only have Ubuntu installed you can hold down the shift key at startup, then the boot menu (grub) will show at some point (see image below).

grub-menu

If you choose “Advanced options for Ubuntu” you will see a list of all bootable kernels. You probably already have some kernels in the list, since kernel cleanup is something you need to do yourself. It is good practice to have your current kernel and the last three versions before that, if you run into trouble. I found mine stable enough, so I took the chance and deleted all but one (my last working one 3.19.0-22).

Okay, now we know which version we have, but we don’t know where to find the kernels… Let me show you how. There are 2 way (that I know of). The first is the easiest – through the package manager apt-get. You can check which kernels are available by typing:

$: apt-cache search linux-image

I got this list of kernels and extra (more about that later)

alsa-base – ALSA driver configuration files
linux-image-4.4.0-21-generic – Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-4.4.0-21-lowlatency – Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-extra-4.4.0-21-generic – Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
linux-image-extra-virtual – Transitional package.
linux-image-extra-virtual-lts-utopic – Transitional package. (dummy transitional package)
linux-image-extra-virtual-lts-vivid – Transitional package. (dummy transitional package)
linux-image-extra-virtual-lts-wily – Transitional package. (dummy transitional package)
linux-image-extra-virtual-lts-xenial – Transitional package. (dummy transitional package)
linux-image-generic – Generic Linux kernel image
linux-image-generic-lts-utopic – Generic Linux kernel image (dummy transitional package)
linux-image-generic-lts-vivid – Generic Linux kernel image (dummy transitional package)
linux-image-generic-lts-wily – Generic Linux kernel image (dummy transitional package)
linux-image-generic-lts-xenial – Generic Linux kernel image (dummy transitional package)
linux-image-hwe-generic-trusty – Depends on the generic hardware enablement kernel image (dummy transitional package)
linux-image-hwe-virtual-trusty – Depends on the virtual hardware enablement kernel image (dummy transitional package)
linux-image-lowlatency – lowlatency Linux kernel image
linux-image-lowlatency-lts-utopic – lowlatency Linux kernel image (dummy transitional package)
linux-image-lowlatency-lts-vivid – lowlatency Linux kernel image (dummy transitional package)
linux-image-lowlatency-lts-wily – lowlatency Linux kernel image (dummy transitional package)
linux-image-lowlatency-lts-xenial – lowlatency Linux kernel image (dummy transitional package)
linux-image-virtual – This package will always depend on the latest minimal generic kernel image.
linux-image-virtual-lts-utopic – This package will always depend on the latest minimal generic kernel image. (dummy transitional package)
linux-image-virtual-lts-vivid – This package will always depend on the latest minimal generic kernel image. (dummy transitional package)
linux-image-virtual-lts-wily – This package will always depend on the latest minimal generic kernel image. (dummy transitional package)
linux-image-virtual-lts-xenial – This package will always depend on the latest minimal generic kernel image. (dummy transitional package)
linux-virtual – Minimal Generic Linux kernel and headers
linux-image-3.4.0-4-goldfish – Linux kernel image for version 3.4.0 on Android touch emulation
linux-image-goldfish – Linux kernel image for the goldfish kernel.
linux-image-4.4.0-22-generic – Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-4.4.0-22-lowlatency – Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-4.4.0-24-generic – Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-4.4.0-24-lowlatency – Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-extra-4.4.0-22-generic – Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
linux-image-extra-4.4.0-24-generic – Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
linux-image-extra-3.19.0-22-generic – Linux kernel extra modules for version 3.19.0 on 64 bit x86 SMP
linux-image-3.19.0-22-generic – Linux kernel image for version 3.19.0 on 64 bit x86 SMP
linux-image-3.19.8-031908-generic – Linux kernel image for version 3.19.8 on 64 bit x86 SMP

 

The “important” ones are in bold – they are of course all important, but the ones we are looking at is the ones I marked as bold. Here I assume you have version 3.19.8-031908 installed, if not it doesn’t matter just choose a kernel that you want. Remember you can also downgrade if something is not working, like your sound (mine did that when I upgraded) or something else. Now we install the kernel we selected. In this example we install the newest version: 4.4.0-24 by typing:

$: sudo apt-get -y install linux-image-4.4.0-24-generic

Now you have successfully installed a new kernel – but wait there is more… As you can see in the list above I highlighted the Linux kernels that is named extra. These are some extra modules normally containing drivers and other goodies for your machine. If you run a desktop edition of Ubuntu, I recommend you install this package, unless you know what you are doing. So lets install these too.

$: sudo apt-get -y install linux-image-extra-4.4.0-24-generic

Now we are almost there. The last thing we need to install are the Linux headers… The what? Yes, we haven’t talked about headers yet. Header files define interfaces to functions as well as structures used by programs and are needed by other programs that needs to compile to a specific specification. It all originates from C which is the language Linux is written. You don’t have to know what it is or what it do to install another kernel, so lets keep on going.

To install the headers we first need to find the right one. We need the one matching our newly installed kernel (4.4.0-24). By typing the following, you will get a list like the one we saw earlier.

$: apt-cache search linux-headers

The list looks like the one we got of images.

linux-headers-4.4.0-21 – Header files related to Linux kernel version 4.4.0
linux-headers-4.4.0-21-generic – Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
linux-headers-4.4.0-21-lowlatency – Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
linux-headers-generic – Generic Linux kernel headers
linux-headers-generic-lts-utopic – Generic Linux kernel headers (dummy transitional package)
linux-headers-generic-lts-vivid – Generic Linux kernel headers (dummy transitional package)
linux-headers-generic-lts-wily – Generic Linux kernel headers (dummy transitional package)
linux-headers-generic-lts-xenial – Generic Linux kernel headers (dummy transitional package)
linux-headers-lowlatency – lowlatency Linux kernel headers
linux-headers-lowlatency-lts-utopic – lowlatency Linux kernel headers (dummy transitional package)
linux-headers-lowlatency-lts-vivid – lowlatency Linux kernel headers (dummy transitional package)
linux-headers-lowlatency-lts-wily – lowlatency Linux kernel headers (dummy transitional package)
linux-headers-lowlatency-lts-xenial – lowlatency Linux kernel headers (dummy transitional package)
linux-headers-virtual – Transitional package.
linux-headers-virtual-lts-utopic – Transitional package. (dummy transitional package)
linux-headers-virtual-lts-vivid – Transitional package. (dummy transitional package)
linux-headers-virtual-lts-wily – Transitional package. (dummy transitional package)
linux-headers-virtual-lts-xenial – Transitional package. (dummy transitional package)
linux-libc-dev – Linux Kernel Headers for development
linux-libc-dev-arm64-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-armhf-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-powerpc-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-ppc64el-cross – Linux Kernel Headers for development (for cross-compiling)
linux-source-4.4.0 – Linux kernel source for version 4.4.0 with Ubuntu patches
linux-virtual – Minimal Generic Linux kernel and headers
linux-libc-dev-alpha-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-armel-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-hppa-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-m68k-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-mips-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-mips64-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-mips64el-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-mipsel-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-powerpcspe-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-ppc64-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-s390x-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-sh4-cross – Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-sparc64-cross – Linux Kernel Headers for development (for cross-compiling)
linux-headers-3.4.0-4-goldfish – Linux kernel headers for version 3.4.0 on Android touch emulation
linux-headers-goldfish – Linux kernel headers for the goldfish kernel.
linux-headers-4.4.0-22 – Header files related to Linux kernel version 4.4.0
linux-headers-4.4.0-22-generic – Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
linux-headers-4.4.0-22-lowlatency – Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
linux-headers-4.4.0-24 – Header files related to Linux kernel version 4.4.0
linux-headers-4.4.0-24-generic – Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
linux-headers-4.4.0-24-lowlatency – Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
linux-headers-3.19.8-992-generic – Linux kernel headers for version 3.19.8 on 64 bit x86 SMP
linux-headers-3.19.8-992 – Header files related to Linux kernel version 3.19.8

 

I have only highlighted the one we are going to install. And to do that we just type:

$: sudo apt-get -y install linux-headers-4.4.0-24-generic

Now you need to reboot your system. If you installed a version that is newer than the one you’d already had it should automatically boot up with the new kernel. You can check after reboot by typing the following, like earlier:

$: uname -r

If it says 4.4.0-24-generic you are good to go – remember to test the new system. If some fails you can go back by following the step above, when you boot. If the kernel did not automatically boot up, you can choose it manually like mentioned above.

I mentioned earlier I has some issues with my sound disappearing when I upgraded, so I say it again – test your machine through out. That said lets talk about the other method for upgrading. We have tried the easy way through apt package manager, but there is not many kernels to choose from. If you would like to install any kernel it would be nice to have a list to download from. It happens that we have such a list right here:

http://kernel.ubuntu.com/~kernel-ppa/mainline

In this repository you can also find release candidates (RC) if you want to try the absolutely newest (note: things might not work properly – but you can always revert to an older kernel). Go into the folder containing the kernel you would like to install. My example will be the for latest stable version right now (version 4.6.2-yakkety).

In the folder you will see all these folders and files:

0001-base-packaging.patch
0002-UBUNTU-SAUCE-no-up-disable-pie-when-gcc-has-it-enabl.patch
0003-debian-changelog.patch
0004-configs-based-on-Ubuntu-4.6.0-8.9.patch
BUILD.LOG
BUILD.LOG.amd64
BUILD.LOG.armhf
BUILD.LOG.binary-headers
BUILD.LOG.i386
BUILD.LOG.ppc64el
BUILD.LOG.s390x
BUILT
CHANGES
CHECKSUMS
CHECKSUMS.gpg
COMMIT
README
SOURCES
linux-headers-4.6.2-040602-generic-lpae_4.6.2-040602.201606100516_armhf.deb
linux-headers-4.6.2-040602-generic_4.6.2-040602.201606100516_amd64.deb
linux-headers-4.6.2-040602-generic_4.6.2-040602.201606100516_armhf.deb
linux-headers-4.6.2-040602-generic_4.6.2-040602.201606100516_i386.deb
linux-headers-4.6.2-040602-generic_4.6.2-040602.201606100516_ppc64el.deb
linux-headers-4.6.2-040602-generic_4.6.2-040602.201606100516_s390x.deb
linux-headers-4.6.2-040602-lowlatency_4.6.2-040602.201606100516_amd64.deb
linux-headers-4.6.2-040602-lowlatency_4.6.2-040602.201606100516_i386.deb
linux-headers-4.6.2-040602_4.6.2-040602.201606100516_all.deb
linux-image-4.6.2-040602-generic-lpae_4.6.2-040602.201606100516_armhf.deb
linux-image-4.6.2-040602-generic_4.6.2-040602.201606100516_amd64.deb
linux-image-4.6.2-040602-generic_4.6.2-040602.201606100516_armhf.deb
linux-image-4.6.2-040602-generic_4.6.2-040602.201606100516_i386.deb
linux-image-4.6.2-040602-generic_4.6.2-040602.201606100516_ppc64el.deb
linux-image-4.6.2-040602-generic_4.6.2-040602.201606100516_s390x.deb
linux-image-4.6.2-040602-lowlatency_4.6.2-040602.201606100516_amd64.deb
linux-image-4.6.2-040602-lowlatency_4.6.2-040602.201606100516_i386.deb

 

Again I marked all the files that needs to be downloaded. Just right click and click “Save link as” or navigate to a folder in the terminal and use wget:

$: wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.6.2-yakkety/linux-headers-4.6.2-040602-generic_4.6.2-040602.201606100516_amd64.deb

$: wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.6.2-yakkety/linux-headers-4.6.2-040602_4.6.2-040602.201606100516_all.deb

$: wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.6.2-yakkety/linux-image-4.6.2-040602-generic_4.6.2-040602.201606100516_amd64.deb

When they are all downloaded, navigate, in the terminal, to the folder where you did put your files and run:

$: sudo dpkg -i *.deb

That is it. You maybe have to accept the usage of some storage but that is it. You now have a new kernel installed from the Ubuntu PPA

I hope you found this helpful – please leave a comment.

Skriv et svar