next up previous
Next: What is GNU/Linux? Up: Personal Computers Previous: Hardware and Software

Booting

A computer with its power turned off is an inert collection of hardware; all of its potential as a tool resides in data on its hard drive, stored much like music on an audio cassette. A running computer differs only slightly in outside appearance, but in terms of physical state is entirely different, in much the same way a living body differs from a dead one: Data courses through the memory and is modified by the processor, information trickles in from the mouse and keyboard,6 video output is written on the screen, files are read from and written to the hard drive, and so on. How does a computer undergo the miraculous transformation from a dead mass of hardware to a running, interactive machine at the mere application of some electricity?

The act of starting a computer is called booting. It is a chicken-and-egg situation, because a computer cannot do anything useful until it has programs loaded into memory, but it cannot load anything into memory without a program to tell it how. The ingenious solution is a multi-stage process, named for the proverbial ``pulling yourself up by the bootstraps.'' There is a chip--the BIOS--that can perform basic hardware checks, and read a small amount of data from the hard drive. The BIOS chip is a piece of read-only memory (ROM), and performs its task automatically when electricity is applied. The BIOS tests that basic components (specifically, a processor, some memory, a storage device, and a video device) are electrically connected (which is simple); then it reads a few hundred bytes from a storage medium (usually the hard drive, but possibly a floppy or CD) into memory. These bytes reside in an agreed-upon location called the boot sector, and constitute a small program, called a boot loader. The boot loader has two abilities: it knows where to locate the kernel7 on the hard drive and how to read it into RAM. Once loaded, the kernel initializes the hardware, finds and loads device drivers and the necessary parts of the root filesystem (see Section 3.3), and starts up system processes. In a minute or so, the system is running full tilt and is ready to use.

If you watch a computer boot up, you can see these stages occur in succession. The BIOS detects the amount of RAM and tests it, and possibly verifies that the disk drives are working. In GNU/Linux, there will typically be a prompt, LILO:, the Linux (boot) Loader, which waits a few seconds for you to tell it which operating system to load. Then there is a brief message about ``booting the kernel'' and a quick slew of messages about detected devices, filesystems checked and mounted, and services (daemons) started. At the end of it all, you are presented with a login prompt. This information is a powerful diagnostic tool, once you become accustomed to reading it. Once GNU/Linux is running, you can see most of the boot messages by typing dmesg | less at a shell prompt. Hitting the spacebar will show one screenful of information at a time. Most of this information (everything past the bootloader stage) is hidden behind a blank Windows screen when Windows is booted, though it is saved in a file if you know where to find it.

There is another chicken-and-egg story, which is, ``How did the information get on the hard drive to begin with?'' Of course, at some point someone installed the operating system, but how did they boot the computer? The answer is that computers are able to boot from the floppy drive, and newer PCs can boot from the CD-ROM. To install an operating system, you need a ``boot disk'' (a boot floppy or a bootable CD-ROM).8 The BIOS loads the kernel, which mounts a root filesystem, either from the floppy itself, or from a CD-ROM. Once the kernel is running, it's straightforward to transfer everything from the CD-ROM to the hard drive.9


next up previous
Next: What is GNU/Linux? Up: Personal Computers Previous: Hardware and Software
hwang
2001-10-31