+4 votes
349 views
How to compile Kernel Linux CentOS 7

in Linux / Unix by (552k points)
reopened | 349 views

1 Answer

+5 votes
Best answer

1. How to install the necessary packages to compile Kernel Linux CentOS 7
2. How to compile and install Linux CentOS 7 Kernel
3. How to configure Kernel Linux on CentOS 7
4. How to compile the kernel in CentOS 7 (Linux)

One of the most fundamental elements in any Linux distribution is the kernel and although we have heard about it, on many occasions we do not know with certainty what role it plays in the system..

The Linux kernel is basically the core component of the GNU / Linux operating system, and its function is linked to managing the hardware resources of the computer such as the CPU, memory and hard drives , and thus offering the best use of These resources, and similarly with the kernel, are provided drivers for devices that are connected to different system buses such as USB, PCI, SATA or IDE.

For administration or control issues in some specific cases we can resort to a custom-compiled Linux kernel in order to enable or disable specific functions of said Kernel, which are not available by default in the distribution kernel. To do this, TechnoWikis will explain in detail how to compile and use the most recent Linux kernel taken from the sources in CentOS 7..


1. How to install the necessary packages to compile Kernel Linux CentOS 7


First, we will update the repositories of the software packages, proceed to install the development tools necessary to compile a kernel, and install the ncurses library with the yum command as follows:
 yum update yum install -y ncurses-devel make gcc bc bison flex elfutils-libelf-devel openssl-devel grub2 

image


2. How to compile and install Linux CentOS 7 Kernel


The next step is to download the latest sources of Kernel 4.17 using the wget command in the / usr / src / directory or alternatively download the last kernel by visiting the following link:
kernel
Note
The stable version at this time is 4.17.11.
Step 1

First, we access the indicated directory:
 cd / usr / src / 
Then we download the kernel by running:
 wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.17.11.tar.xz 

image

Step 2

We proceed to extract the compressed files and modify the directories using the following commands:
 tar -xvf linux-4.17.11.tar.xz 

image

Now we access the kernel directory as follows:

 cd linux-4.17.11 / 

3. How to configure Kernel Linux on CentOS 7


Step 1

The Kernel for CentOS 7 must be configured correctly with the following configuration options that are required within the system environment:
 CONFIG_KVM_GUEST = y CONFIG_VIRTIO_PCI = y CONFIG_VIRTIO_PCI_LEGACY = y CONFIG_BLK_DEV_SD CONFIG_SCSI_VIRTIO = y CONFIG_VIRTIO_NET = y CONFIG_SERIAL_8250 = y CONFIG_SERIAL_8250_CONSOLE = y 
Now we are going to copy the running Kernel configuration (.config) from the / boot directory to the new Linux-4.17.11 kernel as follows:
 cp -v /boot/config-3.10.0-693.5.2.el7.x86_64 /usr/src/linux-4.17.11/.config 
Now we are going to execute the make menuconfig command in order to configure the Linux kernel, and as soon as the command is executed, a pop-up window with all the kernel menus will be displayed, there it will be possible to enable or disable certain kernel features and if We want to exit just press the ESC key to exit the wizard.

image

Step 2

The following wizard will be displayed, there we will define the parameters as we deem necessary.

image

Step 3

When we make the desired changes we select the Save option to apply these changes and we will see the following. Select "Ok" to finish the process.

image

Step 4

The following will be displayed, click on "Exit" to exit the assistant.

image


4. How to compile the kernel in CentOS 7 (Linux)


Before starting the process we must validate the free space in the file system, for this we execute the following:
 df -h 

image

Now we will compile and install the kernel and modules with the following commands, this can take a considerable time, the compilation process assigns the files in the / boot directory and creates a new kernel entry in the grub.conf file:

 make bzImage make modules make make install make modules_install 

image

Once this process is finished, we will restart the system and verify the new kernel by executing the following:

 join me -sr 

image

In this way we have learned to compile the Linux kernel in CentOS 7.


by (3.5m points)
edited

Related questions

+4 votes
1 answer
asked Oct 13, 2019 in Linux / Unix by backtothefuture (552k points) | 1.4k views
+5 votes
1 answer
+3 votes
1 answer
asked Nov 16, 2019 in Linux / Unix by backtothefuture (552k points) | 652 views
+3 votes
1 answer
+4 votes
1 answer
asked Oct 4, 2019 in Linux / Unix by backtothefuture (552k points) | 370 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users