How To Compile The Kernel

Table of contents:

How To Compile The Kernel
How To Compile The Kernel

Video: How To Compile The Kernel

Video: How To Compile The Kernel
Video: Compiling The Linux Kernel On Ubuntu u0026 Debian 2024, November
Anonim

One of the advantages of operating systems of the Linux family is their extreme flexibility, expressed in the ability to fine-tune almost all components. For example, you can compile a kernel with configuration options tailored specifically to the hardware you are currently using. By installing such a kernel, you can significantly increase the overall performance of the system.

How to compile the kernel
How to compile the kernel

Necessary

  • - access to the repository with source packages or Internet access;
  • - the password for the root user on the local machine.

Instructions

Step 1

Get the kernel sources. If you have access to the source repository and it includes a package with the correct version of the kernel, install this package using the apt-get or synaptic utility.

If you don't have access to the repositories, or you need to build a specific version of the kernel, get the sources from the kernel.org server. Open https://www.kernel.org/pub/linux/kernel in your browser. Change to the subdirectory corresponding to the required kernel version line. Select the desired archive and download it to your hard drive. Use the browser's save feature or your preferred download manager. You can also download the archive with the kernel source code of the required version via FTP from the ftp.kernel.org server.

Download kernel patches (patches) if needed. Pick up the patches you want at kernel.org and save them to your hard drive as well.

Step 2

Prepare your system for kernel compilation. Install gcc compiler, develop glibc and ncurses packages, fakeroot package (unless you plan to build the kernel as root). Install the TCL / TK libraries if you want to configure the kernel using a graphical interface under the control of an X server.

Step 3

Prepare your kernel source tree. Unpack the source archive to the / usr / src / linux directory. Or unpack it into an arbitrary directory and create a linux symbolic link to it from the / usr / src directory. Use a decompressor program that matches the type of archive you downloaded (tar or bzip).

Apply patches to the kernel sources if necessary. Unpack the patches into the / usr / src directory. Use the patch command to apply the changes.

Step 4

Configure the kernel. If the version of the configuration should be based on the one already on the system, copy the file named like config- from the / boot directory to the / usr / src / linux directory and rename it to.config.

Change to the / usr / src / linux directory. Run make with config, menuconfig, oldconfig, or xconfig. The config parameter will allow you to configure the kernel step by step. If you specify oldconfig, the values of the old configuration will be used as much as possible. The make menuconfig command will allow configuration using a convenient text-based menu, and make xconfig will launch the graphical configurator. Set all required kernel configuration parameters.

Step 5

Compile the kernel. Run make dep and make clean sequentially to generate dependency files and clean up the source tree. Run make bzImage to compile and create a kernel image file. Compile the kernel modules by typing make modules in the console.

Recommended: