UNIX System Administration Handbook - Evi Nemeth [18]
MONTGOMERY, JOHN, AND WOODY LEONHARD. The Underground Guide to Unix: Slightly Askew Advice from a Unix Guru. Reading, MA: Addison-Wesley. 1995.
REICHARD, KEVIN, AND ERIC FOSTER-JOHNSON. Unix in Plain English, 3rd Edition. Foster City, CA: IDG Books Worldwide. 1999.
RANKIN, BOB. The No BS Guide to Linux. No Starch Press. 1997.
WALL, LARRY, TOM CHRISTIANSEN, AND RANDAL L. SCHWARTZ. Programming Perl, 2nd Edition. Sebastopol, CA: O’Reilly & Associates. 1997.
2 Booting and Shutting Down
UNIX is a complex operating system, and turning UNIX systems on and off is more complicated than just flipping the power switch. Both operations must be performed correctly if the system is to stay healthy.
Although the boostrapping process has always been somewhat mysterious, it was simpler in the days when one manufacturer controlled all of the system’s hardware and software. Now that UNIX runs on PCs, the boot procedure has to play by Microsoft’s rules and deal with a large variety of potential configurations. Although we discuss the boot procedure for all our example systems, you’ll see that we have quite a bit more to say about the PC-based versions of UNIX than about the “captive” systems.
Although this chapter appears early in the book, it refers to material that is not discussed in detail until many hundreds of pages later. In particular, familiarity with the material in Chapter 5, The Filesystem, Chapter 12, Drivers and the Kernel, and Chapter 28, Daemons, will prove helpful. If your system already boots without any problem, you may want to skip this chapter and come back to it later.
An additional caveat: the booting process is hardware dependent. The information that follows is generically true but may differ from reality for your system.
2.1 BOOTSTRAPPING
Bootstrapping is the nerd word for “starting up a computer.” The normal facilities provided by the operating system are not available during the startup process, so the computer must “pull itself up by its own bootstraps.” During bootstrapping, the kernel is loaded into memory and begins to execute. A variety of initialization tasks are performed, and the system is then made available to users.
Boot time is a period of special vulnerability. Errors in configuration files, missing or unreliable equipment, and damaged filesystems can all prevent a computer from coming up. Boot configuration is often one of the first tasks an administrator must perform on a new system. Unfortunately, it is also one of the most difficult, and it requires some familiarity with many other aspects of UNIX.
When a computer is turned on, it executes boot code that is stored in ROM. That code in turn attempts to figure out how to load and start your kernel. The kernel probes the system’s hardware, then spawns the system’s init process, which is always PID 1.
Several things must happen before a login prompt can appear. Filesystems must be checked and mounted, and system daemons started. These procedures are managed by a series of shell scripts that are run in sequence by init. The startup scripts are often referred to as “rc files” because of the way they are named; the “rc” stands for “runcom” or “run command,” a historical remnant of the CTSS operating system circa 1965. The exact layout of the startup scripts and the manner in which they are executed vary among systems. We cover the details later in this chapter.
Automatic and manual booting
Most UNIX systems can boot in either automatic mode or manual mode. In automatic mode, the system performs the complete boot procedure on its own, without any external assistance. In manual mode, the system follows the automatic procedure up to a point but then turns control over to an operator before most initialization scripts have been run. At this point, the computer is in “single-user mode.” Most system processes are not running, and other users cannot log in.
In day-to-day operation, automatic booting is used almost exclusively. A typical boot procedure for a modern machine is to turn on the power