- How To…
- Installing Mac OS X
- Exploring the Finder
- Configuring System Preferences
- Managing User Accounts
- Managing Files and Folders
- Securing Your Mac
- Application Tips & Techniques
- Utilities Tips & Techniques
- Apple Hardware
- Menu Master 1.2
- MacWireless 11g PC Card
- ChronoSync 3.0
- DejaMenu 1.2
- Endicia for Mac 2.5
- EyeTV 2.0
- VersionTracker Pro 4.1
- Squeezebox 3
- WhatSize 10.2.6
- AppZapper 1.3.1
- DeskPicture 10.02
- Full Tilt Poker
- Portable Handles
- PowerSquid Surge3000
- Firefox 2.0
- USB 2.0 Universal Drive Adapter
- Back-UPS RS 1500 LCD
- Google Desktop 22.214.171.124
- Google Earth 4
- OfficeTime 1.1
- iStat pro 4.01
- PTHPasteboard 4.2.0
- iBiz 3.1.5
- Iris 1.0
- Hazel 2.0.2
- Xspinner 1.0
- Apple Predictions For 2006
- Reviewing 2006 Predictions
- Apple Predictions for 2007
- The Broadband Battle
- Emulating Early Apples
- Tech Tips from a Trip Abroad
- Profiting from the "Macworld Effect"
- Macworld Expo 2007 Keynote
- Tired of Waiting for Apple
- Buying an External Hard Drive
- Things I Love About Leopard
- Macworld Expo 2008 Reflections
- Combo Update 10.5.2
- Things I Loathe About Leopard
Mac OS X Startup Sequence
Last updated Feb 25, 2005.
Most Macintosh users turn on their computers and wait for the Finder or login window to appear. That's all normal users need to know to begin working on a Macintosh computer. But power users and administrators benefit from understanding what goes on behind the scenes to run Mac OS X.
When the power is turned on, Mac OS X performs a series of tasks to prepare the system for operation. Visual and auditory cues help you follow the startup sequence. If something goes awry during startup, those cues can provide clues as to where the problem is and how to fix it. The following pages explain the Mac OS X startup sequence.
BootROM is a hardware component that contains the startup (boot) programs, which are the first processes that run when the computer is turned on. These programs include the Power-On Self Test (POST) and Open Firmware.
The Power-On Self Test checks basic hardware components for functionality. POST sets components such as the processor, random access memory (RAM), and crucial hardware interfaces to states expected by the system. In addition, POST verifies that the RAM is functioning to operating specifications.
If the system fails POST, the computer will beep one to five times. Error beeps may vary, depending on the computer model. If no sound is present, some models will flash an LED to indicate a failure. Search the Knowledge Base for the specific hardware error messages.
If the system passes POST, you will hear the normal startup chime.
Open Firmware initializes the rest of the hardware, builds the initial device tree (a hierarchical representation of devices associated with the computer), and selects the operating system to use.
Open Firmware also checks whether startup modifier keys have been pressed, and takes the appropriate action.
When the Open Firmware startup program in BootROM locates and selects the Mac OS X operating system, it transfers control to BootX (a process that Open Firmware starts from /System/Library/CoreServices on the startup disk). The primary task of BootX is to initialize the kernel environment and the drivers (such as the drivers for I/O buses) needed to boot the system. In addition, BootX starts up the kernel initialization process.
When Open Firmware attempts to find BootX, one of the following icons will appear, indicating these results:
- Metallic Apple logo: Found BootX
- Circle with slash: Could not find BootX on the startup volume
- Flashing square with globe: Looking for BootX on a remote disk via the network
- Small metallic spinning globe: Found BootX on network
- Flashing question mark over a folder or floppy disk icon: Open Firmware did not find a startup disk (locally or on a network)
If Mac OS X components have been renamed or moved from the root level of the startup disk, a broken folder icon will appear. A black belt may appear around a folder icon if a Mac OS 9 restore has been installed incorrectly using the Restore discs that came with the computer.
When loading the kernel environment, BootX first attempts to load a previously cached set of device drivers. If this cache is missing or corrupt, BootX searches /System/Library/Extensions for drivers and other kernel extensions whose OSBundleRequired property is set to the appropriate value for the type of boot. (This is either a local or network boot, depending on the current selection in Startup Disk preferences.) You can recognize this stage by the metallic Apple logo and the spinning gear that appear on the screen.
The kernel initializes the Input/Output Kit (I/O Kit), which controls input and output devices. The I/O Kit links the loaded drivers into the kernel based on the device tree previously created by Open Firmware.
The kernel starts the launchd process, and the launchd process is then responsible for bootstrapping the rest of the system.
New in Mac OS X 10.4, the launchd process manages daemons, both for the system as a whole and for individual users. A daemon is a continuously running program, which exists for the sole purpose of managing service requests that the computer system expects to receive. The daemon forwards the requests to the appropriate processes. launchd manages daemons, both for the system as a whole and for individual users.
During startup, launchd scans the LaunchDaemons and LaunchAgents folders in both /System/Library and /Library for plist files. Each plist file represents a process that launchd needs to manage. The contents of the plist file specify the location of the code that should be run and when the process should be launched.
Unlike startup items, which are always launched during the initial startup sequence, launchd items are intended to launch only when needed. This reduces the number of processes running, which in turn, helps increase system performance and reduce the initial startup time.
Startup Scripts and Startup Items
After launchd executes successfully, it runs the /etc/rc script to perform basic system initialization tasks. These initialization tasks include a file-system consistency check (fsck) and starting a process called SystemStarter, which launches the startup items.
Startup items are processes that run during the last phase of the startup sequence to prepare a Mac OS X system for normal operation. Startup items consist of programs, including customizable shell scripts, that perform tasks such as starting additional system daemons.
System startup items are located in /System/Library/StartupItems, and consist of folders each containing (at a minimum) one program (typically a shell script) whose name matches the folder's name, and a configuration property list (plist) file that the shell script reads when the startup item loads.
As mentioned earlier, launchd items are intended to replace startup items. However, Mac OS X 10.4 still supports startup items to provide compatibility with existing software.
Launchd items, startup items, and any applications that launch before the loginwindow process are referred to as system processes. These applications provide services to all users of the system and are usually children of launchd. (A child process is a process that is started by another process, which is called its parent.) Processes created after the launching of loginwindow are referred to as user processes. User processes are always associated with a particular user session, and are usually children of the session's Window Manager process. You specify which user processes to launch after login in the Login Items pane of Accounts preferences.
Many startup scripts rely on system configuration information stored in /etc/hostconfig. Some of the entries in hostconfig specify whether certain services should be started when the computer starts up. For example, when you turn on Personal Web Sharing, the Services pane of Sharing preferences sets an entry in hostconfig. When the Apache startup item executes during system startup, it checks hostconfig to determine if it should start the Apache web server.
By the time the user logs in to a Mac OS X system, a number of processes are already running. Most of these processes are daemons or processes created by the system that run in the background. In addition to those started by launchd and startup scripts, a handful of processes are created on behalf of the user by the loginwindow process and the Window Manager daemon.
The loginwindow Process
Login occurs after system initialization with the appearance of the login window. The loginwindow process coordinates the login process and the individual user's session, calling on other system services as needed. Depending on the user's login preferences, the login window may prompt the user for a valid login name and password, or may use cached values to log in the user automatically. When the user's login name and password have been authenticated, loginwindow proceeds to load the user environment.
When the user logs in, loginwindow does the following:
- Loads the user's computing environment, including preferences, environment variables, device and file permissions, keychain access, and so on
- Launches the Dock, Finder, and SystemUIServer
- Launches the Setup Assistant if an installation is in progress
- Automatically launches applications specified in the Login Items pane of Accounts preferences
When all of these applications are launched and running, the login procedure is complete.
The loginwindow application uses Launch Services to launch all applications, including the Finder, Dock, SystemUIServer, and user-specified applications. Most applications in the user session run as child processes of the Window Manager process. They are not owned by loginwindow.
Once the user session is running, loginwindow monitors the session and user applications in the following ways:
- Manages logout, restart, and shutdown procedures
- Manages the Force Quit window, which includes monitoring the currently active applications, responding to user requests to force quit applications, and relaunching the Finder
- Displays alert dialogs when a notification is received from hidden applications (applications not visible in the user interface)
- Writes any standard error (stderr) output to /Library/Logs/Console/user/console.log (where user is the short name), which is then used as input by the Console application
- Saves a limited archive of logs in console.log.# files within the same folder, where # is a number from 0 through 9, which are all viewable in the Console application under /Library/Logs > Console > user
User Environment Setup
Mac OS X requires user authentication prior to accessing the system. Although the loginwindow application manages the user authentication process, it does not itself authenticate the user. The loginwindow application passes the information specified in the login window to Open Directory for authentication. When Open Directory authenticates the user, loginwindow initiates the user session and displays the status bar, along with the text "Logging In."
When a user logs in to the system, the loginwindow application sets up the user environment and records information about the login. It also configures the mouse, keyboard, and system sound using the user's preferences, and retrieves the user record from Open Directory.