The Boot Sequence

The Boot Sequence

As anyone who's turned on a computer knows , a computer has to go through a series of steps before it becomes generally available for use. This process is called booting , which is short for bootstrapping itself an abbreviation of "pulling itself up by its own bootstraps." Booting involves a sequence of starting software that in turn launches other software, and so on, until eventually the entire operating system is loaded.

Though you may not have cared about this sequence before, it's useful to know what the steps are when you're administering a machine. We'll give you an overview of the fundamental layers of software involved, and of the various places where something can go awry.

Every type of operating system has a somewhat different boot process, and this includes different flavors of Unix.

The Mac OS X boot sequence is based on launchd a daemon that manages other daemons. We had a lot to say about launchd earlier in this chapter in the section "Running Regularly Scheduled Commands."

The official Apple documentation of the Mac OS X boot sequence is at http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/BootProcess.html.

Here's an abbreviated version:

1.
When the power comes on, a part of the hardware called the BootROM performs a test of the hardware (Power On Self Test, or POST) and runs a piece of software called Open Firmware. This is the software that selects which operating system to use. In older Macs, Open Firmware can boot into either Mac OS 9 or Mac OS X, but the latest Macs can only boot into Mac OS X.

2.
Once BootROM or the user has selected Mac OS X, the next piece of software to take over is the BootX booter, located in /System/Library/CoreServices . The system is now using software from the disk. If the cache of device drivers is out of date or corrupted, BootX will search /System/Library/Extensions for software drivers needed to communicate with various hardware devices. BootX then runs the kernel of the operating system: /mach_kernel .

3.
The kernel now runs launchd , which is the first process, process ID 1. Prior to Mac OS X 10.4, the kernel would run mach_init . But starting with Mac OS X 10.4, launchd is used instead.

4.
The launchd daemon manages many other daemons both during startup and throughout the system's uptime. launchd keeps running until the system is shut down.

See man launchd and the various launchd configuration files in /System/Library/LaunchDaemons .

Figures 11.31 and 11.32 show two launchd configuration files from the /System/Library/LaunchDaemons directory. Figure 11.31 shows

com.apple.periodic-weekly. plist

which causes launchd to run the command line

/usr/sbin/periodic weekly

at 3:15 a.m. every Saturday (day 6). See "Scheduling jobs using launchd ," earlier in this chapter, for more on the use of launchd to schedule running commands.

Figure 11.31. Contents of the launchd configuration file /System/Library/LaunchDaemons/com.apple.periodic-weekly.plist .
 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict>   <key>Label</key>   <string>com.apple.periodic-weekly</string>   <key>ProgramArguments</key>   <array>        <string>/usr/sbin/periodic</string>        <string>weekly</string>   </array>   <key>LowPriorityIO</key>   <true/>   <key>Nice</key>   <integer>1</integer>   <key>StartCalendarInterval</key>   <dict>        <key>Hour</key>        <integer>3</integer>        <key>Minute</key>        <integer>15</integer>        <key>Weekday</key>        <integer>6</integer>   </dict> </dict> </plist> 

Figure 11.32. Contents of the launchd configuration file /System/Library/LaunchDaemons/org.postfix.master.plist .
 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict>   <key>Label</key>   <string>org.postfix.master</string>   <key>Program</key>   <string>/usr/libexec/postfix/master</string>   <key>ProgramArguments</key>   <array>        <string>master</string>        <string>-e</string>        <string>60</string>   </array>   <key>QueueDirectories</key>   <array>        <string>/var/spool/postfix/maildrop</string>   </array> </dict> </plist> 

Figure 11.32 shows the configuration file

org.postfix.master.plist

which starts the Postfix e-mail server daemon /usr/libexec/postfix/master with an option of -e 60 (this causes the daemon to expire after 60 seconds of idle time). The QueueDirectories property tells launchd to watch the directory /var/spool/postfix/maildrop and restart the daemon if anything appears inside that directory.

See "Creating New LaunchDaemons and StartupItems," later in this chapter, for details on creating a new launchd configuration to start and manage a system daemon.

5.
Another step taken by launchd is running the script /etc/rc , which in turn runs the SystemStarter program. Apple intends to phase out the use of /etc/rc at some point in the future.

6.
SystemStarter runs a series of scripts found in /System/Library/StartupItems and /Library/StartupItems .

The scripts in /System/Library/StartupItems are supplied by Apple, and you should not change them. The /Library/StartupItems directory is where you may install scripts of your own to launch daemons or other commands at system startup. However, Apple is moving away from SystemStarter , and, as of Mac OS X 10.4, Apple recommends that you use launchd instead. See "Creating New LaunchDaemons and StartupItems," later in this chapter.

7.
After launchd has finished starting the system daemons configured in /System/Library/LaunchDaemons and the legacy StartupItems have been run, launchd starts a process called loginwindow , which provides a graphical dialog and handles authenticating users. An administrator can configure Mac OS X to bypass user authentication (using Login Options in the Accounts pane of System Preferences) by having the system automatically log in as a specified user on startup; this is the default on a freshly installed Mac OS X system.



Unix for Mac OS X 10. 4 Tiger. Visual QuickPro Guide
Unix for Mac OS X 10.4 Tiger: Visual QuickPro Guide (2nd Edition)
ISBN: 0321246683
EAN: 2147483647
Year: 2004
Pages: 161
Authors: Matisse Enzer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net