0

I'm on Ubuntu 18.04 and I'm having problems with my iGPU hanging my system (this bug here: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1861395).

I'm currently on the 5.3 kernel, but I want to try changing kernels to fix the problem.

I don't really need super-cutting edge kernel features, I'm more interested in stability.

Should I upgrade to 5.6? or downgrade to 5.2 or 4.XX?

How should I do it so that I can safely go back to the official kernel from the repos if something goes wrong?

Edit: It has been drawn to my attention that this question is quite similar to mine: How to update kernel to the latest mainline version without any Distro-upgrade?.

However, it only covers how to upgrade kernels, not how to ensure that I can safely revert my system to its previous state using the package manager. With most packages you install through PPAs, apt will replace the old version with the new on. Is it the same for kernels?

2 Answers2

1

You can install mainline kernels from Ubuntu kernel PPA.

You can install as many as you like. The system will boot with the latest one by default, but you can select any kernel in grub menu.

To revert to the standard Ubuntu kernel, boot with it and remove all mainline kernels using e.g. synaptic.

Pilot6
  • 90,100
  • 91
  • 213
  • 324
  • I don't usually boot with GRUB. If for some reason the boot completely fails with the new kernel, will it fall back on the old one? – setholopolus May 05 '20 at 17:48
  • No, it won't fall back. What do you mean by "I don't usually boot with GRUB"? Is grub installed? If this is the case, you can always get to grub nmenu using ESC key even if the menu is hidden. If you really don't use grub, it is more complex. – Pilot6 May 05 '20 at 17:51
  • I meant that the menu doesn't come up by default. Pushing ESC while booting will solve my use case. Thanks! – setholopolus May 05 '20 at 17:52
  • Check if you can get there, before you try. – Pilot6 May 05 '20 at 17:53
-1

Abstract

To upgrade to a kernel I would suggest going for a stable build. Also, as a rule of thumb, I recommend always upgrading your kernel and never downgrading because it can cause system flaws.

Required Installs for this Guide

sudo apt-get install -y gcc libncurses5-dev make wget flex bison vim libssl-dev libelf-dev

How To

In order to change your current kernel it takes some patience and caution, but there is definitely a way to do it while still having the ability to revert back to the original kernel. So let's get started, I recommend doing all of this with root so first do sudo -i and enter your password.

So let's go ahead and download the latest stable kernel as of now (2020-05-05).

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.5.19.tar.xz

Note: You may need to install wget for this to work (apt-get install wget).

Now let's extract this archive and move it to a suitable directory.

tar -xvf linux-5.5.19.tar.xz -C ../usr/src/

Note: You may need to install tar for this to work (apt-get install tar).

This extracted the archive to a directory that contains all the other kernels. We're now going to cd into that directory to complete the next few steps.

cd ../usr/src/linux-5.5.19/

Now for the fun part :)

If you don't have a strong computer this part can easily take 2 hours to complete so please be warned if you are on battery life or on a time crunch. Also, be sure to read all the following directions before rebooting (it will be essential if anything goes wrong).

We are now going to compile the kernel, so just follow the following commands and please let all of them run to completion. This first command usually takes the longest for people. Also, I will be using the -j4 flag on these make commands in order to speed up the process. It basically utilizes 4 cores for the compilation instead of one (I'm assuming you have 4 cores, and if not you can just leave off the -j4).

make -j4

Note: You may need to install make for this to work (apt-get install make).

make modules -j4

make modules_install -j4

make install -j4

DON'T REBOOT YET

We will now be modifying grub to give you time to choose the kernel you want to use on startup.

cd ~/../etc/default/

vim grub

Note: You can use any text editor you're familiar with, another popular one is nano, but please be familiar with your choice and know how to edit and save. I have chosen vim for this guide and you may need to install vim for it to work (apt-get install vim).

Modify the following lines to this (in vim you press i to start editing and navigate with the arrow keys):

GRUB_DEFAULT=2
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=25

To save the file, press ESC, then press :wq! and hit enter.

Now for your last and final step, you need to update grub.

update-grub2

Once that command finishes you may restart your system (reboot).

Once the system comes back you will notice that you are prompted at startup for some options. Select advanced options and then select your new linux-5.5.19 kernel.

If there are any issues with this guide please leave a comment and I will try to address the issue by editing this guide.

Hope it works!

VoidTwo
  • 469
  • Why would you suggest to BUILD a kernel from source? – Pilot6 May 05 '20 at 17:26
  • I guess I'm old school for this type of thing. It allows the user to see exactly what is happening and know exactly what they are doing to their computer. – VoidTwo May 05 '20 at 17:28
  • 1
    Ya does this require building? Also, I'm not super comfortable with just running make install because I have no idea what files are dumped where if I do that. I want to be able to revert and recover my exact system from before using the package manager. – setholopolus May 05 '20 at 17:29
  • You can revert, when you restart your computer you will be able to select the kernel you want to use. Also, the make command will show you everything that is happening, and on the plus side, you don't have to install some arbitrary software to install a kernel. And who knows what kind of package managing another software might use. – VoidTwo May 05 '20 at 17:31
  • 1
    This is a wrong way of installing kernels to Debian like system. Even building is wrong. It will spoil everything. – Pilot6 May 05 '20 at 17:46
  • @Pilot6 I've used this method numerous times and it has worked every time. Not sure what you mean by spoiling everything. Could you elaborate? – VoidTwo May 05 '20 at 17:48
  • 1
    It is a long story. Installing kernels without using debian packages is wrong. It will be hard to track, hard to remove, etc. – Pilot6 May 05 '20 at 17:49
  • If you really want to build a kernel from source, there is a way to make deb packages. – Pilot6 May 05 '20 at 17:52
  • @Pilot6 You have piqued my interest now. Do you have any guides/links on another method for building kernels? I'm always open for faster and more stable methods. – VoidTwo May 05 '20 at 18:57
  • You can google "build Ubuntu or Debian kernel" and find a lot of info. I do kernel developing and deal with may kernels at a time. Kernals should be debianised then built with debian/rules. – Pilot6 May 05 '20 at 18:59
  • For example https://gist.github.com/silviucc/c3a19ba1306e232c9391 – Pilot6 May 05 '20 at 19:03