Fedora 7 kernel compilation upgrade to 2.6.35.7 (latest kernel version)

Source: Internet
Author: User

Recently, I have been studying the Linux kernel. The kernel upgrade process is a learning process before I can carefully study the significance of the kernel, first of all, I have successfully compiled and upgraded from kernel 2.6.31.2 to 2.6.35.7 on Ubuntu. However, during compilation and upgrade on fedora, errors occur constantly. Even the same problem occurs many times, but it cannot be solved, here, I will sort out the detailed compilation process, summarize the problems I encountered, share them with you, and back up my own data.

This is my first time upgrading the kernel. It should be normal to have a problem, so I went to Google and Baidu online and finally felt that this article was not bad, my general idea is to follow this article, but there are some problems in the middle. I tried my best to solve them and hoped to help my colleagues who encountered the same problem. In this article, the Linux Fedora Core 8 kernel is upgraded to 2.6.25.14-69. The following describes the entire process of compiling and upgrading.

Step 1:

First, we need to prepare the required tools. The following four tools are required for compilation and upgrade. You can use rpm-Qa * for query. The system installed on the virtual machine has been installed:

Module-init-Tools
Mkinitrd
Lvm2
Device-mapper
Step 2:

Since the kernel is compiled and upgraded, a new version of the kernel is required. Download the latest kernel from the official website: http://www.kernel.org/. download the latest kernel version 2.6.35.7. To view your own version, you can run the uname-R command.
Step 3: process the kernel source code.

1. The core code of the kernel is stored in the/usr/src/directory. I am no exception. Put the downloaded latest kernel under the/usr/src/directory. The following is the processing process.

# 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.35.7.tar.bz2 (unzip new kernel)
# Ln-s linux-2.6.35.7 Linux (regenerate Linux folder)
The core code of the Linux system is stored in the directory/usr/src/Linux. In fact, this directory is a link pointing to the current core version directory, for example, if the current version is 2.4, the actual directory of the core should be:/usr/src/linux-2.4, And the directory in the newly downloaded kernel is Linux, so, unpacking directly under/usr/src will overwrite the original kernel directory. Therefore, it is safe to delete the link Linux first, then unpackage, rename, and re-link. Before unpacking, make sure that there is no Linux directory under the/usr/src directory, or you do not want to keep this directory.
2. Configure kernel options. It's a little tedious ,~~ Hope a success ~~. (This step is cumbersome and must be taken seriously)
# Cd linux-2.6.35.7 (to the/usr/src/linux-2.6.35.7 directory)
# Make mrproper (this command ensures that there is no incorrect. o file in the source code directory. Skip this command if it is the first compilation)
# 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
Jbd (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 encountered the third type of error after being restarted. I was so depressed that I had to re-install it ~~~ If you do not enter the 2.6.35.7 kernel after you restart the Linux system according to all the steps in this article, you will find that your error message is the above three types ~~~ 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

Note: 1. Kernel configuration

Linux currently supports the following CPU types: x86, arm, DEC Alpha, Sun iSCSI, m68000, MIPS, and PowerPC. The above types already include CPU models used by most users. During installation and configuration, Linux automatically identifies these models.

The first command to be run is: # cd/usr/src/Linux; Make mrproper. Make sure that there are no correct. O files and file dependencies in the source code directory.

The following Kernel configuration process is cumbersome, but the proper configuration is directly related to Linux running in the future. It is necessary to know some of the main and frequently used options.

2.6 kernel configurations include:

# Make config (text-based most traditional configuration interface)

# Make menuconfig (Text menu-based configuration interface)

# Make xconfig (graphical window mode-based configuration interface)

# Make oldconfig (if you only want to modify some small points based on the original Kernel configuration, it will be omitted)

# ALSA: {upgrade from version 2.4 to version 2.6. This requires ALSA (Advanced Linux sound architecture: New Linux audio architecture ). It replaces OSS (Open Sound System ). When configuring the kernel, select the oss api imitation options (snd_ossemul, snd_mixer_oss and snd_pcm_oss) and appropriate audio driver (pCI driver) for ALSA ). Finally, download and install the latest ALSA-lib and ALSA-utils .}

During configuration, the default values can be used for most options. Only a small part of options need to be selected based on the user's needs. For example, if you want the kernel to support a file system with DOS partitions, You need to select fat or dossystem for the file system. If the system is equipped with a NIC or PCMCIA card, select the type of the corresponding card in the network configuration.

When you select the corresponding configuration, there are three options, which represent the following meanings:

"Y"-compile this function into the kernel

"N"-do not compile this function into the kernel

"M"-compile this function into a module that can be dynamically inserted into the kernel as needed.

Compile some functional code that is far away from the other parts of the core and is not frequently used into a loadable module. This helps reduce the length of the kernel and reduce the memory consumed by the kernel, this feature simplifies the impact of environment change on the kernel. Many functions can be processed in this way, such as NIC support and file system support such as fat.

3. start compiling

In the/usr/src/linux-2.6.35.7 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/x86/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 generates a 2.6.35.7 subdirectory under the/lib/modules Directory, which stores all the loaded modules of the new kernel.
# Make install (new kernel installation)

The above command "make install" will: (1) copy the compressed kernel image to the/boot directory and create the corresponding system. map symbolic link; (2) modify the configuration file of bootloader; (3) Call the mkinitrd program to create the initrd image of the kernel. for grub. add the following similar configuration lines to the conf configuration file:

Title fedora (2.6.35.7)
Root (hd0, 1)
Kernel/boot/vmlinuz-2.6.35.7 Ro root =/dev/volgroup00/logvo00 rhgb quiet

Initrd/boot/initrd-2.6.35.7.img

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.35.7/Drivers/SCSI/buslogic. O/lib/modules/2.6.35.7/kernel/Drivers/SCSI
But don't forget, run make install after the copy.
Note: After the kernel is configured, the dependency and integrity of the kernel source code file need to be checked and compiled. At this time, ensure that the GCC version used by the System is above the gcc-2.95.3:

# Make clean (make sure all related files are in the latest version)

# Make zimage (compile the compressed kernel)

When the kernel supports many peripherals and functions, the kernel may become very large. In this case, you can compile the large kernel:

# Make bzimage

If you select a loadable module, compile the selected module after compiling the kernel:

# Make Module)

# Make module-install (transfer the compiled module to the standard system location)

The standard directory of the module in the system is located in/lib/modules/X. y. z, followed by X. y. Z is the version number. For security reasons, it is best to back up/lib/modules before running # Make modules-install. A module is usually a file with the. O Extension. Use the command # lsmod to list the modules in the current kernel.
4Start new kernel
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.35.7/ARCH/x86/boot/bzimage/boot/vmlinuz-2.6.35.7
# Cp/usr/src/linux-2.6.35.7/system. MAP/boot/system. Map-2.6.35.7
# Cd/boot (enter the boot directory)
# Rm-RF system. Map (delete the original connection)
# Ln-S system. Map-2.6.35.7 system. Map (reconnect)

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.35.7 (at this time, a initrd-2.4.18.img will be generated under your/boot, and your grub. conf file has been changed accordingly)

Restart and check the upgraded 2.6 kernel!

I did not think of a problem, but I am very sorry: There was a headache During the restart, and I stayed at the following position.

Google and Baidu have made great efforts to find a solution on the http://patchwork.kernel.org/patch/37444/webpage.

The problem lies in the option config_sysfs_deprecated_v2.

The solution is as follows:
Edit the. config file in the kernel source code package.
Config_sysfs_deprecated_v2 = y # this option is not set by default and is commented out.
Do not forget to re-compile the kernel.

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

I hope everyone can succeed!

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.