A detailed configuration article for compiling the kernel [4]

Source: Internet
Author: User
Tags ide hard drive
Section 4 enable the kernel

Generally, the core installation is vmlinuz. In the past, Unix users used this name together. "Z" indicates compression, "V" and"
M "means" virtual "(virtual) and" sticky (sticky) ", each of which belongs to memory and disk management. Recommended warranty
Stay at the vmlinuz core until you know it works.
In order to be able to use the new kernel version, you need to make some changes:
# Cp/usr/src/Linux/system. MAP/boot/system. Map-2.2.16
# Cp/usr/src/Linux/ARCH/i386/bzimage/boot/vmlinuz-2.2.16
The above two files are newly generated during compilation. Modify the following two links in/boot: system. Map and VML.
Inuz to point it to the new kernel file:
# Cd/boot
# Rm-F system. Map vmlinuz
# Ln-s vmlinuz-2.2.16 vmlinuz
# Ln-S system. Map-2.2... 16 system. Map
Note: to retain the vmlinuz core, follow these steps:
# Cp/usr/src/Linux/system. MAP/boot/system. Map-2.2.16
# Cp/usr/src/Linux/ARCH/i386/bzimage/boot/vmlinuz-2.2.16
# Cd/boot
# Rm-F system. Map
# Ln-S system. Map-2.2... 16 system. Map
Add the following section to # vi/etc/Lilo. conf:
Image =/boot/vmlinuz-2.2.16 is set to the core that has been installed
Label = linux2.2.16 is used by lilo to tell you which core or job system to start now
,
Read-Only
Root =/dev/hda2 is the root directory of this special job system/
The root =/dev/hda2 line must be modified as needed.
Run: #/sbin/lilo-V to save and execute the command: lilo you will see the core label. The first one is the asterisk. If you
No new core label or lilo error is displayed. You need to work on/etc/Lilo. conf again (see the following
Lilo analysis ).
Make sure that you have edited/etc/Lilo. conf correctly. Now restart the system:
# Shutdown-R now
Hot Start or CTRL + ALT + DEL is not recommended. In some cases, if the file system is not completely unloaded, it will be damaged and opened.
. When lilo prompts, if you need to start the old core or use some parameters to start, if you do not see
Start prompt, you can try shift or ctrl key, so that the start prompt appears. Once it appears, press tab to view the core
Heart tag. Enter tags and optional parameters to start. Generally, it is automatically started after the time specified by the/etc/Lilo. conf file
Dynamic core. At startup, you may see some error messages, such as siocaddr. This usually shows the module (usually the network
No guidance. It's easy to handle this problem. If this error occurs, "VFS, cannotmount root", you will
Do not compile appropriate disk or file system support in the core.
Press the tab key and enter linux2.1.16 when lilo appears after the machine restarts. The new kernel plays a role.

Appendix: lilo analysis (highly technical, for reference only)

Part 1 lilo Introduction

Lilo (Linux Loader) is an excellent Boot manager provided by Linux.
Multiple operating systems on one machine. Compared with other common boot loaders, The lilo Boot Mode is more
Our artistic and in-depth understanding of it will help us easily deal with multiple operating systems, network guidance, and large hard drives.
And large memory.
Lilo's boot mechanism ------ as we all know, the Initial Startup of a computer is controlled by the BIOS (
Such as memory, keyboard, etc.) after initialization, it will try to load the boot of the hard disk's Master Boot Record (MBR) or floppy disk
Slice. MBR can be run in two ways. One is to locate the active partition and load the corresponding Boot Sector, and then
The Boot Sector loads the basic components of the operating system in the partition. The second is to directly load the information from the specified partition.
And mount the operating system of any partition, such as Lilo, OS/2 boot loader, and partition Ma.
And other boot loader programs can be configured in this way. The Boot Sector of the floppy disk is equivalent to the boot of the active partition of the hard disk.
Sector, which is usually used to mount the operating system on a floppy disk. It can be seen that you only need to install lilo in MBR and active partition.
Or the boot floppy disk can take over the control of the computer, and then lilo completes the subsequent boot process. Lilo
Build a boot table address encoding so that its boot program can locate the Linux Kernel File.
The code can be either in cylindrical/head/sector (CHS) mode or in LBA linear block number mode.
Some SCSI control programs, Lilo, can also work well.
After lilo locates the configuration file and goes through the pre-boot process, the prompt: lilo boot:
In this case, the system allows you to boot different operating systems or different kernel configurations, and press the tab key to display the list of options.
And then enter the optional or press enter to select the default configuration. If you select to boot Linux, you can also directly pass
Parameter to the system kernel.
Lilo is more flexible than the boot loader of other systems, and its boot methods are more colorful.
● When lilo is installed on the hard disk MBR, active partition, or boot floppy disk, Lilo acts as a replacement for the original boot program.
Boot Linux and other operating systems on any partition of any hard disk; except for the Boot Sector, it does not have any hidden files
And does not need to use a specific partition. Its configuration file can be stored in any partition, or even in a Linux environment
A subdirectory of a coherent DOS partition. It can guide several different kernel configurations, or even several different kernels.
It can guide multiple Linux versions on the same host Program; up to 16.
● It can boot Linux from the network.
● The flexibility of lilo makes the configuration quite complex. When multiple systems coexist, it is recommended to install other operations first.
System, and then install linux. In this way, it is easier to Set LILO to boot other systems.

Part 2 lilo Parameters

We usually talk about Lilo, which involves two aspects: the Lilo boot program and the Lilo installation command/sbin/Lilo.
In order not to confuse these two concepts, this article will use LILO to represent the Lilo Bootstrap program, while lilo to represent/sbin/lilo
. Generally, Lilo uses a text file/etc/Lilo. conf as its configuration file. Lilo reads Lilo. Con
F. Write the specific lilo to the system boot Zone according to the parameters. /Etc/Lilo. conf is modified at any time,
You must re-run the Lilo command to ensure that lilo is running normally.
It is also quite complicated. Next we will take RedHat Linux as an example for some preliminary discussion. The RedHat lilo package version is 0.
20. Other Linux versions may be different, but not too large.
The configuration parameters in the Lilo. conf file are divided into two parts: Global parameters and boot image parameters.
. The Boot Image Parameters apply to each Boot Image zone. If a boot image parameter (for example, password and
If the global Parameter definition is in conflict, the definition of this boot image parameter prevails, but is limited to this boot image zone. Li
Lo has many pilot parameters. Here we will only introduce some important parameters. Other configurations in Linux
The file is the same, and a line of text after "#" represents a comment.
1. "Boot =" this parameter specifies the name of the device that contains the boot sector (for example,/dev/had). If this parameter is ignored
Read the boot sector from the root partition.
2. "root =" this parameter indicates the device used as the root file system during kernel startup. The value is set
The device name of the root file system. Available device names include:
(1)/dev/hdan ~ /Dev/hddn: ST-506 compatible hard drive, N partitions from A to D
(2)/dev/sdan ~ /Dev/sden: SCSI compatible hard disk, N partitions from A to E
(3)/dev/xdan ~ /Dev/xdbn: XT compatible hard disk, N partitions from A to B
(4)/dev/FDN: floppy disk, a :( n = 0) or B :( n = 1)
(5)/dev/nfs: Mark of the root file system obtained by the Network
3. "nfsroot =" if you need to provide the root file system through NFS to guide the diskless workstation, this parameter specifies the network
The machine program, directory, and NFS of the root file system. The format is nfsroot = (<server_ip> :) <r
Oot_dir> (, nfs_options ))
4. "nfsaddrs =" sets the network interface addresses required for network communication. If this parameter is not set, the kernel will try to use
The Reverse Address Resolution Protocol (RARP) or startup protocol (BOOTP) identifies these parameters in the format of nfsaddrs =
User IP Address: Server IP Address: gateway IP Address: Subnet Mask: client name: network device name 〉
: <Auto> 〉
5. "image =" specifies the Linux Kernel File.
6. "delay =" sets the waiting time before the first image is booted.
7. "disk =" this parameter defines non-standard parameters for a special hard disk.
8. "APPEND =" is used to pass an optional parameter line to the kernel. A typical application is that it cannot be automatically recognized by the system.
Specify parameters for other hard disks, such as: append = "Hd = 64, 32, 202"
9. "label =" this parameter specifies a name for each image for selection during boot.
10. "Read-only" is set to mount the root file system in read-only mode for file system consistency check (fsck)
.
11. "Install =" install a specified file as the new boot sector. The default value is/boot. B.
12. "loader =" indicates the chain loader used. The default value is/boot/chain. B. If
This option is required if it is not started from the first hard disk or a floppy disk.
13. "table =" indicates the device name that contains the partition table. If this parameter is ignored, the boot loader cannot pass the partition
Zone information to the operating system that has been guided. When the partition table to which this parameter points is modified, you must run/sbin/Li again.
Lo.
14. "init =" The Program executed during kernel initialization. The process is usually init, Getty, RC, and sh. Version 1.3.4
The Linux kernel has been able to execute the/sbin/init command line.
You can set init =/bin/sh to directly jump to shell.
15. "ramdisk_start =" because the kernel cannot be placed in a compressed memory file system image
Compress the memory image into a floppy disk and add "ramdisk_start = <OFFSET>" to the kernel.
To start execution.
16. "mem =" one of the purposes of this parameter is to specify the number of memory used for Linux: for example, Mem = 96 mb. Objective 2
Specify mem = nopentium to tell the kernel not to use a 4 MB paging table.
17. "VGA =" sets the display mode, such as 80x50 and 132x44.
18. "linear" generates line used to replace the hard disk sector/head/cylinder address (Hard Disk geometric parameters)
The address of the Ar slice. The linear address is generated at runtime and does not depend on the hard disk geometric parameters. Some SCSI hard disks and
This parameter may be required for some IDE hard disks used in LBA mode. Note: When you install lilo on a floppy disk
You cannot use the "linear" parameter.
19. The "prompt" prompts "Boot:", force lilo to wait for the user's keyboard input, and press the Enter key to immediately
Boot the default Operating System, and press the tab key to print the available operating system. When "prompt" is set
When "timeout" is not set, the system will remain in the waiting state without guiding any operating system. Do not set this
When the parameter is specified, Lilo directly directs the default Operating System without the "Boot:" prompt, unless the user presses shift,
CTRL or Alt. In most cases, if you have multiple operating systems on your hard disk, we recommend that you
Parameters are used to leave users with a choice.
20. "timeout =" sets the length of time for keyboard input, in the unit of 0.1 seconds. If no input is made during this period
Timeout. The system automatically directs the default Operating System. If this parameter is not set, the default timeout duration is none.
Poor.
21. "Other =" is set to include non-Linux operating systems, such as DOS, sco unix, and Windows 95 boot
The file or device of the image.
22. Alias = name indicates an alias for the current operating system.

Part 3 typical lilo Configuration

Generally, the installation program of Linux can complete the installation configuration of lilo to better solve the problem of multiple systems.
If the system cannot automatically complete this configuration, You can manually modify the configuration file/etc/L.
ILO. conf to implement guidance under different conditions.
1. When the system can automatically complete the configuration
There is only one suggestion for this situation: Install lilo on the root of the LINUX partition, rather than the MBR multi-event zone.
. If DOS/Windows is installed in hda1 and Linux is installed in hda2, the content of/etc/Lilo. conf is large.
As follows:
Boot =/dev/hda2 # specify the boot location
Compact
Delay = 50 # latency: 5 seconds
Root = Current # root in the current Partition
Image =/boot/vmlinuz # specify the Linux Kernel File
Label = Linux # use Linux as the Representative name
Other =/dev/hda1 # partitions of other operating systems
Table =/dev/hda # specify the hard disk that contains the Partition Table
Label = dos # Use dos as the Representative name
2. When the system cannot automatically complete the configuration
There are two situations where the system cannot automatically complete the Configuration:
(1) the BIOS cannot directly view the Linux Root partition;
(2) the BIOS can only read and write the first 504 MB of the standard IDE hard disk.
At this time, you must follow the most basic principle: Create a smaller LINUX partition that the BIOS can access, including
Kernel files, ing files, chain loaders, and other necessary content, while the root can be another independent partition. To
Generally, the installation program of Linux can complete the installation configuration of lilo to better solve the problem of multiple systems.
If the system cannot automatically complete this configuration, You can manually modify the configuration file/etc/L.
ILO. conf to implement guidance under different conditions.
1. When the system can automatically complete the configuration
There is only one suggestion for this situation: Install lilo on the root of the LINUX partition, rather than the MBR multi-event zone.
. If DOS/Windows is installed in hda1 and Linux is installed in hda2, the content of/etc/Lilo. conf is large.
As follows:
Boot =/dev/hda2 # specify the boot location
Compact
Delay = 50 # latency: 5 seconds
Root = Current # root in the current Partition
Image =/boot/vmlinuz # specify the Linux Kernel File
Label = Linux # use Linux as the Representative name
Other =/dev/hda1 # partitions of other operating systems
Table =/dev/hda # specify the hard disk that contains the Partition Table
Label = dos # Use dos as the Representative name
2. When the system cannot automatically complete the configuration
There are two situations where the system cannot automatically complete the Configuration:
(1) the BIOS cannot directly view the Linux Root partition;
(2) the BIOS can only read and write the first 504 MB of the standard IDE hard disk.
At this time, you must follow the most basic principle: Create a smaller LINUX partition that the BIOS can access, including
Kernel files, ing files, chain loaders, and other necessary content, while the root can be another independent partition. To
For other configuration details, we use the following instances to describe.
Part 4 Lilo. conf configuration instance
With this basic knowledge, we can easily Configure lilo according to our own intentions.
Example 1. Lilo. conf file
Boot =/dev/hda # Install lilo in MBR. Lilo as the Main Boot manager
Message =/boot/message # comments:/boot/message
Compact # generate a smaller "map" File
Map =/boot/map # specify the "map" file as/boot/Map
Install =/boot. B
Password = zhoudi # Set the password
VGA = normal #80x25 text mode
Linear # use the "linear" Address
Prompt # Prompt User keyboard input
Timeout = 50 # timeout Duration: 5 seconds
Default = dos # operating system with the default boot label DoS
Image =/boot/vmlinuz-2.0.34-1 # Set Linux core
# Setting Linux core Boot Image
Label = Linux # mark as Linux
Root =/dev/hda1 # Set the root file system
Read-Only # lilo loads the root file system in read-only mode
# Set MS-DOS or Windows 95
Other =/dev/hda2 # The DOS partition is the second partition of the first IDE hard disk.
Label = dos # mark as DoS
Table =/dev/hda # The primary device is the first IDE hard disk.
# Set sco unix Note: SCO partitions must be active partitions and Lilo must be installed on MBR.
Other =/dev/hda3
Label = SCO
Table =/dev/had
  
In this example, Lilo manages all operating systems on the machine as the Main Boot manager. Lilo can also be used as the second
Level Boot manager. You only need to change the "Boot" parameter to the root partition. Example: boot =/dev/h
When da1 uses lilo in this way, Linux Root partitions must be set to active using DOS or Linux fdisk programs.
Dynamic partition, and this method is only valid for the primary partition of the hard disk (not an extension or logical partition.
Example 2: a standard IDE Hard Drive requires Linux and DOS/windows.
For large hard drive problems, many people only know the limit of less than 1024 cylinders, but I do not know why the standard IDE Hard Drive only
Recognize the first 504 MB. In fact, the int13 call of the BIOS uses the CHS encoding of three single-bit tuples, 10 bits are the cylindrical number, 8
BITs are the head number, and 6 bits are the fan area number. The possible cylindrical number is 0 ~ 1023, the possible head number is 0 ~ 255, and
The possible sector number on the track is 1 ~ 63. Up to 8455716864 single-byte tuples (7.875 GB) can be specified with the 24-bit)
. Unfortunately, the standard ide interface allows 256 sectors/channels, 65536 cylinders, and 16 heads. It itself
237 = 137438953472 (128 GB), but 63 BIOS sectors and 1024 cylinders are added.
Only 528482304 (504 MB) is available after the limit.
Countermeasure: Divide 350 MB (/dev/hda1) to DoS and 150 MB (/dev/hda2) to Linux in the first MB of the hard disk.
The hard disk parameters should be specified in the corresponding configuration file.
Boot =/dev/hda
......
Disk =/dev/hda
BiOS = 0x80
Sectors = 63
Heads = 16
Cylinders = 2100
Image =/vmlunuz
Append = "Hd = 2100,16, 23"
Root =/dev/hda2
Label = Linux
 
Example 3. If you have a large hard disk larger than 8 GB and you need to install linux on the back of the disk, you can
Select linear mode during installation and add hard disk parameters to it.
The hard disk parameters during installation can be written as follows: HD? = Cyls, heads, and secs. The actual uppercase letters must be used.
To replace the hard disk parameters, these parameters can be found on the hard disk tag, you can also look at the hard disk in the BIOS settings
The parameter corresponds to the line in LBA mode. The question mark is determined based on the hard disk. In actual use, it can be a, B,
One of the four letters C and D. For example, hda = 1869,63, 255 is a parameter of the IBM 15.2 GB hard drive.
Of course, after entering Linux, you can add this file by editing/etc/Lilo. conf, and then run it again
Lilo achieves the same purpose. Here is the content of Lilo. conf before I add parameters:
Boot =/dev/hda
Map =/boot/Map
Install =/boot. B
Prompt
Timeout = 50
Image =/boot/vmlinuz
Label = Linux
Root =/dev/hda1
Initrd =/boot/initrd-2.2.12-20.img
Read-Only
After adding parameters in the linear mode, the format is as follows:
Boot =/dev/hda
Map =/boot/Map
Install =/boot. B
Prompt
Linear <----- added this line
Timeout = 50
Image =/boot/vmlinuz
Label = Linux
Root =/dev/hda1
Initrd =/boot/initrd-2.2.12-20.img
Read-Only
Append = "hda = 1869,63, 255" <------ added this line. Note that the append parameter is for each system
The pilot record must be placed under the image or the other so that it can play a role.
When Linux is started again, Lilo will boot the system in linear mode.
In addition to the different location methods, there is no impact on other aspects.
Chapter 3 kernel-compiled applications
Section 1 embedded Linux technology
How big is your Linux? (And practice results)
This is not what I wrote. It is only used to refer to manufacturing small kernel, and the effect is acceptable.
Minimum Linux Kernel
I am using 2.2.15 of the mandrake kernel. I have not modified any line of code, and only rely on modifying the configuration.
File to obtain the data.
First, use make xconfig to get all the options that can be removed.
Do not floppy
Do not use SMP or mtrr
Do not networking, SCSI
Remove all Block devices, leaving only the old ide Device
Remove all character Devices
Remove all filesystems, leaving only minix
Do not sound support
Believe me, I have removed all the options. After doing so, I got a 188 K core. No
I am afraid it is difficult to use the Linux function through this core, so I decided to add the network back. In general
Network support is added and re-compiled. The core is 189 KB. 10 K to change the TCP/IP stack, it seems
It is a very computation business.
However, even if there are stacks and no driver, it is not surprising that I use the rtl8139 commonly used in the embedded board.
Add the driver back, 195 KB. If you need a DOS file system, the size is 213 KB. If minix uses
Ext2 generation, the size will grow to 222 K.
However, you should note that the size here refers to the size of the core file. That is the same as the desired random memory.
. This number indicates how much ROM you need to store your core.
The memory required for Linux is about 600 ~ Between 800 KB. 1 MB may be able to boot, but it may not be useful.
This is because it may be difficult to connect to the C library. 2 MB should be enough, but it may take more than 4 MB.
You can execute a complete system.
Do you think Linux is really a little big here. Okay! Let's see who occupies the space,
The list below is made from the core 222 K.
# WC
ARCH/i386/kernel. o
ARCH/i386/MM/mm. o
Kernel/kernel. o
Mm/mm. O fs/fs. o
IPC/IPC. o
FS/filesystems.
Net/network.
Drivers/block.
Drivers/Char.
Drivers/MISC/Misc.
Drivers/NET/net. A Drivers/PNP.
/Usr/src/smalllinux/ARCH/i386/lib.
/Usr/src/smalllinux/lib.
/Usr/src/smalllinux/ARCH/i386/lib.
The result is as follows:
243 2250 81946 ARCH/i386/kernel. o
42 316 10569 ARCH/i386/MM/mm. o
173 1541 74660 kernel/kernel. o
266 2307 68053/mm. o
222 3139 123193 fs/fs. o
49 602 21600 IPC/IPC. o
263 2940 106504 fs/filesystems.
137 1510 65512 net/network.
92 719 39178 Drivers/block.
230 2308 87556 Drivers/Char.
1 1 8 Drivers/MISC/Misc.
83 721 25680 Drivers/NET/net.
1 1 8 Drivers/PNP.
20 187 9526/usr/src/smalllinux/ARCH/i386/lib.
23 150 7714/usr/src/smalllinux/lib.
20 187 9526/usr/src/smalllinux/ARCH/i386/lib.
1865 18879 731233 total
The size here is slightly different from the final size, but it can be used as a reference. Shown here
730 K is about 600 K. Obviously, filesystem is quite large. About 230 K
, Accounting for 1/3 of the volume. Memory management accounts for 80 KB, which is similar to the sum of other core parts. TCP/IP sta
CK accounts for 65 K and driver accounts for 120 K. Sysv IPC accounts for 21 k, and can be removed if necessary. The core file should
It can be about 10 k smaller. So what if we want to reduce the core size? The answer should be obvious,
Of course, it is the file system. Linux VFS reduces the file system design, buffer cache, directory c
Ache increases system efficiency. But these are fundamental to the embedded system on flash.
It is of little use. If you can remove them, the core can be reduced to about 20 K. If you skip the entire VFS,
Directly write the file system as a driver type, which can reduce the size of 230 kb to about 50 kb. Entire Core
Scale down to about 100 K.
From the above data, the number of mm segments reduced by uClinux is not much less than that of the province.
In addition to the Al memory, the memory allocation part should also be processed, which is unavoidable. If both
It is not impossible for Linux with a core of less than 100 kb.
Practice: Compile the core of 196k successfully, but it cannot be used to start RedHat. It is too large. 280k can be started, positive
In a smaller effort.
Conclusion
After my thesis is finished, it is necessary to review my graduation design process.
This topic is more challenging for a non-computer student. In today's popular Linux,
System and network management information can be seen everywhere, but the lack of kernel information makes people feel overwhelmed. For Linux
Books show that a month later, I felt that my vision was wide open and I gradually clarified the direction. Collecting translation materials has become an important part.
All night on the Internet to find information, and then on the system continuous inspection. Core of the thesis ------ the compilation process starts to get the instructor
Guidance: I have accumulated 21 articles and hundreds of knowledge points in the kernel, which gives me a sense of accomplishment.
In addition to describing how to do it in detail, this paper also explains the cause, and even the appendix. While highlighting the key points
Other content than my subject ------ embedded Linux operating system, because I know that my subject is a comprehensive subject-
---- Design a device (theory) with an embedded operating system ------ preliminary work.

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.