Compiling the Linux Kernel -Part 1

Many occasions, we wish to develop our own modules, look into various aspects of the Linux kernel code or need to develop our own version of our kernel for specific purposes. This article tries to cover the topic of compiling the Linux kernel code.

Some requirements that will be needed

  • Linux operating system to compile the code(e.g. say Ubuntu) – may be it might be possible to compile the code using “cygwin” on a Windows Operating system. However, it might require some work and might not be that straight forward.
  • Internet connectivity to obtain the code from www.kernel.org . The code obtained can be signature verified to check if the downloaded tarball is proper.

Steps to Download and verify the code:

  • Download the code (tarball.xz file) from www.kernelorg. I am downloading Linux kernel version 5.9.1 (stable) to be compiled (via below command but it can also be downloaded via GUI -chrome/firefox etc).Download the signature file as well as shown below

curl -OL https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.9.1.tar.xz
curl -OL https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.9.1.tar.sign

  • The downloaded file would be in “.xz” format. install “xz-utils” if not present and decompress the file to a tar file with the below command

  • It is a good practice to verify whether the downloaded file is proper or if the downloaded file might be modified after it is uploaded. The interested reader can understand the concept behind it at the below link
  • check the downloaded code is proper – install “gnupg2” if not already present and verify whether the signature of the tarball file is proper. you might need to locate the relevant keys and later verify the tarball. steps to check the validity and correctness of the signature can be found in the link provided above.

  • Now that the code signature is verified – untar the tarball with the below command to start the compilation steps
    • tar -xvf linux-5.9.1.tar

  Compiling the Linux Kernel – Part 2

Comments

  1. Pingback: Compiling the Linux Kernel – Part 2 | Hitch Hiker's Guide to Learning

  2. Pingback: Monolithic Linux Kernel | Hitch Hiker's Guide to Learning

Leave a Reply

Your email address will not be published. Required fields are marked *