Compile
Compile
Anthony McGlone
Chapter 1: Introduction 2
1.1 Installing Oracle VirtualBox . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Chapter 2: Debian - Ubuntu - Linux Mint 3
2.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Download the latest Linux kernel . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Extract the source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.4 Configure the kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.5 Compile the kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.6 Install the kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.7 Boot the new kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Chapter 3: Red Hat - CentOS 7
3.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Download the latest Linux kernel . . . . . . . . . . . . . . . . . . . . . . . . . 7
1
Chapter 1 Introduction
This guide will demonstrate the basic process of compiling and booting a Linux kernel. More
advanced kernel configuration (such as enabling device drivers or new kernel modules) will not
be covered.
If you’re already using a Linux operating system (OS), you can skip ahead to the kernel in-
stallation instructions for your OS.
If you’re on Windows or macOS, you can use Oracle’s VirtualBox to build a Linux virtual
machine (VM). The VM’s hard disk size should be at least 50 gigabytes.
2
Chapter 2 Debian - Ubuntu - Linux Mint
2.1 Prerequisites
In your Linux OS or VM, open a terminal. Install the kernel compilation tools:
The Pretty Good Privacy (PGP) signature for the tar file should be verified before its con-
tents are extracted. On the kernel home page, find the table row corresponding to the latest
kernel version and copy the link address from the [pgp] link. In the wget command be-
low, replace <pgp link address> with this link. Then run the command to download the
tar.sign file:
Next, start the verification process. In the gpg command below, replace <tar sign file>
with the downloaded tar.sign file. Then run it:
The output from the command contains the Rivest–Shamir–Adleman (RSA) key, which will
be used in the verification of the tar file’s signature:
Replace <RSA key> in the following command with the RSA key from your terminal’s
output. Then run it:
3
gpg --recv-keys --keyserver hkps://keyserver.ubuntu.com <RSA key>
This command should download a public key that will be used in the verification. The out-
put will look like this:
There should now be a folder with the extracted source code (e.g. linux-6.0.2/)
The next step is to run make menuconfig. This will load a graphical dialog (see Figure
2.1). The dialog can be used to add or remove modules from the config (do not edit the config
at this time). A quick note on the dialog controls. Use the up/down arrow keys to navigate
vertically. Use the Enter/return key to select a submenu in the dialog. Typing Y will include a
feature. Typing N will exclude it. Use the left/right arrow keys to navigate to Exit when you
want exit a submenu or the dialog.
4
Figure 2.1: Linux kernel configuration dialog
Navigate around the dialog to examine the submenus. Then exit the dialog. Run the following
commands to ensure there are no certificate signing errors during the compilation process:
make -j 2
Note: Once you run this command, you will have to answer a long list of questions. Press
the Enter/return key to select the default option for each answer. When the compilation is
finished, the command prompt will be returned.
Once the command prompt is returned, run the kernel installation command:
5
When the install command is finished, run ls -l /boot. Three files should be updated
(X.X.X should show the version number of the new kernel):
reboot
uname -mrs
6
Chapter 3 Red Hat - CentOS
3.1 Prerequisites
In your Linux OS or VM, open a terminal. Install the GCC compiler: