|< Day Day Up >|
The sequence of events that happens when you power on your computer, or in short, what happens when you boot your computer, is going to be discussed in this and the following subsections. In the process, some very commonly used commands and tools available on Linux will also be introduced.
Booting with Linux is very friendly and flexible, and it offers a number of options. However, all the different possible configurations of installation are not going to be discussed here; rather, a couple of the most frequent options are given special attention. In the first case, you might have installed Linux as the only operating system on your computer, and in the second case, you might have installed Linux along with Microsoft Windows. To make the booting process simple and easily understood, the scope of discussion is narrowed down to these points. However, other possibilities could also work out well.
As mentioned earlier, it is the primary master hard disk that participates in the booting process. A hard disk is comprised of a number of cylinders, and each cylinder is divided into a number of sectors. (A more thorough discussion of the hard disk structure is beyond the scope of this book.) The first sector on the first cylinder of the primary master hard disk is called the boot sector, which stores the master boot record (MBR) along with the partition table data. The master boot record is 446 bytes long and stores program code, which determines the remaining boot process, such as which operating system to boot, on which partition the operating system is located, and so on. It is important to note that until the point the BIOS reads the MBR, the booting process is the same whichever operating system is installed on the computer. When Windows alone is installed on the computer, Windows writes its own MBR code into the boot sector, which points to the first sector of the partition containing the Windows loading programs. This first sector of the Windows partition may contain a list of additional Windows operating systems loaded on different other partitions, as explained in a later section in this chapter. However, if there is only one Windows operating system, then the MBR points to it directly. Figure 2.1 displays a typical hard disk with four primary partitions, when Windows is the only operating system installed on the computer.
Similarly, when Linux alone is installed, the installation process writes the Linux Loader (LILO) into the boot sector. Recent Linux distributions are also equipped with a new boot loader program called GRUB (GNU GRand Universal Boot loader), which is feature-rich and easier to use than LILO. It is important to note that we use either LILO or GRUB, but not both, when we install Linux. Red Hat Linux 8.0 and 9.0 and SuSE Linux 8.1 and 8.2 install GRUB boot loader by default due to its enhanced functionality compared to LILO. Both these boot loader programs are capable of booting multiple operating systems installed on the computer. A boot loader such as LILO or GRUB serves to function as the first stage of boot loader, which further loads the second stage of the boot loader from the boot partition, typically /boot on most Linux installations. Figure 2.2 displays a typical hard disk with partitions when Linux alone is installed.
When Linux is installed on the computer as the only operating system, then the MBR contains the boot loader program (such as LILO or GRUB), which enables the boot process to continue loading the second stage of the boot loader, which in turn loads the kernel finally. Typically, a boot loader program is more useful for loading a specific operating system when multiple operating systems are installed on the PC than when Linux or Windows is the only operating system loaded on the computer. During the Linux installation process, the user is prompted to provide boot loader configuration information, and finally the boot loader is installed in a location specified by the user. By default, the boot loader is installed in the MBR boot sector. The user may choose to install the boot loader onto a floppy, in which case the Linux PC can only be booted through the floppy (or the boot loader may also be installed on another partition on the hard disk, which is not discussed here). Unless there is a real hindrance to installing the boot loader onto the MBR, it should always be installed there. This will make the PC bootable without the need of a floppy. However, a bootable floppy can always be created manually later on for rescue purposes if Linux fails to boot from the MBR for any reason. When the bootable floppy is created, a compressed boot image is copied to the floppy instead of installing the boot loader onto the floppy. It is important to note the difference between writing the boot loader and writing a bootable kernel image to the floppy. In the first case, the boot loader starts from the floppy (instead of from the MBR), then loads the second stage boot loader, and finally loads the kernel image from the hard disk partition identified from the boot loader configuration. In the second case, a boot loader does not come into the picture; the compressed bootable kernel image is read directly from the floppy, which drives the rest of the boot process and will not allow operating systems other than Linux to boot.
When Linux is installed on the PC along with Microsoft Windows to share resources, usually the primary master hard disk is logically divided into partitions, with Windows installed on one partition and Linux on another partition. At a minimum, two partitions are necessary, where the Windows partition serves as the C drive on Windows, and the Linux partition serves as the root file partition (identified by ‘/’) for the Linux operating system. This two-partition setup is really a very base configuration, and normally more partitions (and more space) are necessary for either Windows or Linux in order to load more application software. When both Windows and Linux have to share the same primary master hard drive, normally Windows requires that it should be installed first in sequence, and it should occupy the first primary partition. Linux does not have such a stringent requirement, and it may be installed on any partition on the disk. When Windows is first installed, it writes its own boot loader into the MBR boot sector. Later, when Linux is installed, we are left with two options. As the first option, we could overwrite the MBR written by Windows by the Linux boot loader (LILO or GRUB). In this case, before overwriting the MBR, the partition containing Windows is identified in the boot loader configuration with a specific name, such as windows or win2k. This name serves as the label that is displayed by the boot loader. When we boot the system, a menu of both the operating systems is displayed, and we can choose the one to be booted for the session. If we do not choose a specific one from the list within the default waiting period, the operating system identified as default in the boot loader configuration is automatically booted. As the second option, instead of overwriting the Windows-specific MBR on the boot sector, we can save the Linux boot loader configuration on a floppy. In this case, when we boot the computer without the floppy, Windows is automatically booted (ignoring the presence of Linux on the computer), and we should use the floppy containing the boot loader program in order to boot Linux. When we do so, Windows is ignored, and the PC boots into the Linux partition. This method may be used as an alternative, to keep Windows MBR and Linux MBR separate, but it is always preferable to overwrite the MBR on the primary master hard disk with Linux boot loader program. Figure 2.3 displays a typical hard disk with partitions sharing both Windows and Linux operating systems and their file systems.
As we have noted in the preceding discussion, the LILO or GRUB boot loader is used to find and load the kernel in a typical Intel-based Linux architecture. In other architectures such as machines hosting Alpha-based and Itanium®-based processors, the boot loader program is usually different; however, the current discussion is limited to the Intel-based architecture.
|< Day Day Up >|