Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

To download and configure the linux kernel

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article uses simple and easy-to-understand examples to introduce the steps to download and configure the linux kernel. The code is very detailed. Interested friends can refer to it for reference. I hope it can help you.

download a kernel

The first thing we do is download the kernel source code. Find the URL of the kernel you want to download at Kernel.org Once the URL is found, download the source file using the following command (I'll use the 4.17 RC2 kernel as an example):

wget https://git.kernel.org/torvalds/t/linux-4.17-rc2.tar.gz

Installation environment required

To compile the kernel, we first have to install some of the required environments. This can be done with a single command.

sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison

It is important to note that you will need at least 128GB of locally available disk space to complete the kernel compilation process. So you have to make sure you have enough space.

Extract source code

Under the folder where the newly downloaded kernel is located, use this command to extract the kernel:

tar xvzf linux-4.17-rc2.tar.gz

Use cd linux-4.17-rc2 to enter the newly generated folder.

configure the kernel

Before we can compile the kernel, we must first configure which modules we want to include. Actually, there are some very simple ways to configure it. With a single command, you can copy the current kernel configuration file and then use the trusty menuconfig command to make any necessary changes. Use the following command to do this:

cp /boot/config-$(uname -r) .config

Now that you have a profile, type the command make menuconfig. This command opens a configuration tool that lets you traverse each available module and enable or disable the ones you want or don't want.

Chances are you'll disable an important part of the kernel, so proceed carefully during menuconfig. If you are unsure about an option, leave it alone. Or better yet, use our copy of the currently running kernel configuration file (because we know it works). Once you've traversed the entire configuration list (which is very long), you're ready to start compiling.

compile and install

Now it's time to actually compile the kernel. The first step is to compile using the make command. Call the make command and answer the necessary questions. These questions depend on which existing kernel you will upgrade and which kernel you will upgrade.

After answering the lengthy questions, you can install the previously enabled modules with the following command:

make modules_install

This command will take some time.

Now we install the kernel using this command:

sudo make install

Again, another command that will take a considerable amount of time. In fact, the make install command will take more time than the make modules_install command.

Enable kernel as boot

Once the make install command is complete, it's time to start the kernel as a boot. Use this command to achieve:

sudo update-initramfs -c -k 4.17-rc2

Of course, you'll need to replace the kernel version numbers above with the ones you compiled. When the command is complete, update grub with the following command:

sudo update-grub

You can now restart the system and select the newly installed kernel.

The steps to download and configure the linux kernel are shared here. I hope the above content can help you and learn more. If you think the article is good, you can share it so that more people can see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report