Mac OS X: Startup
This page briefly describes the sequence of events that happen when Mac OS X boots. Although the information presented here has been derived from both documentation and personal experimentation, I would not guarantee the correctness of it. Moreover, it is applicable to Jaguar (10.2.x). Panther (10.3.x) might (would almost certainly) have some differences.
The following things happen (more or less) when Mac OS X boots:
- Power is turned on.
- Open Firmware code is executed.
- Hardware information is collected and hardware is initialized.
- Something (usually the OS, but also things like the Apple Hardware Test, etc.) is selected to boot. The user may be prompted to select what to boot.
- Control passes to
/System/Library/CoreServices/BootX, the boot loader. BootX loads the kernel and also draws the OS badges, if any. - BootX tries to load a previously cached list of device drivers (created/updated by
/usr/sbin/kextcache). Such a cache is of the typemkextand contains the info dictionaries and binary files for multiple kernel extensions. Note that if the mkext cache is corrupt or missing, BootX would look in/System/Library/Extensionsfor extensions that are needed in the current scenario (as determined by the value of theOSBundleRequiredproperty in theInfo.plistfile of the extension's bundle. - The
initroutine of the kernel is executed. The root device of the booting system is determined. At this point, Open Firmware is not accessible any more. - Various Mach/BSD data structures are initialized by the kernel.
- The I/O Kit is initialized.
- The kernel starts
/sbin/mach_init, the Mach service naming (bootstrap) daemon. mach_initstarts/sbin/init, the traditional BSD init process. init determines the runlevel, and runs/etc/rc.boot, which sets up the machine enough to run single-user. During its execution,rc.bootsources/etc/rc.common, a shell script containing utility functions.rc.bootfigures out the type of boot (Multi-User, Safe, CD-ROM, Network etc.).rc.bootfigures out if a file system consistency check is required.- If
rc.bootexits successfully,/etc/rc, the multi-user startup script is then run. If booting from a CD-ROM, the script switches over to/etc/rc.cdrom(installation). /etc/rcmounts local file systems, starts BootCache, creates mach symbol file./etc/rcstartskextd, the daemon process that loads kernel extension on demand from kernel or client processes.- If
/System/Library/Extensions.mkextis older than/System/Library/Extensions,/etc/rcdeletes the existing mkext and creates a new one. It also creates one if one doesn't exist. /etc/rcstarts/usr/sbin/update, the daemon that flushes internal file system caches to disk frequently./etc/rcstarts the virtual memory system./private/var/vmis set up as the swap directory./sbin/dynamic_pageris started with the appropriate arguments (swap filename path template, size of swap files created, high and low water alert triggers specifying when to create additional swap files or delete existing ones)./etc/rcstarts/usr/libexec/fix_prebindingto fix incorrectly prebound binaries./etc/rcexecutes/etc/rc.cleanupto clean up and reset files and devices./etc/rcruns/usr/sbin/configd./etc/rcfinally launches/sbin/SystemStarterto handle startup items from locations such as/System/Library/StartupItemsand/Library/StartupItems. A StartupItem is a program, usually a shell script, whose name matches the folder name. The folder contains a property list file containing key-value pairs such asDescription,Provides,Requires,OrderPreference, start/stop messages etc.