How to Upgrade Linux Kernel

Source: Internet
Author: User
Upgrade Linux kernel-general Linux technology-Linux programming and kernel information. For more information, see the following. Starting yesterday, I wanted to upgrade the redhat9.0 kernel -- 2.14.20

I found a webpage. I wanted to upgrade it to 2.6.24, but it was not successful!

Later I drew a gourd and promoted it to 2.6.18. The image was as successful as the webpage!

But I still want to upgrade it to 2.6.24, but it doesn't work. I have time to do it again!

Paste the webpage for reference.

My environment is redhat9.0 under vmware

For those who cannot connect to the webpage, see the following:

I. Preparations
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. Start the Linux system and log on with the root user to enter the terminal mode.

1. Check the Linux kernel version # uname-
If 2.6.x is displayed on the screen, it indicates that your kernel is 2.6 and you don't have to look at 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.6 kernel source code
: Http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2

3. Download the kernel upgrade Tool
(1 download module-init-tools-3.2.tar.bz2
Http://www.kernel.org/pub/linux/... t-tools-3.2.tar.bz2
(2) download mkinitrd-4.1.18-2.i386.rpm
Http://ayo.freshrpms.net/fedora/... d-4.1.18-2.i386.rpm
(3) download lvm2-2.00.25-1.01.i386.rpm
Http://ayo.freshrpms.net/fedora/... 00.25-1.01.i386.rpm
(4) download device-mapper-1.00.19-2.i386.rpm
Http://ayo.freshrpms.net/fedora/...-1.00.19-2. i386.rpm

Ii. Configuration
Okay, the 2.6 kernel and four upgrade tools have been downloaded. (no more than one. If the download is not complete, please do not try the following steps. The upgrade will not succeed ), go back to the Linux system to start configuration.

4. Copy the downloaded kernel source code package 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, start to decompress the new 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 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 kernel)
# Ln-s linux-2.6.18 linux (regenerate linux folder)

6. Install module-init-tools
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 during kernel Compilation:
Mkinitrd failed
Make [1]: *** [install] Error 1
Make: *** [install] Error 2

8. Configure kernel 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 (Kernel configuration options)

In this case, a graphical interface is displayed, listing all Kernel 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 selected by default. The following options must be selected (check each of the following options carefully; otherwise, compilation may be discarded ):

(1) In the Loadable Module support option, select "Module unloading" and "Automatic kernel module loading;
(2) Device Drivers ---> select "Loopback device support" in Block Devices ";
Choose "Device mapper support" at device Drivers ---> Multi-device support (RAID and LVM ";
Device Drivers ---> Graphics support, be sure to select "Support for frame. buffer devices ";
Device Drivers ---> USB support ---> select "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 ";

Note:
Ext2 and ext3 file system configurations are important and necessary. If the Ext3 and Ext2 file support is directly compiled into the kernel, the machine will be taken away during reboot and the following error message will appear:

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 is the third type of error that occurs after the restart. If you cannot enter the system and are depressed, you have to reinstall it. If you follow all the steps described in this article, after you restart the Linux system, if you unfortunately cannot enter the 2.6.18 kernel, you will find that your error message is the above three types of errors ~~~ Ha !)

(4) If you compile the kernel in vmware and the hard disk uses scsi, the following three options are required:
Device Drivers ---> <*> SCSI device support (If this option is not selected, the following two options cannot be selected)
Device Drivers ---> <*> SCSI device support ---> <*> SCSI disk support
Device Drivers ---> <8> 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 file required for compilation. Note: skip this step if the kernel has never been compiled)
# Make clean (clear the target file compiled by the kernel. Note: skip this step if the kernel has never been compiled)
# Make bzImage (case sensitive. This step truly compiles the kernel)
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 to compile it. Therefore, I will use make bzImage to compile it directly.
# Make modules)
# Make modules_install (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 loaded modules of the new kernel.
# Make install (new kernel installation)

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 (even if the Buslogic module of the 2.4 kernel is statically compiled into the kernel ). The solution is to copy the BusLogic. o file directly:
# Cp/usr/src/linux-2.6.18/drivers/scsi/BusLogic. o/lib/modules/2.6.18/kernel/drivers/scsi
But don't forget, run make install after the copy. If this step gets stuck, none of the following operations can be performed.

4. Start a new kernel
10. Copy the new kernel and System. map files 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
# Cd/boot (enter the boot directory)
# 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 (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, a initrd-2.4.18.img will be generated under your/boot, and your grub. conf file has been 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:
Default = 1
Timeout = 10
Splashimage = (hd0, 0)/grub/splash.xpm.gz
Title Red Hat Linux (2.6.18)
Root (hd0, 0)
Kernel/vmlinuz-2.6.18 ro root = LABEL =/
Initrd/initrd-2.6.18.img

Make two changes:
(1) Change "default = 1" to "default = 0" (if you do not change it, you can also change it, but the system will enter the 2.4 kernel by default after restart)
(2) Replace "LABEL =/" of the kernel row with the partition of the root directory (as shown in the previous step)
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:
Default = 0
Timeout = 10
Splashimage = (hd0, 0)/grub/splash.xpm.gz
Title Red Hat Linux (2.6.18)
Root (hd0, 0)
Kernel/vmlinuz-2.6.18 ro root =/dev/hda2
Initrd/initrd-2.6.18.img
Title Red Hat Linux (2.4.20-8)
Root (hd0, 0)
Kernel/vmlinuz-2.4.20-8 ro root = LABEL =/
Initrd/initrd-2.4.20-8.img

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

According to the above content, the following problems occur after restart:

A cannot access the Internet

# Vi/etc/modules. config

Modify the first line as follows:

Alias eth0 pcnet32

Just reactivate the NIC.

Author: fjb0522

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.