RedHat linux 8.0 kernel compilation steps and instructions

Source: Internet
Author: User


**************************************** *******************************
* Many of the following steps are basic commands or explanations, because I am a beginner in linux,
* Many detours were taken during the compilation process and it took a lot of time to find various solutions.
* I have written all the corresponding commands and want to get started soon just like me.
* It is helpful for beginners to compile the kernel!
*
* Kilvon 05-Mar-2003
**************************************** ******************************

Basic compilation Description: the current version is RedHat linux 8.0.
(The machine has dual Operating Systems: linux and windows 2000)
The kernel version is 2.4.18-14, and the hardware is a model of the compaq notebook,
The downloaded kernel version is 2.4.20 (available on www.kernel.org ),
We recommend that you use a later version to compile the kernel instead of the previous version,
For the reason, see step 7.1.

Before compilation starts, we recommend that you use the relevant software in windows to create
Detailed statistics, including hardware types, manufacturers, chip versions, and so on, especially laptops
And brand machines, because many of their components are from OEM and other manufacturers, and print them
Used to configure the kernel. (For linux, you can also use the system tool.->
Hardware browser)

In addition, it is recommended that you prepare several sheets of paper and pen at your side to take down the information you think is important at any time,
Of course, the error information is included to help identify and solve the problem in the future.

1.copy the internal source code package linux-2.4.20.tar.bz2 to the/usr/src directory:
# Cp linux-2.4.20.tar.bz2/usr/src
# Cd/usr/src

2. Delete the symbol link pointing to the previous kernel version.
# Rm-f linux-2.4

3. Use the following command to uncompress the compressed package
# Bzip2-d linux-2.4.20.tar.bz2
# Tar-xvf linux-2.4.20.tar

4. Create a new symbol link to the directory where the source code is just unlocked.
# Ln-s linux-2.4.20 linux-2.4

5. Go to the working directory for future Compilation:
# Linux-2.4/cd/usr/src/

6. This command ensures that there is no incorrect. o file in the source code directory (that is, the object file, compile c language)
The purpose is to use the link when the code can be compiled in the next step .)
Dependencies. This command is not required for the first compilation of the source code package, but if you use this command multiple times
To compile the kernel with some source code, you must first run this command.
# Make mrproper

7. In order not to affect the available kernel (such as the linux kernel installed at the time of installation ),
Save the previous available kernels (to enable linux to be started if compilation fails ),
In addition, we need to easily identify the kernel identifier of this compilation. The following steps are as follows:
Compilation has nothing to do with it.

7.1 even if grub is used as the boot manager, modify the grub. conf file,
# Cp/boot/grub. conf/boot/grub. conf. bck
(We recommend that you print a copy of the original grub. conf file with conditions. For the reason, see step 7.4)
# Emacs/boot/grub. conf
(Emacs tips: ctrl + x + s is the result of saving, ctrl + x + c is to disable emacs,
Delete n lines of text: place the cursor at the beginning of the text to be deleted ctrl + u, and then press
Number of deleted rows, such as 4, and ctrl + k)

The following figure shows grub. conf:
Default = 1
Timeout = 10
Splashimage = (hd0, 6)/grub/splash.xpm.gz
Title Psyche (2.4.18-14 standard)
Root (hd0, 6)
Kernel/vmlinuz-2.4.18-14.standard ro root =/dev/hda8
Initrd/initrd-2.4.18-14.standard.img
Title Windows 2000
Rootnoverify (hd0, 0)
Chainloader + 1

Note that the two statements kernel... And initrd... must correspond to the following changes:
# Rm-f/boot/System. map
# Rm-f/boot/vmlinuz
# Cp/boot/System. map-2.4.18-14/boot/System. map-2.4.18.standard
# Ln-s/boot/System. map-2.4.18.standard/boot/System. map
# Cp/boot/vmlinuz-2.4.18-14/boot/vmlinuz-2.4.18-14.standard
# Ln-s/boot/vmlinuz-2.4.18-14.standard/boot/vmlinuz
# Cp/boot/initrd-2.4.18-14.img/boot/initrd-2.4.18-14.standard.img
(Initrd only uses copy, because it is used to compile a kernel of a higher version, not the same version.
The advantage of compiling a later version is that the system will create another directory instead
Overwrite the previous version with the newly compiled (possibly wrong) version. Check the/lib/modules directory.
You will understand .)

7.2 how do I know the partition on which your root directory "\" is located? Command:
# Df
The following are some outputs of an even machine:
Filesystem 1K-blocks Used Available Use % Mounted on
/Dev/hda8 4137264 2136592 1790508 55%/
...

It is important to see where your system root directory is installed, because you will see grub when the system installs the compiled kernel. root = LABEL =/hdc = ide-scsi
The following error may occur during system boot:
VFS: Cannot open root device "" or 00: 00
Please append a correct "root =" boot option
Kernel panic: VFS: Unable to Mount root fs on
Therefore, modify the command in grub. conf to: root =/dev/hda8.

7.3 OK. After completing these preparations, we will --
Restart the machine, :) don't worry. You should first confirm the correctness of the work in step 1 to avoid 7.1 errors.
In the subsequent steps. (You must be very careful when compiling the kernel, so you cannot be impatient. Otherwise, hey ...)

7.4 if the system is faulty during the restart process, you can temporarily modify the grub reference on the grub boot interface.
Export parameters. Related Commands include:
E-edit pilot command
ESC key-return to the parent directory
O-insert a command line
B-start the boot System
D-delete a row
In fact, you can delete all the commands on the grub Console (only this startup is affected), and then follow
Commands in/boot/grub. conf are manually typed in the grub console, which is the same effect.

7.5 if you can use the reconfigured grub command to correctly start the system, let's start the real
Compile the program !!!!

7.6 first ensure that we are in the compiled working directory:
# Linux-2.4/cd/usr/src/
Edit Makefile (this file is used to control compilation) and find this line:
EXTRAVERSION =
Modify to (for example, this compilation can also be any legal string, such as "-sema-v.4 ")
EXTRAVERSION =-kilvon.001

8. Compile in X Window:
# Make xconfig

8.1 if you are in text mode, use
# Make menuconfig

8.2 In fact, the most difficult part of the compilation process is the kernel parameter configuration. I spent a lot of time here,
Even worse, I didn't realize this at the beginning. I thought it was the use of those commands... So, let's take a look:

8.3 The principle of selection is to compile some functional code that is far away from other parts of the kernel and is not frequently used into a loadable module (which is far away? The degree of understanding of linux and operating system concepts, and the help of the configuration items are helpful to reduce the kernel length and reduce the memory consumed by the kernel, the impact on the kernel when the corresponding environment change of this function is simplified; do not select a function that is not required; compile some function code that is closely related to and frequently used by the kernel directly into the kernel. The following describes common options:

/1. Code maturity level options
Code maturity level. There is only one item here:
Prompt for development and/or incomplete code/drivers
If you want to test functions that are still in the experimental stage, such as khttpd and IPv6, you must
Select Y. Otherwise, select N.

/2. Loadable module support
Module support. There are three items:

Enable loadable module support:
Unless you want to compile all the required content into the kernel, this item should be required.
Set version information on all module symbols:
You can leave it unselected.
Kernel module loader:
We recommend that you select the required modules when starting the kernel.

/3. Processor type and features
The CPU type has many options. I will not describe them one by one. The following are some of the related items:

Processor family:
Select the CPU type as needed.
High Memory Support:
Large memory capacity. It can be 4 GB or 64 GB.
Math emulation:
Co-processor simulation, co-processor is the darling of the 386 era, and now it is no longer used.
MTTR support: supported by MTTR. Optional.
Invalid Ric multi-processing support:
Supports multiple symmetric processing. Unless you are rich enough to have multiple CPUs, you do not need to choose.

/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. This parameter is required and is recommended if no network adapter is available.
PCI support:
PCI support, required.
PCI access mode:
PCI access mode. Options include BIOS, Direct, and Any. Select Any.
Support for hot-pluggabel devices:
Optional.
PCMCIA/carw.support:
PCMCIA/CarIa support. It is required if PCMCIA is available.
System V IPC
BSD Process Accounting
Sysctl support:
The above three items are related to process processing/IPC calls, mainly System V and BSD.
If you are not using BSD, follow the default setting.
Power Management support: available for Power Management, especially for laptops.
Advanced Power Management BIOS support: Advanced Power Management BIOD support.

/5. Memory Technology Device (MTD)
MTD Device Support
Optional.

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

/7. Plug and Play configuration
Plug-and-play is supported. Choose it. you can experience the plug-and-play experience in Linux.

/8. Block devices
Block device support. You need to select a specific scenario for each user:

Normal PC floppy disk support,
No
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
You can choose.
Logical volume manager (LVM) support: Logical volume management support.
Multiple devices driver support: supports Multiple device drivers.
RAM disk support: ramdisk support.

/9. Networking options
Network options. The network protocol is configured here. Let's see for yourself.
In addition to the TCP/IP networking, you must check the other options.

/10. Telephony Support
Linux supports phone cards, so that you can use a common phone on an IP address to provide voice services. For details, see the help content.

/11. ATA/IDE/MFM/RLL support
This is supported by hard disks, optical drives, tapes, and floppy disks of various interfaces. The content is too large and the default value is used.
The PCMCIA card is occasionally available. The situation varies with machines.

/12. SCSI support
Support for SCSI devices. If you use SCSI hard drive, optical drive, tape, and other devices, you can find them by yourself.

/13. IEEE 1394 (FireWire) support
Even gray, don't worry about it ,:))

/14. I2O device support
Used in smart Input/Output (I2O) system interfaces. No. Use the default value.

/15. Network device support
Network Device Support. Now the protocol has been selected.
In order to avoid the trouble, compile it into the kernel. If M is not selected, select Y. Be patient. Generally, you can find your own network card. If no, you have to go to the vendor to become the driver,
Or go to www.mydrivers.com.

/16. Amateur Radio support
No. No.

/17. IrDA (infrared) support
This requires infrared support. I have.

/18. ISDN subsystem
If you use ISDN to access the Internet, this is essential.

/19. Old CD-ROM drivers (not SCSI, not IDE)
It is specially designed for non-SCSI/IDE optical drives, but who is still using such old Dongdong? Choose it by yourself.

/20. Input Core Support
This option is very important. In addition to joystick (game remote control lever), we recommend that you select "m". Remember!

/21. Character devices
Character device. This content is too much. Use the default settings first, and modify the settings as needed:

I2C support: I2C is a low-speed serial used in microcontrol applications promoted by Philips.
Bus Protocol. This option is required if you want to select the following Video For Linux.
Mice: Mouse. For a notebook, we recommend that you choose "y" on Bus Mouse Support ".
Joysticks: handle. It doesn't make much sense to drive the handle in Linux.
Watchdog Cards: although it is called Cards, it can be implemented using pure software.
Hardware. If you select this option, a name named
The watchdog file that records the running status of your system until the system is restarted.
It takes about 1 minute to start. 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:

/22. Multimedia devices
For capturing audio/video, if you are interested in help

/23. File systems
File System. The content is too large. We recommend that you 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, which is very effective when multiple users share a single host.
Dos fat fs support:

Support for dos fat file formats, 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. If you want to mount the ntfs partition in linux, You need to select it. Remember that during mount,

Only iocharset = cp936 can be added, and codepage = 936 cannot be added.
/Proc file system support:/proc file system is provided to users and systems by Linux.
It is recommended that you select an Internet connection. Otherwise, some functions cannot be correctly executed.

There are also three other types of rules here: Network File Systems (Network File Systems ),
Partition Types (Partition type) and Native Language Support (supported by local languages ).
It is worth mentioning that there are two types of Network File Systems: NFS and SMB are Linux and
Windows accesses the file system used by the other party in the form of network neighbors.

/24 Console drivers
Use default

/25 Sound
What sound card do you use? Select it.

/26 USB Support
It is very important to select at least the following options
Support for USB
UCHI Alternate Deriver (JE) Support
OCHI (Compaq, iMacs...
USB Audio...
Usb midi...
USB Human Interface Device (full HID) support
HID input layer support
/Dev/hiddev raw HID...
Usb LCD device support
Because many of the hardware is required to support usb hid, many of them are selected here.

* If you have some options, you can refer:
/Usr/src/linux-2.4/Documentation/Configure. help
You can also search the entire system and see which files are related to the text:
# Find/usr-name "*. *"-print-exec grep
-Q-s mousedev {}\;-print
This long command is useful

8.4 don't forget to save your configuration to a file, otherwise you will have to re-select it at next compilation!
Load Configuration from file
For example, save to/home/kilvon/conf/Kernel-kilvon.001

8.5 run the following command to read the configuration data and make it take effect:
# Make dep
# Make clean

9. start compiling the kernel and modules.
# Make bzImage
# Make modules
# Make modules_install

10. Move the compiled file to/boot. If the preceding step is incorrect, most of the situations are caused
When you configure the kernel options, select the current version that can only be compiled as modules and compile it into the kernel,
I have encountered such a situation several times. Since www.kernel.org has released a stable kernel,
(Even those alpha and beta versions are not down) 9 to 9 can be compiled successfully.
# Move/usr/src/linux-2.4/System. map/boot/System. map-2.4.20-kilvon.001
# Move/usr/src/linux-2.4/arch/i386/boot/bzImage
/Boot/vmlinuz-2.4.20-kilvon.001
# Rm-f System. map
# Rm-f vmlinuz
# Ln-s/boot/System. map-2.4.20-kilvon.001/boot/System. map
# Ln-s/boot/vmlinuz-2.4.20-kilvon.001/boot/vmlinuz

11. Make some final work:
# New-kernel-pkg -- install -- depmod -- mkinitrd 2.4.20-kilvon.001
-- If mkinitrd is used as Initial Ramdisk, you can try mkinitrd-h.
-- Depmod check whether there are unparsed symbrs in the kernel
-- Install a startup option in grub

12. Check the explanations in step 7.2. Modify the/boot/grub. conf file,
The modified grub. conf is as follows:
Default = 2
Timeout = 10
Splashimage = (hd0, 6)/grub/splash.xpm.gz
Title Psyche (2.4.20-kilvon.001)
Root (hd0, 6)
Kernel/vmlinuz-2.4.20-kilvon.001 ro root =/dev/hda8
Initrd/initrd-2.4.20-kilvon.001.img
Title Psyche (2.4.18-14 standard)
Root (hd0, 6)
Kernel/vmlinuz-2.4.18-14.standard ro root = LABEL =/hdc = ide-scsi
Initrd/initrd-2.4.18-14.standard.img
Title Windows 2000
Rootnoverify (hd0, 0)
Chainloader + 1

13. Check whether the file name under/boot is correct (there are many music videos and cp actions in front)
[Root @ localhost boot] # ll
Total 8880
5824 July 22, September 6 04:53 boot. B
612 September 6 04:53 chain. B
42150 September 5 01:47 config-2.4.18-14
1024 July 15, March 5 21:32 grub
130983 March 5 03:49 initrd-2.4.18-14.img
130983 March 4 20:21 initrd-2.4.18-14.standard.img
65499 March 5 21:31 initrd-2.4.20-kilvon.001.img
473 July 22, March 5 03:49 kernel. h
12288 October 17 03:44 lost + found
23108 22:05 message on April 9, September 6
21282 22:05 message. ja on January 1, September 6
21 August 15, March 5 03:49 module-info-> module-info-2.4.18-14
15436 July 14, September 5 01:47 module-info-2.4.18-14
15436 March 4 20:21 module-info-2.4.18.standard
16834 March 5 21:17 MyKernelSetup-kilvon.001
640 October 11, September 6 04:53 os2_d. B
March 5 19:32 System. map-> System. map-2.4.20-kilvon.001
507814 July 14, September 5 01:47 System. map-2.4.18-14
507814 March 4 20:20 System. map-2.4.18-14.standard
588175 March 5 21:24 System. map-2.4.20-kilvon.001
3236438 September 5 01:47 vmlinux-2.4.18-14
31 March 5 12:51 vmlinuz->/boot/vmlinuz-2.4.20-kilvon.001
1125194 September 5 01:47 vmlinuz-2.4.18-14
1125194 March 4 20:19 vmlinuz-2.4.18-14.standard
1458790 March 5 21:24 vmlinuz-2.4.20-kilvon.001

14. Okay, come on:
# Reboot

15. If something is wrong, it cannot be started. Return to the grub console and start it with the previous kernel. Remember? The "extra" work in the previous step will save you a lot of time at this moment...

16. if the system can be started to the logon interface and can be logged on, but there is a Failed item in the startup process, view:/var/log/boot. log or search in this directory to see what the problem is,
Later, these annoying red characters were solved by changing the kernel compilation configuration. After that, I wrote them here.

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.