In-depth understanding of LILO

Source: Internet
Author: User
Tags ide hard drive

In-depth understanding of LILO

Null

[Back] [forward 〗

Linux boot can adopt multiple methods. Its Loader LILO (Linux Loader) is a flexible boot Loader, compared with other common Boot Loader programs, the LILO Boot Mode is more artistic. Our in-depth understanding of it will help us easily deal with 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. After initialization of some hardware (such as memory and keyboard), it will try to load the Master Boot Record (MBR) of the hard disk) 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 load the basic components of the operating system in the partition by the Boot Sector; the second is to directly load information from a specified partition and load the information into the operating system of any partition through it, boot loaders such as LILO, OS/2 boot loader, and Partition Magic 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. It is usually used to mount the operating system on the floppy disk.

It can be seen that as long as LILO is installed on MBR, active partition, or boot floppy disk, LILO can take control of the computer and then complete the subsequent boot process. LILO creates a boot table address encoding so that its boot program can locate the Linux Kernel File. This address encoding can be performed in the cylindrical/head/sector (CHS) mode, LBA linear block numbers can also be used, so that even some SCSI control programs LILO can run 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 list of options, and then enter the options or press enter to select the default configuration, if you select boot Linux, you can also directly pass parameters 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 MBR, active partition, or boot floppy disk of the hard disk, as a replacement of the original boot program, LILO can guide the Linux and other operating systems on any partition of the hard disk;

● Apart from the boot sector, it does not have any hidden files and does not need to use specific partitions, its configuration file can be stored in any partition, or even a subdirectory of a DOS partition unrelated to Linux;

● 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.

The flexibility of LILO makes the configuration quite complex. When multiple systems coexist, we recommend that you first install other operating systems and then install Linux, it is easier to Set LILO to boot other systems.

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). If this option is ignored, the boot sector is read from the current root partition.

2. "root ="

This parameter indicates which device is used as the root file system when the kernel is started. The set 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 a root file system to boot a diskless workstation, this parameter specifies the program, directory, and NFS where the network root file system is located for the kernel. 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 specified, the kernel will try to use the Reverse Address Resolution Protocol (RARP) or 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 ="
An optional parameter line is passed to the kernel. A typical application is to specify parameters for hard disks that cannot be fully recognized by the system, 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 will not be able to pass partition information to the operating system that has been guided. When the partition table to which this parameter points is modified, you must run/sbin/lilo again.

14. "init ="
The program that is run during kernel initialization. The process is init, getty, rc, and sh. Linux kernel versions 1.3.43 and later can run the command lines described in/sbin/init, 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, to enable the kernel image to be placed in a floppy disk with the compressed memory image, add "ramdisk_start = <offset> 〉", in this way, the kernel can 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 goal 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 Linux installer can complete LILO installation configuration to better solve the problem of multi-system boot. If the system cannot automatically complete this configuration, you can manually modify the configuration file/etc/lilo. 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 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.

In this case, you must follow the most basic principle: to create a Linux partition with a smaller BIOS access, including the Kernel File, ing file, and chain loader, the root can be another independent partition. For other configuration details, we will use the following instances 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 on the SCSI.

Countermeasure: divide a small Linux partition (/dev/hda2) on the IDE hard disk, which contains the basic file, which is mounted to/u2 and its configuration file/etc/lilo. the main content of conf is:

Boot =/dev/hda # mbr install =/u2/etc/lilo/boot. B installed in the main ide
# From boot. binstall The lilo Boot Record map =/u2/etc/lilo/map # The installer creates this ing file, tell the boot loader the location of the kernel block: compact timeout = 50 image =/u2/vmlinuz
# Copy the Kernel File to/u2 label = linux root =/dev/sda1 # Tell the kernel root system to read-only other =/dev/hda1 loader on the scsi hard disk =/ 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 the standard IDE hard drive can only recognize the first 504 MB.

In fact, the int13 call of 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, while the possible sector number on the track is 1 ~ 63. Up to 8455716864 single-byte tuples (7.875 GB) can be specified with these 24-bit addresses ).

Unfortunately, the standard IDE interface allows 256 sectors/channels, 65536 cylinders, and 16 heads. It can access 237 = 137438953472 (128 GB) on its own, but with the restriction of 63 sectors and 1024 cylinders in BIOS, only 528482304 (504 MB) is available.

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

Iv. Uninstall LILO

When LILO overwrites the boot sector, it will keep a backup of the boot Sector in/boot. xxyy, where xxyy is the device master/times number in hexadecimal notation.
(Major/minor numbers), you can use the command "ls-l/dev/device" to obtain the master/times number of the hard disk or partition. If these backup files already exist, when you reinstall LILO or rebuild the kernel, it will not generate 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. For example, if LILO is installed in/dev/had and the corresponding backup file is/boot/boot0000300, simply use 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 Linux fdisk to destroy the Linux partition, because the DOS fdisk 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, LILO can solve more complicated actual situations.

Responsible editor: Knowledge Base Administrator)

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.