This document describes the boot-time loading of kernel extensions (KEXTs) in Mac OS X. In particular, it focuses on the BootX booter and its use of the KEXT property OSBundleRequired
. If you are not familiar with the boot sequence or if you would like more information on booting and system and kernel initialization, see System Startup Programming Topics. More information on KEXTs and their information property lists can be found in I/O Kit Fundamentals.
The BootX Booter
Safe Booting
The Mkext Cache
The OSBundleRequired Property
In order to mount the root file system, the kernel must contain the KEXTs that drive the hardware required to access the root volume. Rather than building these KEXTs into the kernel, Mac OS X provides for boot-time loading of KEXTs by the BootX booter. This is accomplished in part through use of the OSBundleRequired
property in the root dictionary of the KEXT’s information property list (Info.plist
file). The BootX booter, the KEXT loading utility kextd
, and the KEXT caching utility kextcache
use the OSBundleRequired
property to determine which KEXTs are necessary to load or cache.
Important:
It is essential that only those KEXTs required for hardware in the boot process and the minimal set of KEXTs required to operate the system’s user interface include the OSBundleRequired
property in their Info.plist
files. See “The OSBundleRequired Property” for information on how to set this property to the correct value.
Near the beginning of the boot sequence for Mac OS X, the BootX booter receives control from BootROM which has initialized the system hardware and selected an operating system to boot. BootX’s primary responsibility is to load the kernel environment. To do this, BootX first attempts to load a previously cached set of device drivers (called an mkext cache) for hardware that is in the boot process. If this cache is missing or corrupt, BootX searches /System/Library/Extensions
for KEXTs whose OSBundleRequired
property is set to a value appropriate to the type of system boot (see Table 1 for a complete list of values used with this property). For example, if BootX is performing a network boot, it will look for KEXTs whose OSBundleRequired
property is set to “Network-Root”. When booting in single-user mode, BootX will load those KEXTs whose OSBundleRequired
property is set to “Console”, in addition to loading the KEXTs required to mount the root file system. BootX ignores all KEXTs whose OSBundleRequired
property is set to “Safe Boot” and all KEXTs whose Info.plist
files do not contain this property at all.
After the root file system is mounted, kextd
starts and examines all the drivers available on the system. At this point, any unnecessary drivers get unloaded, freeing up memory; and kextd
attempts to fulfill any KEXT loading requests it receives.
The OSBundleRequired
property is also used to facilitate safe-boot mode in which all unnecessary extensions are disabled. During a safe boot, BootX loads the KEXTs required to mount the root file system just as in other modes of booting. Then kextd
starts and examines all the drivers on the system. If this is a safe boot, however, kextd
will only consider loading a KEXT if the OSBundleRequired
property is present in its Info.plist
file. This preserves the integrity of the safe boot by ensuring that only drivers necessary for mounting root or operating the system’s user interface are loaded.
Safe booting helps protect the system from the possible panic of a driver. If a driver’s OSBundleRequired
property is set to “Root”, it will always be loaded by BootX, even in single-user or safe-boot modes. If this driver panics, the system itself may panic, requiring reinstallation of the operating system or booting off a CD. If the same driver’s OSBundleRequired
property is set to “Safe Boot”, however, it will never be loaded by BootX. kextd
will load it after the root file system has been mounted and if the driver panics it can be disabled by re-booting into single-user mode and then using the console to move it out of the way. The safe boot can then be restarted without the panicking driver.
Note: During the development phase of your driver, you may find it useful to set the IOKitDebug
key in your driver’s personality to a nonzero value. If you do so, that driver personality will not be sent to the kernel during a safe boot. If all of your driver’s personalities have nonzero IOKitDebug
values, the KEXT itself will not even be loaded into the kernel during a safe boot.
To initiate a safe-boot, hold down the Shift key while restarting the computer.
The mkext cache is created by the kextcache
utility which takes a directory of KEXTs and archives it into a compressed binary form suitable for putting in ROM or other confined space. The utility kextcache
also makes use of the OSBundleRequired
property when determining which KEXTs to cache. When being used to create a net-boot repository, kextcache
includes all KEXTs with OSBundleRequired
set to “Root”, “Network-Root”, or “Console”. When being used to create a local-boot repository, kextcache
will include all KEXTs with OSBundleRequired
set to “Root”, “Local-Root”, or “Console”. The default behavior of kextcache
is to create a full cache of all KEXTs it is given. For a complete description of the use of this utility, access the Terminal application in Mac OS X (located in /Applications/Utilities/
) and type man kextcache
.
The OSBundleRequired
property should appear in the root dictionary of a KEXT’s Info.plist
if that KEXT is required to mount the root file system (such as a platform driver) or is required to operate the system’s user interface (such as a mouse or graphics driver). A driver that does not fall into either category (for example, an audio driver) should not include the OSBundleRequired
property in its Info.plist
at all. Such a driver will be loaded by kextd
as needed unless booting in safe-boot mode (see “Safe Booting” for an explanation of this process).
For KEXTs that do include this property, it is essential that it be set to the appropriate value. As explained in “Safe Booting,” a KEXT whose OSBundleRequired
property is set to “Root” will always be loaded by BootX when it attempts to mount the root file system. Therefore, unless a KEXT is absolutely required to mount root, its OSBundleRequired
property should not be set to “Root”.
Table 1 matches the values of the OSBundleRequired
property with descriptions of the KEXTs that should use them. If a KEXT does not fit any of these descriptions, it should not include the OSBundleRequired
property in its Info.plist
file.
© 2003, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-31)