Compile the Linux kernel-general Linux technology-Linux programming and kernel information. For more information, see the following. I. Backup important files
Back up the following files to quickly restore the original state of the system when a system error or crash occurs.
1. Back up the kernel and Startup File
# Cd/
# Tar cvzf boot.tar.gz boot
2. Back up system function header files
# Cd/usr/include
# Tar cvzf linux.tar.gz linux
3. database files in the backup module
# Cd/lib/modules
# Tar cvzf 2.4.7-10.tar.gz 2.4.7-10
# Tar cvzf 2.4.7-10debug.tar.gz 2.4.7-10 debug
4. Back up the linux source code
# Cd/usr/src
# Tar cvzf linux-2.4.7-10.tar.gz linux-2.4.7-10
# Tar cvzf linux-2.4.7-10debug.tar.gz linux-2.4.7-10debug
5. Backup important configuration directories
# Cd/
# Tar cvzf etc.tar.gz etc
Ii. Modify core parameters (required by PGC2000)
1. Modify core parameters related to shared memory
# Cd/usr/include/linux
# Vi shm. h
Set # define SHMMAX 0X2000000/* max shared seg size (bytes )*/
Change to # define SHMMAX 0Xa0000000/* max shared seg size (bytes )*/
2. Modify core parameters related to semaphores
# Cd/usr/include/linux
# Vi sem. h
Set # define SEMOPM 32/* <= 1 100 max num of ops per semop call */
Change to # define SEMOPM 900/* <= 1 100 max num of ops per semop call */
3. Modify the core parameters related to the Message Queue
# Cd/usr/include/linux
# Vi msg. h
Find the following three lines (ignore comments ):
# Define MSGMNI 16
# Define MSGMAX 8192
# Define MSGMNB 16384
Modify it:
# Define MSGMNI 128
# Define MSGMAX 131072
# Define MSGMNB 20000000
4. Modify the shm. h, sem. h and msg. h files in/usr/src/linux-2.4.7-10/include/linux as follows.
3. Download and release the core source code
This step can be omitted if you only need to modify and compile the kernel. This step is required when we download a new internal file (such as linux-2.4.7-12.tar.gz) from the internetsite.
1. Run the tar command to release the kernel source code.
# Cd/usr/src
# Tar zxvf linux-2.4.7-12.tar.gz
After the file is released successfully, a linux subdirectory is generated under the/usr/src directory. The source code is included.
2. Link/usr/include/asm,/usr/inlude/linux,/usr/include/scsi to the corresponding directory under/usr/src/linux/include.
# Cd/usr/include
# Rm-Rf asm linux
# Ln-s/usr/src/linux/include/asm-i386 asm
# Ln-s/usr/src/linux/include/linux
# Ln-s/usr/src/linux/include/scsi
4. Configure the kernel
1. Delete the. o files and other subordinate files left in the source code directory.
# Linux-2.4/cd/usr/src/
# Make mrproper
2. Start the Kernel configuration program
# Linux-2.4/cd/usr/src/
# Make xconfig
3. Configure the kernel
The Linux Kernel configuration program provides a series of configuration options. For each configuration option, you can answer "y", "m", or "n ". "Y" indicates that the corresponding feature support or device driver is compiled into the kernel; "m" indicates that the corresponding feature support or device driver is compiled into a loadable module, the system or user can add it to the kernel. "n" indicates that the kernel does not provide support for corresponding features or drivers. Improper configuration may cause kernel compilation failure.
5. Compile the kernel
1. Create the dependent files required for compilation
# Linux-2.4/cd/usr/src/
# Make dep
2. Clear the target file compiled by the kernel
# Make clean
3. Compile the kernel
# Make bzImage (case sensitive)
After the kernel is compiled, an image file bzImage of the new kernel is generated in the/usr/src/linux/arch/i386/boot directory. If you use make zImage to compile a large kernel, the system will prompt you to use the make bzImage command for compiling.
6. Compile and load modules
If you have set the loadable modules When configuring the kernel, You need to compile these modules so that you can use the insmod command to load them in the future.
# Make modules
# Make modules_install
After compilation is successful, the system generates a 2.4.7-10custom subdirectory under the/lib/modules Directory, which stores all the loaded modules of the new kernel.
7. Start the new kernel
1. Copy the new kernel and System. map files to the/boot directory.
# Cp/usr/src/linux-2.4/arch/i386/boot/bzImage/boot/vmlinuz-2.4.7-10custom
# Cp/usr/src/linux-2.4/System. map/boot/System. map-2.4.7-10custom
# Cd/boot
# Rm-f System. map (delete the original connection)
# Ln-s System. map-2.4.7-10custom System. map (reconnect)
2. Configure the/etc/lilo. conf file and add the following lines to the file:
Image =/boot/vmlinuz-2.4.7-10custom
Label = linux-custom
Initrd =/boot/initrd-2.4.7-10.img
Read-only
Root =/dev/hda3 (refer to the existing configuration in the lilo. conf file)
Change default = linux to default = linux-custom.
3. Make the new configuration take effect
#/Sbin/lilo
4. restart the system
#/Sbin/reboot
If the new kernel cannot be started normally, start the old kernel at the LILO: prompt. Find out the cause of the fault and re-compile the new kernel.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.