Building a patched Linux kernel in Linux Mint

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
jjberk
Level 1
Level 1
Posts: 26
Joined: Wed Dec 23, 2015 2:49 pm

Building a patched Linux kernel in Linux Mint

Post by jjberk »

I had reason to run a patched kernel for testing purposes recently. As I am not familiar with building/patching kernels, it took a while before I got a useful result. This post is meant to help those in similar circumstances.

But first:
If you patch and build your own kernel and do not exactly know what you are doing, you are on your own. If you DO know what you are doing, you are STILL on your own, but with a better chance to get things right.
Caveat emptor.

My procedure:
1.
If you are using an NVIDIA driver, start up "Driver Manager" from the menu and switch to the nouveau driver. Then reboot.

2.
Get the source code for the kernel you want to patch/use and extract it in a separate directory (a subfolder of your home directory would be fine, for instance /home/new_kernel/linux-5/19/10). Let's call this directory the Linux folder.

3.
Use "Mainline" (install with apt if necessary) to install a kernel with at least the same main version number as that of the downloaded source code (for instance if you downloaded the source for kernel 5.19.11 some kernel in the 5.19 range). DO NOT REBOOT.

4.
Copy the /boot/config-[version number] of the with "Mainline" installed kernel into the Linux folder.

5.
Use "Mainline" to remove the just installed kernel.

6.
Copy the files /usr/local/src/debian/canonical-certs.pem and /usr/local/src/debian/canonical-revoked-certs.pem into the Linux folder subdirectory /debian.

7.
Patch your new kernel.

8.
Open a terminal in the Linux folder and run:

Code: Select all

make olddefconfig
make -j(nproc)
sudo make INSTALL_MOD_STRIP=1 modules_install
sudo make install
9.
Reboot into the new kernel.

10.
If all works as expected, celebrate!
Last edited by SMG on Tue Sep 27, 2022 10:11 am, edited 1 time in total.
Reason: Moved from Softwar & Applications to Tutorials because this is not a request for help, but it is directions to help others.
Post Reply

Return to “Tutorials”