In-depth Linux lilo

Source: Internet
Author: User
Tags compact ide hard drive

In-depth Linux LILO

Null Jiang yongzhong

[Back] [forward 〗

In-depth Linux LILO
Author: Jiang yongzhong

Linux boot can adopt multiple methods, and its Loader LILO (Linux Loader)
Is a flexible boot loader, compared with other commonly used boot loader, LILO
The guiding method is more artistic and its in-depth understanding will help us conveniently
It handles multiple systems, network boot, large hard disks, large memory, and many other difficult problems.

I. LILO's Guiding Mechanism

As we all know, the Initial Startup of a computer is controlled by the BIOS.
(Such as memory and keyboard) after initialization, it will try to load the Master Boot Record of the hard disk
(MBR) or the Boot Sector of the floppy disk.

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 completes the loading of basic components of the operating system in the Zone
The second is to directly load information from a specified partition and load any partition through it.
Operating System, such as Lilo, OS/2 boot loader, and partition magic.
Programs can be configured in this way.

The boot sector of a floppy disk is equivalent to the Boot Sector of the active partition of the hard disk.
The operating system on the floppy disk.

As you can see, you only need to install lilo on the MBR, active partition, or boot floppy disk,
Then LILO can take control of the computer and complete the subsequent boot process. LILO
Build a bootstrap table address encoding so that its Bootstrap can be located in Linux
Core file. This address encoding can be performed in the cylindrical/head/sector (CHS) mode.
Uses the LBA linear block number mode, so even for some SCSI control programs LILO
It works well.

After LILO locates the configuration file and goes through the pre-boot process, a prompt is displayed:
LILO boot:

In this case, the system allows you to boot different operating systems or different kernel configurations,
Press the Tab key to display the option list, and then enter the option or press enter to select the default configuration.
If you choose to boot Linux, you can also directly pass parameters to the system kernel.

LILO is more flexible than the boot loader of other systems.
The guide method is also more colorful.

● When LILO is installed on the MBR, active partition, or boot floppy disk of the hard disk
The replacement of the original boot program, which can guide Linux and other operations on any partition of any hard disk
System;

● Apart from the boot sector, it does not have any hidden files and does not need to use specific scores.
The configuration file can be stored in any partition or even in a zone unrelated to Linux.
Under a subdirectory of the 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;

● It can boot Linux from the network.

LILO's flexibility makes its configuration quite complex. When multiple systems coexist,
We recommend that you first install other operating systems and then install Linux. In this way, Set LILO
System guidance is relatively simple.

Ii. Several important LILO boot parameters

There are many LILO Bootstrap parameters. Here we will only introduce some important parameters.
.
1. "boot ="

This parameter indicates the name of the device that contains the boot sector (for example,/dev/had ).
Then, read the boot sector from the current root partition.

2. "root ="

This parameter indicates which device is used as the root file system during kernel startup.
The value is the device name of the root file system when the kernel is constructed. The 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 use NFS to provide the root file system to boot a diskless workstation, this parameter is the kernel
Specifies the machine program, directory, and NFS where the network root file system is located. The format is nfsroot =
(<Server_ip> :) <root_dir> (, nfs_options> 〉)

4. "nfsaddrs ="
Set 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 the startup protocol (BOOTP) to find these parameters,
The format is:

Nfsaddrs = <Client IP address>: <Server IP address>: <gateway IP address>: <subnet mask> 〉:
<Client name>: <network device name>: <auto> 〉

5. "image ="
Specify the Linux Kernel File.

6. "delay ="
Set the waiting time before the first image is booted.

7. "disk ="
This parameter defines non-standard parameters for a special hard disk.

8. "APPEND ="
To pass an optional parameter line to the kernel, a typical application is
Automatically recognized hard disk parameters, such as: append = "hd = 64, 32, 202"

9. "label ="
This parameter specifies a name for each image for selection during boot.

10. "read-only"
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 ="
The chain loader used. The default value is/boot/chain. B,
This option is required if it is not started from the first hard disk or a floppy disk.

13. "table ="
Indicates the name of the device that contains the partition table. If this parameter is ignored, the boot loader does not
Partitions can be transferred to the operating system that has been guided. When the partition table to which this parameter points is modified
You must re-run/sbin/Lilo.

14. "init ="
The Program executed during kernel initialization. The process is INIT, Getty, RC, and sh,
Linux Kernel versions earlier than 1.3.43 can execute the command lines described in/sbin/init. If
If a problem occurs during the boot process, 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
Enough and compressed memory images are placed in a floppy disk and "ramdisk_start = <OFFSET>" is added to the kernel?
Start execution.

16. "mem ="
One of the purposes of this parameter is to specify the amount of memory used for Linux: for example, Mem = 96 MB,
The second objective is to specify mem = nopentium to tell the kernel not to use a 4 MB paging table.

17. "VGA ="
Set the display mode, such as 80x50 and 132x44.

Iii. Typical LILO configuration methods

Generally, the installation program of Linux can complete the installation configuration of LILO,
So as to better solve the problem of multi-system boot, if the system cannot automatically complete this configuration
By manually modifying the configuration file/etc/lilo. conf.
.

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 MBR. Assume that DOS, Windows, and hda2 are installed in hda1.
If Linux is installed, the content of/etc/lilo. conf is roughly 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 # partition where other operating systems are located table =/dev/hda
# Specify the hard disk label = dos that contains the Partition Table # 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: Build a BIOS that can be accessed less
Linux partitions, including kernel files, ing files, and chain loaders.
While the root can be another independent partition. For other configuration details, I
You can use the following examples to describe.


Example 1: The main hard disk is the IDE interface, the second hard disk is the SCSI interface, and the root file is in the SCSI
.

Countermeasure: divide a small Linux partition on the IDE Hard Disk (/dev/hda2 ),
It contains the basic file and is mounted to the master of/u2, its configuration file/etc/lilo. conf
Content:

Boot =/dev/hda # lilo is installed in the mbr of the primary ide
Install =/u2/etc/lilo/boot. B # install lilo boot records from boot. B
Map =/U2/etc/LILO/map # The installer creates this ing file, telling the boot loader the location of the kernel Block
Compact
Timeout = 50
Image =/U2/vmlinuz # The kernel file should be copied to/U2 in advance
Label = Linux
Root =/dev/sda1 # Tell the kernel root system to read-only on the SCSI hard disk
Other =/dev/hda1
Loader =/U2/etc/LILO/chain. B # specify the loader label = DoS

Example 2: Linux and DOS/windows must be installed on a standard IDE hard drive.
For large hard drive problems, many people only know the limit of less than 1024 cylinders, but do not know
Why can only recognize the first 504 MB of standard IDE hard drive.

In fact, the int13 call of the BIOS uses the CHS encoding of three single-bit tuples, with 10 bits as the column
Face Number, 8 bits are the head number, and 6 bits are the fan area number. The possible cylindrical number is 0 ~ 1023, yes
The available head number is 0 ~ 255, while the possible sector number on the track is 1 ~ 63, take the 24
A maximum of 8455716864 bitwise tuples (7.875 GB) can be specified ).

Unfortunately, the standard IDE interface allows 256 sectors/channels and 65536 Columns
Face and 16 head. It can access 237 = 137438953472 (128 GB ),
However, with the restriction of 63 sectors and 1024 cylinders in BIOS, only 528482304 (504
MB.

Countermeasure: Divide 350 MB (/dev/hda1) to DOS and 150 MB (/dev/hda2) to Linux in the first MB of the hard disk,
Q: Why can't I ask why I have to raise an apricot?
Boot =/dev/hda
......
Disk =/dev/hda
Bios = 0x80
Sectors = 63
Heads = 16
Cylinders = 2100
Image =/vmlinuz
Append = "hd = 2100,16, 23"
Root =/dev/hda2
Label = Linux

Iv. Uninstall lilo

When lilo overwrites the Boot Sector, it retains a backup of the Boot Sector in/boot. xxyy.
Xyy is a hex device master/times number.
(Major/minor numbers), you can use the command "ls-L/dev/device ".
Obtain the primary/secondary number of the hard disk or partition. If these backup files already exist, when you reinstall LILO or?
When the kernel is created, it no longer generates this file, which ensures that this backup file is the original boot sector.

To uninstall LILO, you only need to restore the initial Boot Sector. Example: LILO
Installed in/dev/had, the corresponding backup file is/boot/boot0000300, which is easy to use
Run the following command:

Dd if =/boot/boot1_300 of =/dev/had bs = 446 count = 1

Of course, if you want to completely Uninstall Linux, you must use the fdisk of Linux
The row is damaged because the fdisk of DOS cannot be removed from non-DOS partitions.

There are still many questions worth exploring about LILO, but as long as you understand its internal mechanism,
It can also solve more complex situations.

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.