1. General boot guide process. On a PC, the initial startup is completed by the BIOS. When Power-On Self-Test (POST) is completed, the BIOS tries to read the first sector of the floppy disk as the Boot Sector. If no floppy disk exists, read the first sector of the hard disk. The new BIOS can change this order, starting from the hard disk first. Or even boot from the CD. Because most BIOS do not support SCSI, the SCSI adapter must provide its own BIOS to start from the SCSI disk. if nothing can be found, the old BIOS will start the built-in rom basic, or directly print "NO ROM-BASIC ". Start the operating system in several steps. Because the boot sector is relatively small, usually the main task is to read the second loader. The second loader then reads the third loader until the entire operating system is fully read. DOS boot zone: OFFSET 0x000 JMP xx Near jump into the program code 0x003 Disk parameters 0x03E Program code loading the DOS kernel 0x1FE 0xAA55 Magic number for BIOS It can be seen that the structure of the boot area is relatively simple. The length is always 512 bytes. Above, the disk parameter is only valid for DOS. It is important that the boot area starts from 0 and ends with the magic number of the BIOS. It is relatively easy to start from a floppy disk, because there is only one boot sector: the first sector. The hard disk is more difficult. It is divided into many partitions. However, the BIOS treats the hard disk like a floppy disk and reads the first partition, which is called master boot record. (MBR ). therefore, the MBR should have the same structure as described above: Starting from 0 and ending with the magic number of BIOS in the last part of MBR, with a partition table. For example: OFFSET Length 0x000 0x1BE code loading and starting the boot sector of the active Partitian 0x1BE 0x010 partition1 0x1CE 0x010 partition2 0x1DE 0x010 partition3 0x1EE 0x010 partition4 0x1FE 0x0012 0xAA55 Disk parameters Each partition information occupies 16 bytes. The structure is as follows: 1 BOOT Boot flag: 0 = not active, 0x80 active 1 HD begin: Head number 2 sec cyl begin: Sector and Cylinder Number of Boot Sector 1 sys system code: 0x83 Linux, 0x82 Linux swap etc. 1 HD end: Head number 2 sec cyl end: Sector and Cylinder Number of Boot Sector 4 low byte high byte relative sector number of start sector 4 low byte high byte number of sectors in the Partition Therefore, the hard disk can have four partitions. The four partitions are called primary partitions: Primary prititions. If they are not enough, you can set the so-called extended partitions. An extended partition contains at least one logical partition. The first sector structure of the extended partition is similar to MBR. The first table item of its partition table corresponds to the first logical partition. If the second logical partition exists, the second table item in the partition table contains a pointer. This pointer points to an address next to the first logical partition. This address contains a partition table. The first table item of the partition table corresponds to the second logical partition. In this way, a linked list is formed, so that the extended partition can have any number of logical partitions. Each primary partition and expansion area contains a boot sector. The system can only be started from one of these locations. The boot flag determines which zone is guided. Originally, only the primary partition, therefore, the MS-DOS fdisk and most similar tools can only activate the primary partition. MBR code to do the following operations: 1: Determine the active partition. 2: Use BIOS to read the startup sector of the active partition. 3: Jump to the 0 position of the Start sector. The MBR has enough space to complete these tasks. As mentioned above, each partition theoretically contains a boot sector, and the second hard disk also contains a structure similar to the first one. MBR can fully accommodate a complex boot program. The so-called Boot manager dynamically determines the active partition. Linux provides lilo 2. Lilo: the Linux Loader The lilo Boot Sector contains the space of a partition table. Therefore, Lilo can be installed in MBR or in the boot sector of a partition. Lilo has all the functions of the DOS Boot Sector, and it can also boot the logical sector and the second hard disk partition. Lilo can also work with other leaders (such as NT loader), so that users can have many choices. (Note: The following titles are used in the original article to prevent ambiguity) 2.1 lilo started by MS-DOS MBR If the system has at least one Linux primary partition (non-swap partition, and on the first hard disk), Lilo can install one of these partitions. When the corresponding lilo partition is activated, the boot process is as follows: BiOS read into MBR MBR reads active primary partition: The partition where lilo is located. LILO directs Linux or another operating system. It's easy to boot other OS without using LILO to activate that partition. Linux partitions are safe and unchanged. 2.2 LILO started by a boot manager If you do not want to delete the old boot manager, or an OS LILO cannot be booted, you can consider this approach. 1. If the boot manager can guide the expansion area, it is a good place for LILO. 2. If the boot manager can boot the second hard disk partition, linux can be mounted to the second hard disk. 3. Some boot managers can even boot logical partitions, so LILO can be mounted to logical partitions. Of course, pay attention to the following situations: 1. Some operating systems directly rewrite MBR, which will damage the original boot manager. 2 re-partitioning will damage the Boot Sector of the extended partition, which may be reinstalled by LILO. When installing a new system, whether or not to reinstall (linux) depends on the new boot manager, either the LILO boot Sector is canceled or the boot manager provides a boot item for it. Partitioning or formatting will delete LILO and linux. 2.3 LILO occupies MBR If the entire linux system is on the second hard disk and there is no extended partition on the first hard disk, LILO is only mounted on the MBR. In this way, the old MBR will be washed away. Therefore, before installing LILO, you need to back up the old MBR (including the Partition Table. There are many tools in DOS to complete this task. In linux, the backup is as follows: # Dd if =/dev/had of =/backup/MBR bs = 512 count = 1 Write the following command: # Dd if =/backup/MBR of =/dev/had bs = 446 count = 1 In this way, the original MBR will be written but does not include the partition table. If the partition table is to be restored, bs = 512. Note that the new partition table will be damaged! 2.4 LILO file Files related to LILO are usually stored in/boot/, and the configuration file lilo. conf is located in/etc. The ing files containing the actual boot system information are installed with/sbin/lilo. For any LILO installation, the configuration file should be set to suit individual needs. The configuration file: configuration file Basically, the configuration file assigns values to some variables. Each row contains a flag variable or a variable value. The configuration file is assigned a value by a special variable into several areas, each of which leads to a linux or other OS. The following describes common rows: Boot = device Indicates which device or partition contains the Boot Sector. If no value is assigned to boot, the current default value is used. Compact Activation mode: In this mode, LILO reads several adjacent partitions into the BIOS at a time. This greatly shortens the loading time, especially from a floppy disk. Delay = tenths In 10 seconds, it is required that LILO wait for the user before guiding the first boot configuration. If no definition is available, direct guidance is provided. Linear Use LILO to generate linear addresses instead of the usual Sector/Head/Cylinder mechanism. The Linux address mechanism does not depend on the physical structure of the disk. Install = boot sector Use the specified boot sector to write the boot sector./boot. B is used by default. Disktab = disktab The specified disktab is used. By default,/boot/disktab. disktab is used to save the physical structure information of the hard disk. Map = map file The path of the ing file. Message = file Specify a file. The file content will be displayed in LILO boot. If this file is not described, only "LILO" will appear ". Verbose = level This section describes the debugging level of LILO. From 0 (no information is displayed) to 5 (all status information ). Backup = backup file Backup file of the previous Boot Sector content. The default value is/boot. device number. Force-backup = backup file Same as backup, if the backup file exists, it will be overwritten. Prompt Specify the kernel to be booted by using the keyboard. It is not selected by default. Timeout = tenths Set a time-out value, which must have keyboard input during this time; otherwise, use the first configuration. Similarly, if it times out, you cannot enter a password. Generally, the default value is infinite. Note: The difference between delay and timeout (joe thinks). delay is the maximum time that the user must enter after "LILO" appears. Timeout is the maximum interval between the two keys that the system waits for after you press any key. Serial = port, bps parity bits Set serial port parameters. If LILO obtains the serial port parameters from the file. If one of them is invalid, all three parameters are invalid. Select a Port from four standard serial ports: 0 for COM1 or/dev/ttyS0 .. The supported baud rate ranges from 100 to 9600. All verification settings are supported. (N: none, e: even, o: odd) bits is 7 or 8. The default value is serial = 0, 2400n8. Ignore-table Let LILO ignore the broken partition table. Fix-table Allows LILO to convert the address of each partition (sector/head/cylinder) to a linear address. Generally, the partition address starts from cylinder boudary. Some operating systems will change this. Because LILO can only write the start sector of LILO on the partitions with the same addresses, the correct 3D address can be corrected using the fix-table. However, this correction cannot be always guaranteed, so repartitioning to ensure alignment cylinder boudary is the best option. Password = password Set password for boot Configuration Restricted Relax the password restrictions. Password is required only when you want to assign an additional startup parameter to the kernel. Optional The kernel that can be configured has errors or does not exist. If optional is not specified, LILO prints some errors and exits. Each configuration that is guided from LILO starts from the image line. Image = kernel Label = name The Image contains the kernel to boot. Label is used by the user. The Image line usually points to a device, for example,/dev/fd0. The range of the kernel can be indicated by range. Range = range Range can be expressed by start sector-end sector or start sector + length. For example: Image =/dev/fd0 Label = floppy Range = 1 + 512 The following Variable assignment may occur: Append = string Send the string as the boot parameter to the kernel. For example, hardware parameters. Literal = string And append queries are not much. However, it will overwrite the original settings. Therefore, it cannot be described globally. Ramdisk = size Set the RAM disk size. Read-Only Read-write Set the access mode of the root file system. Root = Device Set the device that exists in the root file system. VGA = Mode Screen Settings. Possible modes: Normal, extended, and ask .. The following settings are for other operating systems: Loader = loader refers to the file used to guide the operating system. The default value is/boot/chain. B. In addition, Lilo contains the following Loader: Os2_d. B can boot OS/2 from the second Hard Disk Any_d. B tries to reverse the order of the two hard disks before booting the operating system, so as to direct the OS on the second hard disk. Table = device indicates a device that stores the OS to be booted in a partition of the device. If the table is not described, LILO will not transmit the information to the osunsafe to be booted. Turn off the OS check to be booted. This setting is used only when you need to boot from a floppy disk. This setting does not exist. Each time the map installer starts running, the boot disk must be inserted with a soft drive. The disktab file The disktab file contains the physical structure information of the device that LILO wants to boot. Generally, this information can be obtained from the device driver. Therefore, the disktab file is used only when this method is not run. In this case, LILO reports the error message if the file is unavailable: Geo_query_dev HDIO_GETGEO (dev ...) Or HDIO_REQ not supported for your SISI controller Please use/boot/disktab Then, the physical structure information must be manually entered: #/Boot/distab-LILO parameter table # # This table contains the geometry parameters for SCSI and # IDE disks, which can not be recognized automatically # Entries in this Table Overwrite recognized parameters! # # Dev. BIOS secs/heads/cylin-par. # Num. Code track cylin. Ders. offset (Optional) #0x800 0x80 32 64 202 0 #/dev/SDA The domain meanings are as follows: Zero x 800 Device number. It consists of the Primary and Secondary device numbers. Device number. It consists of the Primary and Secondary device numbers. 0x80 The bios of the device. The first hard disk of the 0x80 code system. 0x81 second ,.... All partitions on the same hard disk have the same value. 32, 64, 203 Number of Sector (per track) Heads count Number of cylinders 0 Partition start. It can also be read from a partition table. 2.5 LILO startup information During startup, LILO will display 'lilo'. If LILO exits due to an error, you can determine the cause of the system error based on the display. No information: LILO is not read, LILO is not installed, or the partition where LILO resides is not activated. Lnumber: The first part of LILO is read and executed. However, the second part cannot be read. The following number indicates the cause of the error. This may be caused by physical errors or incorrect physical structure information of the hard disk. LI: The first part of LILO can be read into the second part, and the second part has an error during execution. This may be due to incorrect physical structure information or re-installing boot. B without running LILO for re-installation. The second part of LIL: LILO is started, but it cannot be read into the descriptor tables from the map file. This indicates incorrect physical structure information or physical errors. LIL? : The second part of LILO is read incorrectly. Same reason as LI LIL-: descriptor tables is incorrect. This may be because the physical structure information is incorrect or the map file is reinstalled without running LILO for reinstallation. -- Excerpt from: Beijing LINUX Iamafan |