Linux Kernel configuration Compilation

Source: Internet
Author: User
Tags file copy

It is particularly worth mentioning that there are many things worth learning about in the Linux kernel system. Here we will mainly introduce the Linux kernel system, including the Linux kernel system. The Linux kernel is successfully upgraded from kernel 2.4.20-8 to kernel 2.6.18.

Although there are many articles on the Internet about Linux kernel upgrade, the download link is either outdated or unclear, and the cloud is connected; what's more, many articles have errors in the command line during reprinting. At the beginning, I upgraded these strategies, which wasted a lot of time.

The upgrade was successful and in a good mood. You can also write an "Upgrade Strategy" for your advantage! Therefore, it is not a memoir to specifically reinstall a Linux kernel system on a virtual machine, and then perform a perfect upgrade by recording these steps and writing a Linux kernel upgrade record !), Share with you ~~!

First, the line with the # sign below is the command line to be entered, and all the command lines mentioned in this article are entered in the terminal. Next, let's start a wonderful Linux kernel upgrade journey!

I. Preparations

Start the Linux kernel and log on with the root user to enter the terminal mode.

1. view the Linux kernel version

# Uname-a if 2.6.x is displayed on the screen, it indicates that your kernel is 2.6 and you do not need to read the following. What should you do !~~~ If 2.4.x is displayed, congratulations, go through it and proceed to the next step.

2. Download The 2.6Linux kernel system source code

: Http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2

3. Download the Linux kernel system upgrade Tool
(1 download module-init-tools-3.2.tar.bz2
Http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-3.2.tar.bz2
(2) download mkinitrd-4.1.18-2.i386.rpm
Http://ayo.freshrpms.net/fedora/linux/3/i386/RPMS.core/mkinitrd-4.1.18-2.i386.rpm
(3) download lvm2-2.00.25-1.01.i386.rpm
Http://ayo.freshrpms.net/fedora/linux/3/i386/RPMS.core/lvm2-2.00.25-1.01.i386.rpm
(4) download device-mapper-1.00.19-2.i386.rpm
Http://ayo.freshrpms.net/fedora/linux/3/i386/RPMS.core/device-mapper-1.00.19-2.i386.rpm
(2.6.18 kernel and the four upgrade tools I have backup, if the above is invalid, please leave your mailbox in http://www.fly2.cn/guestbook, I will send you)

Ii. Linux Kernel System Configuration

All right, the 2.6Linux kernel system and four upgrade tools have been downloaded. (No download is complete. If not, please do not try the following steps. The upgrade will not succeed ), next, go back to the Linux kernel to start configuration.

4. Copy the downloaded kernel and four upgrade tools to the/usr/src folder. I don't need to teach you how to copy it ~~~~ It won't be copied to hit the wall !~~ Haha!

5. After the copy is completed, decompress the new Linux kernel. Execute the following commands in sequence:
# Cd/usr/src (go to the/usr/src directory. If it is already in the/usr/src directory, do not execute this command)
# Rm-rf linux (delete the linux folder. It is worth mentioning that if the Linux kernel has never been compiled before, there is no such folder, and this command line can be skipped)
# Tar jvxf linux-2.6.18.tar.bz2 (unzip new Linux kernel)
# Ln-s linux-2.6.18 linux (regenerate linux folder)

6. Install the module-init-tools toolkit.
In the/usr/src directory, execute the following commands in sequence:
# Tar jvxf module-init-tools-3.2.tar.bz2 (extract module-init-tools)
# Cd module-init-tools-3.2 (by the/usr/src directory to enter the module-init-tools directory)
#./Configure -- prefix =/
# Make moveold
# Make all install
#./Generate-modprobe.conf/etc/modprobe. conf

7. install three other upgrade tools
Go back to the/usr/src directory and execute the following three commands to install the other three upgrade tools:
# Rpm-ivh -- nodeps mkinitrd-4.1.18-2.i386.rpm (note that -- nodeps parameters must be added here, the same below)
# Rpm-ivh -- nodeps lvm2-2.00.25-1.01.i386.rpm.
# Rpm-ivh -- nodeps device-mapper-1.00.19-2.i386.rpm.
If you do not update the above upgrade packages, the following error will be prompted when you compile the Linux kernel later:
Mkinitrd failed
Make [1]: *** [install] Error 1
Make: *** [install] Error 2

8. Configure Linux kernel system options. It's a little tedious ,~~ Hope a success ~~.
# Cd linux-2.6.18 (to the/usr/src/linux-2.6.18 directory)
# Make mrproper (this command ensures that there is no incorrect. o file in the source code directory)
# Make menuconfig configure kernel options)

In this case, a graphical interface is displayed, listing all Linux kernel system configuration options. Some options also have sub-options. You can select them using the arrow keys and use the Y key to confirm them. After many tests, most of the options are supported by default. check each of the following options carefully. Otherwise, compilation may be discarded ):
(1) In the Loadable Module support option, you must select "Module unloading" and "Automatic kernel module loading;
(2) The Loopback Device support must be selected in device Drivers ---> Block Devices;
Choose Device Drivers ---> Multi-device support (RAID and LVM) to choose device mapper support ";
Device Drivers ---> Graphics support ", be sure to select" Support for frame buffer devices ";
Device Drivers --->; USB support ---> choose "USB Mass Storage support". If you want more USB support in the real environment, select all. I am in a virtual machine. I don't need it anymore)
Device Drivers --->; Network device support --->; Ethernet (10 or 100 Mbit) --- >;< *>; AMD PCnet32 PCI support

(3) File system ---> the following nine options are selected for the ext2 and ext3 File system configurations)
Second extended fs support
Ext2 extended attributes
Ext2 POSIX Access Control Lists
Ext2 Security Labels
Ext3 journalling file system support
Ext3 extended attributes
Ext3 POSIX Access Control Lists
Ext3 Security Labels
JBB (ext3) debugging support
File system ---> DOS/FAT/NT Filesystems ---> select "NTFS file system support ";
File Systems --> Miscellaneous filesystems ---> <*> Compressed ROM file system support (cramfs)

Note:
Ext2 and ext3 file Linux kernel configurations are very important and necessary. If the Ext3 and Ext2 file support is directly compiled into the kernel, the machine will be taken away during reboot, the following error message is displayed: kernel panic: no init found, try passing init = option to kernel .....

Or:
VFS: Cannot open root device "hdxy" or unknow-block (0, 0)
Please append a correct "root =" boot option
Kernel panic: VFS: Unable to mount root fs on unknown-block (0, 0)

Or:
Mount: error 19 mounting ext3
Fail troot: effect_root (/sysroot,/sysroot/initrd) failed: 2
Umount/initrd/proc fail: 2
Freeing unused kernel memory: 244 k freed
Kernel panic-not syncing: No init found. Try passing init = option to kernel
My machine encountered the third type of error after being restarted. I had to reinstall it because I couldn't get into the system and got depressed ~~~)

4) if you re-compile the Linux kernel system under vmware and the hard disk uses scsi, the following options are required:
Device Drivers ---> SCSI device support ---> <*> SCSI disk support
Device Drivers ---> SCSI device support ---> SCSI low-level drivers --- >;< *>; BusLogic SCSI support

Iii. Compilation

OK. The complicated configuration work has been completed. At this point, all preparations before compilation have been completed!

9. start compiling ...... :
In the/usr/src/linux-2.6.18 directory, execute the following command to compile. It takes some time to compile the program. Please wait for a cup of tea!
# Make dep: Create the dependent files required for compilation. Note: skip this step if the kernel has never been compiled)
# Make clean: clears the target file compiled by the kernel)
# Make bzImage case sensitive. This step is used to compile the kernel)

After the linux 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 to compile it. Therefore, I will use make bzImage to compile it directly.
# Make modules compile and load modules)
# Make modules_install install the installable module)

After the installation is successful, the system will generate a 2.6.18 subdirectory under the/lib/modules Directory, which stores all the modules that can be loaded in the new Linux kernel system.
# Make install new kernel)
Note: The following error message may appear during make install:
No module BusLogic found for kernel 2.4.12
Mkinitrd failed

This problem occurs only in the SCSI hard drive + VMWARE + REDHAT architecture, because BusLogic is compiled into the kernel rather than a module, the Buslogic module of the 2.4 kernel does not work even if it is statically compiled into the kernel ). The solution is to directly use BusLogic. o file copy past: # cp/usr/src/linux-2.6.18/drivers/scsi/BusLogic. o/lib/modules/2.6.18/kernel/drivers/scsi. Do not forget to copy the file and run make install. If you select the BusLogic Module to M-Module mode during make menuconfig, this prompt will not appear .)

4. Start the new Linux Kernel System

10. Copy the new Linux kernel System and System. map file to the/boot directory and execute the following commands in sequence:
# Cp/usr/src/linux-2.6.18/arch/i386/boot/bzImage/boot/vmlinuz-2.6.18
# Cp/usr/src/linux-2.6.18/System. map/boot/System. map-2.6.18
# Enter the boot directory for cd/boot)
# Rm-rf System. map (delete the original connection)
# Ln-s System. map-2.6.18 System. map (reconnect)

11. Modify the Grub startup Manager

If there is no error, modify the grub configuration file and do not tell me the lilo you are using.) In the/boot directory, run the following command:
# New-kernel-pkg -- mkinitrd -- depmod -- install 2.6.18 at this time your/boot will generate a initrd-2.4.12.img and your grub. conf will be changed accordingly)
# Df: Check the partition where the root directory is located and use it in the next step. Note that the root partition is the 50 m partition of boot from time to time, which is generally your largest partition, that is, "/". Do not make a mistake. My name is/dev/hda2)
# Vi/grub. conf

Go to the grub. conf file and find the following information:

 
 
  1. default=1   
  2. timeout=10   
  3. splashimage=(hd0,0)/grub/splash.xpm.gz   
  4. title Red Hat Linux (2.6.18)   
  5. root (hd0,0)   
  6. kernel /vmlinuz-2.6.18 ro root= LABEL=/   
  7. initrd /initrd-2.6.18.img  

Make two changes:
1) Change "default = 1" to "default = 0" without modification. After restart, the system will enter the 2.4 kernel by default)
2) Replace "LABEL =/" of the kernel row with the partition where the root directory is located)

This step is very important. The modification error may cause the system to be inaccessible. I will list the modified grub. conf file. If it is not clear, you can modify it as follows:

 
 
  1. default=0   
  2. timeout=10   
  3. splashimage=(hd0,0)/grub/splash.xpm.gz   
  4. title Red Hat Linux (2.6.18)   
  5. root (hd0,0)   
  6. kernel /vmlinuz-2.6.18 ro root=/dev/hda2   
  7. initrd /initrd-2.6.18.img   
  8. title Red Hat Linux (2.4.20-8)   
  9. root (hd0,0)   
  10. kernel /vmlinuz-2.4.20-8 ro root=LABEL=/   
  11. initrd /initrd-2.4.20-8.img  


12, OK, all done! Restart the system and check the upgraded 2.6Linux kernel!

  1. Linux Kernel compilation and installation of RTAI
  2. Brief Introduction to Linux kernel system applications
  3. The Linux kernel version has become the first reason for my criticism.
  4. Run the Linux kernel and start Fedora.
  5. Linux Kernel compilation and installation of RTAI

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.