After many Linux users have gone through the process of getting familiar with Linux, do they want to customize Linux according to the actual configuration of their machines to achieve the best system performance? Also
After many Linux users have gone through the process of getting familiar with Linux, do they want to customize Linux according to the actual configuration of their machines to achieve the best system performance? Some users may think that they haven't encountered any problems while using Linux. Linux is indeed "never crashed" as people have advertised ", therefore, there is no need to take the risk of modifying the system kernel. In fact, the customization and modification of Linux kernel is not as complicated as many people think. If you can modify the Linux kernel according to your actual situation, you can effectively simplify the Linux kernel and remove unnecessary components to provide faster system startup speed, release more memory resources.
Next we will give a brief introduction to the Linux kernel.
The so-called system kernel is actually the system core program code written by the system designer to control various components of the system, allocate system resources among different programs, and coordinate the data transfer between the system and hardware and peripherals. Different from the Windows kernel, the Linux kernel is configurable. you can customize the system kernel based on your actual needs. For example, you can optimize the system kernel based on the CPU model of your machine.
Although different vendors have set the system kernel for specific hardware devices or network protocols before launching their own Linux products, however, you can make further modifications to the Linux kernel for the machines you actually use, so as to improve the performance of the Linux system to a new level. This article will introduce in detail the customization of the system kernel in combination with the popular and mature Red Hat Linux version. Users of Linux products launched by other vendors can refer to the introduction in this article to customize the Linux kernel.
Preparations
Although most of the operations to re-compile the Linux kernel can be completed automatically and not complex, once an error occurs, the Linux system may fail to start properly. Therefore, to prevent any problems that may occur in advance, you must make a boot disk for the Linux system before making any changes to the Linux system kernel (note: you may have been asked to create a system boot disk when installing the Linux system. if you do not have a ready-made system boot disk, follow the instructions in this article to create a new one ), at the same time, important data should be backed up in a timely manner. Next, let's take a look at how to customize the Linux kernel.
You must log on to the Linux system as the administrator root account. Because all the commands in this article are implemented through the command method, you 'd better choose to log on using the command method. If the Linux system on your machine is logged on to the graphical mode by default, you can use the terminal command window in the graphical environment (click the button displayed in the computer pattern in the GNOME desktop task bar ).
Create a boot disk
Generally, during the installation of the Linux system, the installer requires you to create a boot disk for the Linux system. In this way, when the Linux system fails to be started due to a serious error, you can use the boot disk to restart the Linux system. If you do not have any ready-made boot disks, you can create them by yourself as described below.
If you are using a Linux product launched by Red Hat, first enter the "more/etc/lilo. conf" command in the command mode or command terminal window, and then press Enter. This command will display the Linux Loader configuration file (LILO for short) in a split screen. The user found the following entry in the File: image =/boot/vmlinuz-2.2.12-20 ". The path pointed out by this item is the location of the Linux kernel that the user first loads when starting the Linux system. The number after "vmlinuz-" indicates the version of the Linux kernel currently used by the user. the actual display value may vary depending on the user's actual situation. Enter "q" and return to the command mode.
Then, the user enters the "mkbootdisk-verbose-device/dev/fd0 2.212-20" command. the Linux system kernel version number prevails. After you press enter, Linux requires you to insert a floppy disk and then automatically create a system boot disk for us. Set system kernel
Now, we start to customize the Linux kernel. First, enter the command "cd/usr/src/linux" to convert the current working directory to/usr/src/linux.
Linux provides users with two system kernel setting interfaces: menuconfig and xconfig. You can run the "make menuconfig" command to start menuconfig in any command mode, and then select and modify it using the direction key and Tab key. For xconfig, you can only start it in Windows by running the "make xconfig" command. Xconfig provides a more user-friendly interface. you can click and select various menus and buttons. This article describes how to use xconfig. you can use menuconfig to implement the same functions.
Run the "make xconfig" command and press Enter. after a series of text is quickly displayed, the main window of xconfig is displayed. This window contains many button options. Clicking any of them will pop up the setting window for Linux kernel settings. For example, after you click "Processor type and features" in the xconfig window, you can set the Processor of your machine in the corresponding pop-up window.
In each setting window, you can enable or disable any function by selecting "Y" or "N. In addition, you can select the "M" option to edit some functions as modules. The so-called module is not a component of the system kernel. However, when necessary, the system kernel connects to the specified module to provide specific functions. By default, many functions in the setting window are edited as different modules.
If you do not know how to set a specific function during the specific setting process, you can click the help button of this function option to start the corresponding help text. The help text provides detailed descriptions of all functional options. If you find that you may have selected an incorrect option and want to restore the previous settings, you can directly return to the main window without saving any changes. After completing all the settings that need to be modified, you can click "Save and Exit" in the xconfig main window to Save the user settings and Exit xconfig.
Edit system kernel
After setting the system kernel according to your actual needs, you need to compile the new system kernel.
After you close all open programs, run the "make bzImage" command in command mode. This command automatically edits the kernel of the new system, which takes about 10 to 30 minutes, depending on the performance of your machine.
After compiling the system kernel, return to the command method. If an error message is displayed, the system kernel is incorrectly set, for example, other additional functions required to not start a function. In this case, you can only set the system kernel from the beginning.
After successfully compiling the new system kernel, you also need to compile and install various functional modules set during system kernel configuration. Specifically, enter the "make modules" command and press enter. This command will compile the kernel module. After compilation, enter the "make modules_install" command, which will automatically install the compiled module.
Finishing work
After compiling the new system kernel and module, we need to copy the new system kernel to the Linux startup directory. You can run the following command: "cp arch/i386/boot/bzImage/boot/vmlinuz-mykernel ". In addition, we also need to modify LILO so that LILO can find a new system kernel at system startup. We can use any text editing tool in Linux to modify the LILO configuration file. Here we use the pico text editor. Run the "pico/etc/lilo. conf" command to start the pico editor and load the LILO configuration file. Find the "image =" item and replace the existing value with "/boot/vmlinuz-mykernel. We recommend that you write down the current value of "image =" so that you can easily restore the security settings if any problem occurs. After the modification, press Ctrl-X, select "Y", and press enter to save the settings and exit the pico editor. In this way, we have completed all the work of customizing the Linux kernel. After restarting the machine and entering the Linux system again, the user will feel the new experience brought by the new system kernel.