The entire process of compiling the kernel (kernel2.6.13) in the VMware5.0 Environment

Source: Internet
Author: User
The entire process of kernel compilation (kernel2.6.13) in the VMware5.0 environment-Linux general technology-Linux programming and kernel information. The following is a detailed description. As the saying goes: "hard work, hard work." It can be realized only by compiling the Linux kernel. I have also failed many times and gave up compiling for a while. finally, through continuous practice and online collection of this information, the compilation was successful not long ago. I sorted out the information I collected on the Internet and the compilation process, and shared it with you. I hope I can help my colleagues who need it, so that we can avoid detours.
Back to the truth:
Environment: VMware5.0 for windows (in the new Virtual Machine wizard, select IDE for "Virtual Machine disk type)
Kernel version: kernel2.6.16 (the original kernel adopts the character mode, excluding the xwindow Mode)
The original system is redhat9.0, kernel 2.4.20-8, and compiled Kernel 2.6.13, which is for reference only.
There are four parts in total: preparation before compilation->; Compilation configuration->; compilation process->; FAQs about running the kernel
Preparations before Compilation
1. download a copy of the internal source code, and my next example is linux-2.6.13.tar.gz. You can download it or update it at the following URL.
Http://kernel.org/pub/linux/kernel/v2.6/
2) download the latest version of module-init-tools ("module-init-tools-3.0.tar.gz" and "modutils-2.4.21-23.src.rpm ")
Http://www.kernel.org/pub/linux/... it-tools-3.0.tar.gz
Http://www.kernel.org/pub/linux/... s-2.4.21-23.src.rpm
3) install modutils-2.4.21-23.src.rpm. you may see the warning "user rusty and group rusty not existing. it doesn't matter. You only need to force the installation. if you do not perform these steps on Redhat 9 and Redhat 8, you will encounter problems in the "make modules_install" step.
# Rpm-e -- nodeps modutils (Force uninstall the original modutilsRPM package)
# Rpm-ivh modutils-2.4.21-23.src.rpm (install the source code package to the/usr/src/redhat Directory)
# Cd/usr/src/redhat/SPECS (go to the standard file directory)
# Rpmbuild -- bb modutils. spec (generate a binary RPM package)
# Cd ../RPMS/i386 (transfer to the location of the generated binary RPM package)
# Rpm-ivh modutils *. rpm (just generate two [modutils-2.4.21-23.i386.rpm & modutils-debuginfo-2.4.21.23.i386.rpm] binary RPM packages, install them together !)
4) install module-init-tools. It replaces depmod [/sbin/depmod] and other tools.
Tar-zxvf module-init-tools-3.0.tar.gz
Cd module-init-tools-3.0
./Configure -- prefix =/sbin
Make
Make install
/Generate-modprobe.conf/etc/modprobe. conf
5) decompress the kernel source code and put the downloaded source code package under/usr/src. Then
Cd/usr/src
Tar? Linux-2.6.13.tar.gz zvxf
Ln? S linux-2.6.13 linux
Cd linux
6) make mrproper
This command ensures that the source code directory does not contain the correct. o file and file dependencies. Because we use the complete downloaded
The source program package is compiled, so this step can be omitted. If you use these source programs multiple times to compile the kernel, you 'd better run
Run the following command:
7)
Make sure that the asm, linux, and scsi links in the/usr/include/directory point to the source code of the kernel to be upgraded. They chain to the real, the computer architecture under the source code directory (for PC, the architecture used is i386 ).
Include sub-directories. For example, asm points to/usr/src/linux/include/asm-i386 and so on. If you do not have these links, you must create them manually.
, Follow the steps below:
# Cd/usr/include/
# Rm-r asm linux scsi
# Ln-s/usr/src/linux/include/asm-i386 asm
# Ln-s/usr/src/linux/include/linux
# Ln-s/usr/src/linux/include/scsi
This is an important part of configuration. Delete the asm, linux, and scsi links under/usr/include, and then create a new link.
Point to the directory with the same name under the new kernel source code directory. These header file directories contain the required duplicates to ensure that the kernel is correctly compiled on the system.
The header file. Now you should understand why we have created a link named linux in the "redundant" Directory of/usr/src?

Second compilation Configuration
Please pay special attention to the configuration of several important modules in this part. Generally, use the "make menuconfig" command to configure the kernel.
Enter the graphic mode
# Startx
The following Kernel configuration process is cumbersome, but the proper configuration is directly related to Linux running in the future.
Some important and frequently used options.
You can use one of the following commands to configure the kernel based on your needs and hobbies:

# Make config (the most traditional text-based configuration interface is not recommended)
# Make menuconfig (Text menu-based configuration interface, recommended for character terminals)
# Make xconfig (the configuration interface based on the graphic window mode is recommended in Xwindow)
# Make oldconfig (if you only want to modify some small points based on the original Kernel configuration, it will save a lot of trouble)

Among the three commands, the make xconfig interface is the most user-friendly. If you can use Xwindow, we recommend that you use this command.

.

If you cannot use Xwindow, use make menuconfig. Although the interface is worse than the above one, it is always better than make

Config is much better.

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 or into modules
M -- compile this function into a module that can be dynamically inserted into the kernel as needed

If you are using make xconfig, you can select the corresponding option with the mouse. If make menuconfig is used

You need to use the space key for selection. You will find a bracket in front of each option, but some are brackets, some are angle brackets, and

Parentheses. When using the space key, you can find that the brackets are either empty or "*", while the angle brackets can be empty, "*" and

"M" indicates that the items corresponding to the former are either not required or compiled into the kernel. The latter has the same options and can be compiled into modules. Parentheses

You must select one of the following options.

In the process of compiling the kernel, the most annoying thing is the configuration work in this step. Many new users do not know how to choose these

. In fact, the default value can be used for most options during configuration. Only a small part of options need to be selected based on different user needs. Select

The principle is to compile some function code that is far away from other parts of the kernel and is not frequently used into a loadable module, which helps reduce

The length of the kernel reduces the memory consumption of the kernel, and simplifies the impact on the kernel when the corresponding environment changes of this function.

Select; some function code that is closely related to the kernel and frequently used is directly compiled into the kernel. Next let's separate the common options

.


8.1. Code maturity level options
Code maturity level. There is only one item here: prompt for development and/or incomplete code/drivers, if

To test functions that are still in the experiment stage, such as khttpd and IPv6, You must select Y as the option; otherwise, you can select

Select N.

8.2. Loadable module support
Module support. There are three items:

Enable loadable module support: unless you want to compile all required content into the kernel, this item should

This is required.
Set version information on all module symbols: Optional.
Kernel module loader: enables the Kernel to load required modules at startup. We recommend that you select this module.
8.3. Processor type and features
CPU type. There are a lot of content. I will not introduce them one by one. The following are some of the relevant content:

Processor family: select the CPU type based on your situation.
High Memory Support: supports large Memory capacity. It can be 4 GB or 64 GB.
Math emulation: coprocessor simulation. Coprocessor is the darling of the 386 age and is no longer needed.
MTTR support: supported by MTTR. Optional.
Hierarchical Ric multi-processing support: supports Symmetric multi-processing. You don't need to select one unless you have multiple CPUs.

.

8.4. General setup
Here are some of the most common attributes. This part contains a lot of content. Generally, you can use the default settings. The following describes

Some frequently used options:

Networking support: network support. Required. We recommend that you select this option if no network adapter is available.
PCI support: supports PCI. If the PCI Card is used, it is required.
PCI access mode: PCI access mode. Options include BIOS, Direct, and Any. Select Any.
Support for hot-pluggabel devices: supports hot swapping devices. It is not very good to support.
PCMCIA/carw.support: PCMCIA/carw.support. PCMCIA is required.
System V IPC
BSD Process Accounting
Sysctl support: the above three types of support are related to process processing and IPC calls, mainly System V and BSD. If you

If you do not use BSD, follow the default setting.
Power Management support: Power Management support.
Advanced Power Management BIOS support: Advanced Power Management BIOD support.

8.5. Memory Technology Device (MTD)
MTD device support. Optional.

8.6. Parallel port support
Serial Port support. If you do not want to use the serial port, do not select it.

8.7. Plug and Play configuration
Plug-and-play is supported. Although plug-and-play in Linux is not as good as Windows currently, you can select this option.

Experience plug-and-play in Linux with the mouse down.

8.8. Block devices
Block device support. You have to select one based on your own situation. Here is a brief description:

Normal PC floppy disk support: general PC floppy disk support. This should be required.
XT hard disk support:
Compaq SMART2 support:
Mulex DAC960/DAC1100 pci raid Controller support: For RAID images.
Loopback device support:
Network block device support: supported by Network block devices. If you want to access the Internet neighbors, choose.
Logical volume manager (LVM) support: Logical volume management support.
Multiple devices driver support: supports Multiple device drivers.
RAM disk support: ramdisk support.

8.9. Networking options
Network options. The network protocol is configured here. There is too much content to cover. Let's just look at it. If you have

You can understand what you know. If you are too lazy to check the network, use the default option (You must select TCP/IP networking ).

. Let's take a look at TCP/IP, ATM, IPX, DECnet, Appletalk ...... A lot of protocols are supported. IPv6 also supports Qos.

And/or fair queueing (fair scheduling of Service Quality) is also supported, and kHTTPd, but these are still in the experimental stage.

8.10. Telephony Support
Phone support. What is this? Let me check the help. It turns out that the phone card is supported in Linux, so that you can

Use a regular phone to provide voice services. Remember, the phone card has nothing to do with modem.

8.11. ATA/IDE/MFM/RLL support
This is supported by hard disks, optical drives, tapes, and floppy disks of various interfaces. There is too much content. Use the default option. If you use

For more special devices, such as PCMCIA, find the corresponding options.

For example, PCMCIA.

8.12. SCSI support
Support for SCSI devices. I don't have a SCSI device, so I don't need to select it. If you use a SCSI hard drive, optical drive, or tape

Slave, you have found it yourself.

8.13. IEEE 1394 (FireWire) support
What is this? I have never seen any earlier version. Let's look at the help. Fireware hardware was originally required to improve the performance of the serial bus,

No, no.

8.14. I2O device support
This is not clear. In the help section, it is said that the I2O interface adapter is required to support this function. In the Intelligent Input/Output (I2O) system

The interface is used, and hardware is required again.

8.15. Network device support
Network Device Support. I have selected the Protocol above. Now I have to select a device. As you can imagine, the content must be much more. Okay.

Probably classified, including ARCnet devices, Ethernet (10 or 100 Mbit), Ethernet (1000 Mbit), Wireless LAN

(Non-hamradio), Token Ring device, Wan interfaces, and PCMCIA network device support.

I use 10/100 M Ethernet. It seems that I only need to select this one. I am still familiar with Ethernet devices of 10/100 M. Although there are many contents, I

We can see that the RealTeck RTL-8139 PCI Fast Ethernet Adapter support I use, in order to avoid trouble, compile

It's better to go to the kernel. If M is not selected, select Y. Be patient. Generally, you can find your own network card. If not, you have

Go to the vendor to get the driver.

8.16. Amateur Radio support
If you don't understand it, you should configure amateur wireless broadcasting. No, no.

8.17. IrDA (infrared) support
This requires infrared support.

8.18. ISDN subsystem
If you use ISDN to access the Internet, this is essential. I have done it myself.

8.19. Old CD-ROM drivers (not SCSI, not IDE)
I did really thoughtful, who is still using the non-SCSI/IDE optical drive, I choose it, anyway, I am using the IDE CD-ROM,

This is not selected.

8.20. Character devices
Character device. This content is too much. Use the default settings first, and modify the content as needed. Let's introduce the main categories:

I2C support: I2C is a low-speed serial bus protocol used in micro-control applications promoted by Philips. If you want to select the following

Video For Linux, this item is required.
Mice: Mouse. Now supports bus, serial port, PS/2, C & T 82C710 mouse port, and PC110 digitizer pad,

Select as needed.
Joysticks: handle. Even if you drive the handle in Linux, it doesn't make much sense, and there are too few games.
Watchdog Cards: although it is called Cards, it can be implemented with pure software, and of course there are hardware. If you select this

Then, a file named watchdog will be created under your/dev, which can record the running status of your system until the system

Restart in about 1 minute. With this file, you can restore the system to the state before restart.
Video For Linux: audio/Video cards are supported.
Ftape, the floppy tape device driver:
PCMCIA character device support:

8.21. File systems
File System. There are too many contents. The old method is to modify the content based on the default options. This section describes the following items:

Quota support: Quota can limit the maximum disk space available to each user.

Is very effective.
Dos fat fs support: supports the format of dos fat files, including FAT16 and FAT32.
ISO 9660 CD-ROM file system support: the disc uses the ISO 9660 file format.
NTFS file system support: ntfs is the file format used by NT.
/Proc file system support:/proc file system is a channel provided by Linux for users to interact with the system. It is recommended that you select

Otherwise, some functions cannot be correctly executed.

There are three other categories: Network File Systems and Partition Types.

Zone type), Native Language Support (local Language Support ). It is worth mentioning that the two

Type: NFS and SMB access the file system used by the other party in the form of network neighbors by Linux and Windows respectively.

Select.

8.22. Console drivers
Console driver. Generally, you can use the VGA text console, the standard 80*25 text console.

8.23. Sound
Sound Card Driver. If you can find the sound card driver in the list, it is naturally best, otherwise you will try OSS.

8.24. USB supprot
USB support. Many USB devices, such as the mouse, modem, printer, and scanner, can be supported in Linux.

Select as needed.

8.25. Kernel hacking
With this configuration, you can do some work even when the system crashes. Common users do not need this function.

After the configuration is complete, save the disk and exit. Of course, you can save the current configuration file so that you can save the effort to configure it again next time.

Three compilation processes
After complicated configuration, you can wait for a cup of tea. Compilation-related Commands include the following:
# Make clean -- delete unnecessary modules and files
# Make bzImage -- start compiling the system kernel
# Make modules -- start compiling the plug-in Module
# Make modules_install -- install the compiled Module

The following is the configuration generation
# Make install
If "no module buslogic found" is displayed, the solution is as follows:
1st methods:
Edit the/etc/modules. conf file
Comment out the line "alias scsi hostadapter BusLogic,
That is, # alias scsi hostadapter BusLogic
Save/etc/modules. conf and exit
# Make install
2nd methods:
Manually add a startup Item
# Depmod-
# Cp/usr/src/linux/System. map/boot/System. map-2.6.13
# Cp/usr/src/linux/arch/i386/bzImage/boot/vmlinuz-2.6.13

4. FAQs about Kernel running
1. If it is not started after compilation, the following error is reported:
VFS: Cannot open root device "LABEL =/" or 0.0
>; Please append a correct "root =" boot option
>; Kernel panic: VFS: Unable to mount root fs
If the preceding error occurs, make sure that you configure the following options into the kernel
(1) If/uses the EXT3 file system, add EXT3 support to the kernel.
(2) If it is an IDE hard disk, it must be loaded by the IDE driver.
(3) Select Initial disk (initrd) support in block devices -- RAM disk support, sometimes before mount/
Some modules need to be loaded, and these modules are done in an image file -- kernel-ver.img, which is located in/boot. for example, if the EXT3 is loaded as a module, it is used during mount/, so the system is in initrd. find it in kernel-ver.img.
Use the command mkinitrd initrd. kernel-ver.img kernel-ver to generate initrd. kernel-ver.img

2. How to handle an error when loading iptables during system startup
Modify the/etc/rc. sysinit file:
Replace/proc/ksyms with/proc/kallsyms.
Replace all/proc/sys/kernel/modprobe with/sbin/modprobe
Add mount-f/sys to the mount-f/proc file.
In the file, add action $ "Mounting proc filesystem:" mount-n-t proc/proc: "Mounting sysfs filesystem: "mount-n-t sysfs/sys

Modify the/etc/fstab file:
Add none/sys sysfs defaults 0 0

Modify the/etc/init. d/halt file:
Call the awk '$2 ~ In the halt_get_remaining function ~ /^ \/$ | ^ \/Proc | ^ \/dev/{next} is changed
Awk '$2 ~ /^ \/$ | ^ \/Proc | ^ \/sys | ^ \/dev/{next}

Create directory:
Mkdir/sys

Then restart the machine. The module problem should be solved almost.

Compilation has been completed successfully. the above are the problems and solutions I encountered during the kernel compilation process. If some problems were not encountered, I did not write them in. I hope you can add some corrections to fully promote the Linux spirit !!!

Note:
Http://www.linuxfans.org/nuke/mo .. e = viewtopic & t = 80658
(2) http://www.icwin.net/ShowArtitle.asp? Art_id = 10 & cat_id = 16
(3) http://www.linuxfans.org/nuke/mo... viewtopic & p = 4409655
Related Article

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.