Team LiB   Previous Section   Next Section

4.1 The Boot Process

On an x86-based PC, the first sector of every hard disk is known as the boot sector and contains the partition table for that disk and possibly also code for booting an operating system. The boot sector of the first hard disk is known as the master boot record (MBR) because when you boot the system, the BIOS transfers control to a program that lives on that sector along with the partition table. That code is the boot loader, the code that initiates an operating system. When you add Linux to the system, you need to modify the boot loader, replace it, or boot from a floppy or CD to start Linux.

In Linux, each disk and each partition on the disk is treated as a device. So, for example, the entire first hard disk is known as /dev/hda and the entire second hard disk is /dev/hdb. The first partition of the first hard drive is /dev/hda1, and the second partition is /dev/hda2. The first partition of the second hard drive is /dev/hdb1, and so on. If your drives are SCSI instead of IDE, the naming works the same way except that the devices are /dev/sda, /dev/sda1, and so on. Thus, if you want to specify that the Linux partition is the second partition of the first hard drive (as in the examples in this chapter), you refer to it as /dev/hda2. Note, though, that GRUB has its own disk naming convention, described in Section 4.3.

Once you've made the decision to install LILO or GRUB, you still need to decide how it should be configured. If you want your system to dual-boot Linux and Windows 95/98/ME, you can install LILO or GRUB on the MBR and set it up to let you select the system to boot. Dual-booting Linux and Windows NT/2000/XP is not quite as straightforward because they use the Windows NT loader, which is installed on the MBR and expects to be the one in charge. The standard solution described in this chapter is to add Linux as an option in the NT loader and install LILO or GRUB in the Linux partition as a secondary boot loader. The result is that the NT loader transfers control to the secondary loader, which then boots Linux. See Section 4.6 later in this chapter for more information. You can also install one of the Linux boot loaders in the MBR and use it to boot Windows—see the "Linux+WindowsNT" and the "Multiboot with GRUB" mini-HOWTOs if you're interested in doing that.

When you install the boot loader (either LILO or GRUB) on the MBR, it replaces the MS-DOS boot loader or any other boot loader that may be there, such as the Windows NT loader. If you have problems with your installation or you simply want to restore the original boot loader, you can do one of the following.

  • If you're running LILO, you can boot Linux from a floppy or CD and restore the boot sector, which LILO automatically backs up:

    % /sbin/lilo -u
  • If you have the capability, boot to DOS and run the fdisk command with a special option that rebuilds the MBR:

    C:> fdisk /mbr
  • For Windows 2000 and Windows XP, which do not have an fdisk command, boot your computer from the Windows CD (or the Windows boot floppies if you can't boot from your CD drive). When you see "Welcome to Setup," press R (for repair) and, in Windows 2000, you then press C. Select your Windows installation from the numbered list that is displayed (there may be only one entry) and enter the administrator password at the prompt. Enter the command fixmbr at the command-line prompt and confirm it with y. After the MBR has been restored, type exit to reboot.

The common element in all three methods is that they replace the boot loader on the MBR with the original Microsoft boot loader. The boot loader on the MBR is the one that will be used to boot the system. This means that if you want to switch from LILO to GRUB, say, or from GRUB to LILO, you don't need to uninstall the old loader; simply install the new one.

The rest of this chapter describes the various techniques for booting Linux and the options that you can specify to configure both the boot loader and the Linux kernel. Whether you use LILO, GRUB, or Loadlin, you can pass options to the loader and specify options for the kernel.

    Team LiB   Previous Section   Next Section