Unfortunately I didn’t manage to finish that tutorial this weekend. I am having all kinds of hell trying to compile kernel 4.10 from Ubuntu on Ubuntu itself. All I want to do is recompile it with the
CONFIG_RCU_NOCB_CPU_ALL flags as specified here in comment 22.
If anyone can post a video of compiling the kernel on Ubuntu 16.04 I would be grateful. The last error I got before stopping is this:
cc1: fatal error: ./ubuntu/vbox/vboxguest/include/VBox/VBoxGuestMangling.h: No such file or directory
Unfortunately, I have to compile the kernel on a single thread rather than using
-j [thread number] in order to see the error messages, so each attempt takes roughly 30-40 minutes.
In case anyone else can take my work and fix it, I am posting it below.
Unfinished Work to try and recompile kernel with flags for Ryzen
Update Grub Timeout
Update grub configuration file so that we have enough time to select our own kernel. The commands below will set it to a 10 second timeout.
sudo sed -i "s;$SEARCH;$REPLACE;g" $FILEPATH
Ensure Running 4.10
Next, ensure you are running the 16.04.3 with the 4.10 kernel. To check, you can just run
uname -r and you should get the following output:
If you are not running 4.10, then update it.
We are only doing this because we are focusing on Ryzen stability, we want to be building for the 4.10 kernel and using it’s config as part of the process.
There are some packages we will need in order to compile the kernel later.
sudo apt-get install build-essential libssl-dev bc -y
Create A Workdir
Lets create an area to work in so that when we are finished with building the kernel we can just delete everything in our workdir to clean up.
In preparation for the next step, we need to ensure we have sources in our
/etc/apt/sources.list file. If the lines below aren’t in there, you need to add them.
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ xenial restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ xenial-updates restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb-src http://security.ubuntu.com/ubuntu xenial-security restricted main universe multiverse #Added by software-properties
deb-src http://gb.archive.ubuntu.com/ubuntu/ xenial-proposed restricted main universe multiverse #Added by software-properties
Then you need to update your package indexes.
sudo apt update
If you don’t do this, you may get an error in the next step like:
You must put some 'source' URIs in your sources.list
Fetch Ubuntu Specific Kernel
Because we want the Ubuntu specific kernel with any changes they have made we will do the following to fetch the kernel source to build from:
sudo apt-get install dpkg-dev -y
sudo apt-get source linux-image-$(uname -r) -y
sudo apt-get build-dep linux-image-$(uname -r) -y
This is a fairly large download (144MB for me) and may take a while to complete.
If you get an error message like below, just ignore it.
W: Can't drop privileges for downloading as file 'linux-hwe_4.10.0-34.38~16.04.1.dsc' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
In the end you should have the following output from
drwxr-xr-x 30 root root 4.0K Aug 25 13:34 linux-hwe-4.10.0
-rw-r--r-- 1 root root 9.0M Aug 16 09:29 linux-hwe_4.10.0-33.37~16.04.1.diff.gz
-rw-r--r-- 1 root root 5.7K Aug 16 09:29 linux-hwe_4.10.0-33.37~16.04.1.dsc
-rw-r--r-- 1 root root 138M Jun 30 07:08 linux-hwe_4.10.0.orig.tar.gz
Give ourselves ownership.
sudo chown -R $USER:$USER *
Copy the Config
Navigate to the kernel folder and copy our distribution’s config here.
cp /boot/config-$(uname -r) .config
Edit The Config
Now we are going to edit the config to add
CONFIG_RCU_NOCB_CPU_ALL, which is the whole point of this tutorial. We are going to alter the configuration based on this comment, in order to improve the stability on Ryzen.
I decided to ADD them under the commented out
CONFIG_RCU_EXPERT so my config looks like:
# CONFIG_RCU_EXPERT is not set
Change Kernel Version Number
In order to make your kernel “newer” than the stock Ubuntu kernel from which you are based you should add a local version modifier.
Add something like “+test1” to the end of the first version number in the
debian.master/changelog file, before building. This will help identify your kernel when running as it also appears in
When a new Ubuntu kernel is released, it will be newer than your kernel, so you will have to regenerate it and be careful when upgrading.
Below is the command to compile the kernel using 8 threads. You probably do want to take SMT into account, so use an 8 if you are on Ryzen 5 with 4 cores/8 threads, or 16 for a 1700 or higher. If you are debugging, just use make on its own so that you will see any error messages.
This will take a while, so set a timer for 20-30 minutes and come back.
Install and Reboot
Install the kernel with:
sudo make modules_install install
Reboot and prey for no black screen of death. Because we updated our grub configuration to set a longer timeout, it should be easy enough to select an older kernel if something went wrong.
Optional - Reduce Grub Timeout
If everything worked, you may want to reduce your Grub timeout for faster reboots.
sudo sed -i "s;$SEARCH;$REPLACE;g" $FILEPATH