Customizing the Linux Kernel

  

After experiencing a curious and familiar process with Linux, do many Linux users want to customize Linux to the actual configuration of their machine to get the best system performance? Maybe some users will think that they haven't encountered any problems in their own use of Linux. Linux does “never crash” as people advertise, so there is no need to risk changes to the system kernel. In fact, customization and modification of the Linux kernel is not as complicated as many people think. If the user can make reasonable modifications to the Linux kernel according to their actual situation, it can effectively simplify the Linux kernel and remove unnecessary components, thus providing faster system startup speed and releasing more memory resources. Below we will give a brief introduction to the Linux kernel. The so-called system kernel is actually the components of the control system written by the system designer, the system resources are allocated between different programs, and the system core program code of the data transfer between the system and the hardware and peripherals is coordinated. Unlike the kernel of the Windows system, the kernel of the Linux system is configurable, and the user can customize the system kernel according to his actual needs. For example, users can optimize the system core for the specific model of their machine's CPU. Although different vendors have set up the system kernel for specific hardware devices or network protocols before launching their respective Linux products, users can further modify the Linux system kernel for the machine they are actually using. , thereby taking the performance of the Linux system to a new level. This article will focus on the customization of the system kernel in combination with the current and more mature version of Red Hat Linux. Users of Linux products from other vendors can also customize the Linux kernel by referring to the introduction in this article. Preparations Although most of the operations of recompiling the Linux kernel are automated and not complicated, once an error occurs, the Linux system may not boot properly. Therefore, in order to prevent any problems that may arise in advance, the user must make a Linux system boot disk before making any changes to the Linux kernel (Note: Users may have been asked to make the system during the Linux installation process. Boot disk, if the user does not have a ready-made system boot disk, you can re-create a new one according to the instructions in this article), and should also back up some important data in a timely manner. Below, we will look at how to implement the customization of the Linux system kernel. The user needs to log in to the Linux system as the administrator root account. Because all the commands in this article are implemented by commands, users should choose to log in as a command. If the Linux system on the user's machine is logged in to the graphical mode by default, you can use the terminal command window in the graphical environment (click the button displayed in the computer graphic on the GNOME desktop task bar). Making a boot disk Generally, during the installation process of a Linux system, the installer will ask the user to make a Linux system boot disk, so that when the Linux system has a serious error and cannot be started normally, the user can restart the Linux system using the boot disk. If the user does not have any ready-made boot disk, they can do it themselves as described below. Suppose the user is using a Linux product from 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, the configuration file of Linux Loader (LILO). The user finds the following entry in the file <;image=/boot/vmlinuz-2.2.12-20”. The path indicated by this entry is the location of the kernel of the Linux system that is first loaded by the user each time the Linux system is booted. The number after the “vmlinuz-” item represents the version of the Linux kernel currently used by the user. The actual display value may vary depending on the user. After writing down the number, enter “q” to return to the command mode. Then the user enters the “mkbootdisk --verbose --device /dev/fd0 2.212-20 ” command, where the Linux kernel version number is based on the actual version number of the user. After the carriage return, Linux will ask the user to insert a floppy disk and then automatically create a system boot disk for us. Setting up the system kernel Now, we are starting to customize the Linux system kernel. First, the user enters the command “cd /usr/src/linux ” to convert the current working directory to /usr/src/linux. The Linux system provides users with two system kernel setting interfaces, menuconfig and xconfig. Among them, the user can start menuconfig by entering the command “make menuconfig” in any command mode, and then use the arrow keys and the Tab key to select and modify. For xconfig, the user can only start under X Windows with the command “make xconfig”. Xconfig provides a more user-friendly interface that allows users to select menus and buttons with a single mouse click. This article will focus on the use of xconfig, users can achieve the same functionality by using menuconfig. The user enters the command “make xconfig” press Enter, after a series of texts are displayed, the main window of xconfig will pop up. This window contains a number of button options. Clicking on any of them will bring up a settings window for making specific settings for the Linux kernel. For example, after the user clicks on the second item in the xconfig window, "Processor type and features", the user's own machine processor can be set in the corresponding pop-up window. In each settings window, the user can turn any feature on or off by selecting the “Y” or “N” option. In addition, users can also select the “M” option to edit certain functions as modules. The so-called module is not a component of the system kernel, but the system kernel will connect to the specified module to provide specific functions when needed. By default, many of the features in the settings window are edited as different modules. If the user does not know the setting of a specific function during the specific setting process, you can click the help button of the function option to start the corresponding help text. The help text provides a detailed description of all the functional options. If the user finds that he or she may have chosen the wrong option and wants to restore the previous settings, he or she can choose to return directly to the main window without saving any changes. After the user has completed all the settings that need to be changed, he can click on the xconfig main window “Save and Exit“ to save the user settings and exit xconfig. Editing the system kernel After the user completes the setting of the system kernel according to the actual needs of the individual, the new system kernel needs to be compiled. After the user closes all open programs, enter the “make bzImage” command in command mode. This command will automatically complete the editing of the new system kernel, which takes about 10 to 30 minutes, depending on the performance of the user's machine. After compiling the system kernel, return to the command mode. At this time, if an error message appears, it means that the user has made a wrong setting for the system kernel, such as other additional functions that are not necessary to start a certain function. At this time, all the user can do is to set the system kernel from scratch. After successfully compiling the new system kernel, the user also needs to compile and install various functional modules set in the process of configuring the system kernel. Specifically: Enter the "make modules” command and press Enter. This command will complete the compilation of the kernel module. Once the compilation is complete, enter the “make modules_install” command, which will automatically install the compiled module. Finishing work After completing the compilation of the new system kernel and modules, we need to copy the new system kernel to the Linux boot directory. Users can enter the following command & ldquo;cp arch/i386/boot/bzImage /boot/vmlinuz-mykernel”. In addition, we need to modify the LILO accordingly so that LILO can find a new system kernel when the system starts. We can modify the LILO configuration file using any of the text editing tools under Linux. Here we use the pico text editor. Enter the &picquo;pico /etc/lilo.conf” command to launch the pico editor and load the LILO configuration file. Find the <quo;image=“ item and replace the existing value of the item with “/boot/vmlinuz-mykernel”. It is recommended that the user write down the current value of the <;image=“ item so that if there are any problems, it is easy to revert to the security settings. Once you have made your changes, press Ctrl-X, select “Y” then press Enter to save your settings and exit the pico editor. In this way, we have completed all the work of customizing the Linux system kernel. After rebooting the machine and re-entering the Linux system, users will experience the new experience brought by the new system kernel.

Copyright © Windows knowledge All Rights Reserved