Article title: compile the kernel. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Author: meichaol
The following installation process is tested on the RedHat Linux 6.1 Server. the installation process uses the root user, the new kernel version at that time.
For 2.2.13, the latest stable version is now 2.2.15 (please go to the http://www.kernel.org to query the latest kernel version information ).
(I have tested the following compilation and installation steps on HP LC3 PII 300 .)
1. create an emergency boot disk
Check the/etc/lilo. conf file to determine which kernel image file you are using to start it. For example:
[Root @ deep] # cat/etc/lilo. conf
Boot =/dev/sda
Map =/boot/map
Install =/boot. B
Prompt
Timeout = 50
Image =/boot/vmlinuz-2.2.12-20
Label = linux
Root =/dev/sda6
Initrd =/boot/initrd-2.2.12-20.img
Read-only
The above example shows that the system is started using the/boot/vmlinuz-2.2.12-20 kernel image file. Now, use root to log on, and then
Put a 1.44 M floppy disk.
[Root @ deep] # mkbootdisk -- device/dev/fd0 2.2.12-20
Insert a disk in/dev/fd0.any information on the disk will be lost.
Press to continue or ^ C to abort:
Use the above command to create a portable floppy disk. you can use this floppy disk to recover it when an error occurs during Kernel upgrade.
We recommend that you use this floppy disk to restart the machine to ensure normal use.
II. kernel optimization
Decompress the following .tar.gz file
Go to the/usr/src/Directory
[Root @ deep] # cp linux-version.tar.gz/usr/src/
[Root @ deep] # rm-rf linux
[Root @ deep] # rpm-e -- nodeps kernel-headers kernel
[Root @ deep] # rm-rf/usr/src/linux-2.2.12/
[Root @ deep] # rm-rf/lib/modules/2.2.12-20/
[Root @ deep] # tar xzpf linux.version.tar.gz
[Root @ deep] # chown-R 0.0/usr/src/linux/
[Root @ deep] # rm-f linux-version.tar.gz
Increase the number of tasks
To increase the number of tasks allowed by the system, edit the header file/usr/src/linux/include/linux/tasks. h and
Modify the parameters.
[Root @ deep] # vi/usr/src/linux/include/linux/tasks. h
Change the NR_TASKS value from 512 to 3072.
Change MIN_TASKS_LEFT_FOR_ROOT from 4 to 24.
Use vi/usr/src/linux/Makefile to edit the Makefile file and modify the following code lines:
Set
CFLAGS =-Wall-Wstrict-prototypes-O2-fomit-frame-pointer
Change
CFLAGS =-Wall-Wstrict-prototypes-O6-mcpu = pentiumpro-march = pentiumpro
-Fomit-frame-pointer-fno-limits tions
III. Compilation
Are you sure the connections between the/usr/include/asm,/usr/include/linux, and/usr/include/scsi symbols are correct?
Local connection to the relevant location of the kernel source code.
You can use the following command:
[Root @ deep] # cd/usr/include
[Root @ deep] # rm-rf asm linux scsi
[Root @ deep] # ln-s/usr/src/linux/include/asm-i386 asm
[Root @ deep] # ln-s/usr/src/linux/include/linux
[Root @ deep] # ln-s/usr/src/linux/include/scsi
Use the following command to understand the residual. o files and unnecessary associations during kernel compilation:
[Root @ deep] # cd/usr/src/linux/
[Root @ deep] # make mrproper
After installing the source code, you can now configure the kernel.
[Root @ deep] # cd/usr/src/linux/
[Root @ deep] # make config
Three kernel configuration methods are available:
The first method is the make config command, which provides a character-based interface for various kernel configurations. The system will prompt
Your various kernel configuration options.
The second method is the make menuconfig command, which provides an easy-to-use menu interface for kernel configuration.
The third method is the smart make xconfig command, which provides a graphical interface for kernel configuration.
After the configuration is complete, save the options, return to the/usr/src/linux/directory, and then use the following command to compile the kernel.
[Root @ deep] # make dep; make clean; make bzImage
The compilation time varies from 10 minutes to more than an hour based on your machine configuration. please wait patiently :-)
After compilation, you can install the compiled and compressed kernel image files. If the option of the loadable module is selected during kernel configuration
(CONFIG_MODULES), you also need to use the following command to compile the corresponding module.
[Root @ deep] # make modules
[Root @ deep] # make modules_install
Then copy the kernel image file/usr/src/linux/arch/i386/boot/bzImage to/boot and give it a proper name:
[Root @ deep] # cp/usr/src/linux/arch/i386/boot/bzImage/boot/vmlinuz-kernel.version.number
Copy/usr/src/linux/System. map to/boot and give it a proper name:
[Root @ deep] # cp/usr/src/linux/System. map/boot/System. map-kernel.version.number
Then run the cd command to go to the/boot directory and re-establish the connection between vmlinuz and System. map:
[Root @ deep] # cd/boot
[Root @ deep] # ln-fs vmlinuz-kernel.version.number vmlinuz
[Root @ deep] # ln-fs System. map-kernel.version.number System. map
Delete unnecessary files:
[Root @ deep] # rm-f module-info
[Root @ deep] # rm-f initrd-2.2.12-20.img (if you have a SCSI device)
Finally, edit the/etc/lilo. conf file to enable the system to use the new kernel at startup:
[Root @ deep] # vi/etc/lilo. conf
Boot =/dev/sda
Map =/boot/map
Install =/boot. B
Prompt
Timeout = 20
Restricted
Password = somepasswd
Image =/boot/vmlinuz-kernel.version.number # (here is the name of your kernel image file ).
Label = linux
Root =/dev/sda6
Read-only
(The above is just an example. it will be slightly different from your file)
Don't forget to update lilo in time after modifying/etc/lilo. conf:
[Root @ deep] #/sbin/lilo-v
Note: If you select NO when configuring Unix98 PTY support (CONFIG_UNIX98_PTYS), you need to modify
/Etc/fstab file, delete the following lines:
None/dev/pts devpts gid = 5, mode = 620 0 0
Edit/etc/conf. modules and delete unnecessary modules
[Root @ deep] # vi/etc/conf. modules
For example
Alias scsi_hostadapter model (if a SCSI driver exists ).
Alias eth0 Ethernet model card (Ethernet card ).
Alias parport_lowlevel parport-pc (parallel port ).
Pre_install pcmcia_core/etc/rc. d/init. d/pcmcia start (if it is a notebook ).
If these modules do not select or have been compiled into the kernel when configuring the new kernel, they should be deleted. After modification
You must run LILO again and restart the machine.
Recreate an emergency boot floppy disk
If everything is normal, congratulations! The Kernel upgrade is complete! In this case, you should re-create an emergency boot floppy disk.
Log on as root and insert a new floppy disk:
[Root @ deep] # mkbootdisk -- device/dev/fd0 2.2.13
Insert a disk in/dev/fd0.any information on the disk will be lost.
Press to continue or ^ C to abort:
Update/dec entry
If you have upgraded the kernel or added a new device, you should update the/dev entry.
Log on as a root user:
[Root @ deep] # cd/dev
[Root @ deep] #./MAKEDEV update
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service