-->
Previous Table of Contents Next


The Boot Sector

To understand the Linux boot process, a look at the DOS boot sector is necessary. Figure 4.1 shows the DOS boot sector layout. The program code is the bootstrap to the operating system. The disk parameters include the File Allocation Table (FAT).


Figure 4.1.  The DOS boot sector layout.

The LILO boot sector is similar to the DOS boot sector, except the disk parameter section is not used and the boundaries between code sections are different. The Linux boot sector layout is shown in Figure 4.2. The differences between the two boot sectors can cause a problem for DOS if the Linux LILO boot sector is written to a DOS disk’s Master Boot Record because DOS won’t be able to load properly.


Figure 4.2.  The Linux LILO boot sector layout.

The magic number referred to in both boot sector layouts is a two-byte number used by some operating systems to verify that the sector read is the boot sector.

The Linux LILO boot sector can, in theory, be used to boot DOS because the partition table area of the boot record can contain the DOS’ FAT file, but in practice the boot process usually fails. It is much better to use a boot sector written to the Linux partition.


Warning:  
Because the DOS and Linux LILO boot sectors differ, you should install DOS before Linux. This will make sure that the DOS boot sector is written to the hard disk. If you install Linux first and the Linux LILO boot sector is written to the hard disk, DOS cannot boot.

The LILO boot sector can be saved on a boot floppy, on the Master Boot Record of the hard disk, on the boot sector of the Linux partition, or in the boot sector of an extended partition. It cannot be stored in any non-Linux partition or on any hard disk other than the first.

Note that although DOS cannot handle a boot sector in an extended partition, Linux can through extensions to fdisk or a utility program called activate.


Warning:  
A common problem with LILO is that it will write a LILO boot sector anywhere, even into locations that cannot be accessed by the operating system. Make sure you are writing your LILO boot sector to a valid location. If you have already installed Linux and are making changes, keep a boot floppy at hand.

The Boot Process

During the boot process, the boot sector is read to obtain the bootstrap for the operating system. In the case of DOS, the Master Boot Record or boot sector is read, then COMMAND.COM is loaded. COMMAND.COM is the DOS operating system kernel.

Although usually set up when the Linux installation process is followed, you may want to alter the boot system used by Linux. There are several approaches that can be used depending on your requirements and machine hard drive configuration. We can look at a few of the typical configuration examples to show how the boot process can be modified.

Dedicated Linux Hard Disk

With a dedicated Linux installation or a Linux boot by default (and despite other operating systems on the hard disk), the Master Boot Record can be replaced with the Linux LILO boot sector. LILO will then boot straight into Linux from the Master Boot Record without touching partition boot sectors. In some cases, though, you may have to explicitly specify the boot sector. In other words, at the boot: prompt you may have to specify boot=/dev/hda (or whichever device holds the modified Master Boot Record) if the default values do not work.


Warning:  
If you replace the Master Book Record with LILO for a dedicate Linux system and then later remove Linux, you will have to low-level format the hard drive or restore the old MBR before the drive can be used by another operating system such as DOS.

To install LILO as a dedicated Linux boot, follow these steps:

1.  Boot Linux as usual. Make sure you have a boot floppy disk in case of problems.
2.  Copy your existing Master Boot Record to a floppy in case of problems. The command to copy the MBR from the main drive (/dev/hda) to a floppy using 512 character blocks (the default) is

dd if=/dev/hda of=/fd/MBR bs=512 count=1

3.  Use the setup or LILO installation program to copy LILO into the boot sector, setting LILO in the Master Boot Record.
4.  Reboot the machine to boot from the Master Boot Record.

Your machine should load Linux automatically. If Linux does not boot, use your boot floppy to start Linux and either repeat the process or restore the original Master Boot Record from the floppy using the following command:


dd if=/fd/MBR of=/dev/hda bs=446 count=1


Previous Table of Contents Next