Boot argument options in OS X

When you boot your system you you can the keyboard at startup to alter the boot behavior. A common option is to hold the Shift key to boot to Safe Mode, but you can also hold Command-V for verbose mode or Command-S for Single User mode.

In addition to keyboard commands at startup, you can use the “nvram” terminal command to set a number of different boot options, which might be useful when troubleshooting your Mac. Apple’s machines have a number of hidden boot options that you can use, though do keep in mind that most of these are for troubleshooting purposes and will only be useful to programmers.

sudo nvram boot-args="[options]"

for example:

sudo nvram boot-args="-v"
Set the system to Verbose mode, similar to Command-V at startup.

sudo nvram boot-args="-x"
Boot into Safe Mode. Boots your system with the bare minimum kexts.

sudo nvram boot-args=”-s”
Boot into Single user mode, similar to Command-S at startup. Command line only mode. Allows you to run commands as root to fix system.

sudo nvram boot-args="arch=x86_64"
On Snow Leopard system, even though a 64-bit kernel is available, the system boots to the 32-bit one by default. This command will change this so the system always boots to the 64-bit kernel. To change systems to always boot to a 32-bit kernel, replace the “x86_64” section of the command with “i386.” In some instances, third-party kernel extensions might be 32-bit or 64-bit only, which will require booting to the respective kernel type in order to load.

sudo nvram boot-args="maxmem=32"
Limits the addressable memory to the specified amount, which in this case is 32GB. Without it, the system sets the memory limit to either the maximum that the hardware can address, or to the amount that is installed.

sudo nvram boot-args="cpus=1"
Limits the number of active processors in the system to the set level. Apple’s developer tools have an option to enable or disable some of the CPUs on the system, but you can do this manually by running this command and specifying the number of CPU cores to use. In some cases, such as with laptop systems, this might help preserve power, though is likely not useful for much else unless you are testing and programming.

sudo nvram boot-args="iog=0x0"
This reverses the “Clamshell” mode for Apple’s laptop systems, where when you close the display but connect the system to an external monitor and keyboard the system will stay awake. After running this command, when connecting an external monitor, the internal display will be disabled, which can be beneficial in some situations such as those where you are mirroring your desktop but wish to run the external display at a higher resolution than your laptop can run.

sudo nvram boot-args="srv=1"

This is set on Xserves and machines that have Mac OS X Server installed, and supposedly changes some kernel tuning parameters for server-friendly operation.

sudo nvram boot-args="_panicd_ip=a.b.c.d"
Lets you specify the IP address of a panic debug server to write kernel core dumps to.

sudo nvram boot-args="debug=0x144"
This is a combination of kernel debugging features to display extra information about the kernel’s processes, which can be useful in case of kernel panics. Another option is to use debug=0x14e. Alternative debug options are the following:

0x1 DB_HALT:
Halt at boot time and wait for a debugger connection.

0x2 DB_PRT:
Send kernel-debugging output generated by the kernel’s printf() function to the console.

0x4 DB_NMI:
Enable the kernel-debugging facility, including support for generating a nonmaskable interrupt (NMI) without a physical programmer’s switch. On a Power Mac, an NMI can be generated by briefly pressing the power button. On a notebook computer, the command key must be held down while pressing the power button. If the power button is held down for more than five seconds, the system will power off. The DB_NMI bit is cleared if you use System Preferences to change the startup disk.

0x8 DB_KPRT:
Send kernel-debugging output generated by kprintf() to the remote output device, which is typically a serial port (if one is available). Note that kprintf() output is synchronous.

0x10 DB_KDB:
Use KDB instead of GDB as the default kernel debugger. Unlike GDB, KDB must be explicitly compiled into the kernel. Moreover, KDB-based debugging requires native serial port hardware (as opposed to, say, USB-based serial port adapters).

0x20 DB_SLOG:
Enable logging of miscellaneous diagnostics to the system log. For example, the load_shared_file() kernel function logs extra information if this bit is set.

0x40 DB_ARP:
Allow the kernel debugger nub to use ARP, allowing debugging across subnets.

0x80 DB_KDP_BP_DIS:
Deprecated. Used for supporting old versions of GDB.

0x100 DB_LOG_PI_SCRN:
Disable the graphical panic screen so that panic data can be logged to the screen. It is also useful for monitoring the progress of a kernel core dump transmission.

0x200 DB_KDP_GETC_ENA:
Prompt for one of the c, r, and k characters to continue, reboot, or enter KDB, respectively, after a kernel panic.

0x400 DB_KERN_DUMP_ON_PANIC:
Trigger core dump on panic.

0x800 DB_KERN_DUMP_ON_NMI:
Trigger core dump on NMI.

0x1000 DB_DBG_POST_CORE:
Wait for a debugger connection (if using GDB) or wait in the debugger (if using KDB) after an NMI-induced core dump. If DB_DBG_POST_CORE is not set, the kernel continues after the core dump.

0x2000 DB_PANICLOG_DUMP:
Send only a panic log, not a full core dump on panic.

Others found:

artsize
Specifies the number of pages to be used for the address resolution table (ART).

BootCacheOverride
The BootCache driver is loadedbut does not runin the case of a network boot. Setting BootCacheOverride=1 overrides this behavior.

ctrc
Limits tracing to a specific processor (see the tb argument).

dart
Setting dart=0 turns off the system PCI address mapper (DART) on 64-bit hardware. DART is required on machines with more than 2GB of physical memory but is enabled by default on all machines, regardless of their memory sizes.

debug
Specifies a variety of debug flags including those for kernel-debugging behavior. See Table 413 for details of these flags.

diag
Enables the kernel’s built-in diagnostics API and its specific features.

fhrdl1
Setting fhrdl1=1 forces hardware recovery of data cache level 1 (L1 D-cache) errors. Deprecated (see the mcksoft argument).

fill
Specifies an integer value that is used to fill all memory pages at boot time.

fn
Alters the processor’s force-nap behavior. Setting fn=1 turns force-nap off; setting fn=2 turns force-nap on.

_fpu
Disables FPU features on the x86. A string value of 387 disables FXSR/SSE/SSE2, whereas a string value of sse disables SSE2.

hfile
Name of the hibernate file (also stored in the kern.hibernatefile sysctl variable).

io
Specifies I/O Kit debugging flags. In particular, setting the kIOLogSynchronous bit (the value 0x00200000) ensures that the IOLog() function will complete synchronously. Normally, IOLog() output goes to a circular buffer that is emptied periodically.

kdp_match_mac
Specifies a MAC address that is to be used by the remote kernel-debugging protocol.

kdp_match_name
Specifies a BSD network interface name that is to be used by the remote kernel-debugging protocol.

mcklog
Specifies machine check flags.

mcksoft
Setting mcksoft=1 enables machine check software recovery.

novmx
Setting novmx=1 disables AltiVec.

_panicd_ip
Specifies the IP address of a remote kernel-core-dump server machine, which is expected to be running the kdumpd daemon on UDP port 1069.

pcata
Setting pcata=0 disables the onboard PC ATA driver. This may be useful during developmentfor example, if a polled-mode driver is to be loaded.

platform
Specifies a string to be used as the platform name in the fake device tree on the x86. The default platform name used is ACPI.

pmsx
Setting pmsx=1 enables the experimental Power Management Stepper (PMS) mode introduced in Mac OS X 10.4.3.

romndrv
Setting romndrv=1 allows a native graphics driver (ndrv) to be used even if its creation date is older than a predefined minimum date, which is March 1, 2001.

_router_ip
Specifies the router through which the remote kernel-debugging protocol is to be routed while transmitting kernel core dumps to a remote machine.

serial
Setting serial=1 enables the serial console.

serialbaud
Specifies the baud rate for the serial port. The initialization routine for the kprintf() function checks this argument.

smbios
Setting smbios=1 enables detailed log messages in the SMBIOS driver. An x86-only argument.

tb
The kernel supports event tracing to a circular in-memory buffer. A nondefault trace buffer size can be specified through the tb argument. By default, the kernel uses 32 pages in debug mode and 8 pages in nondebug mode. The minimum and maximum values are 1 and 256 pages, respectively.

vmdx, pmdx
Cause the kernel to attempt to create a memory disk at boot time. Used as vmdx=base.size, where x is a single-digit hexadecimal number (0f), base is a page-aligned memory address, and size is a multiple of the page size. The v specifies virtual memory. A p can be used instead to specify physical memory. If the creation is successful, device nodes /dev/mdx and /dev/rmdx will appear after boot.

vmmforce
Specifies virtual machine monitor (VMM) features as a logical OR of feature bits. The features so specified are enforced for all virtual machine instances.

wcte
Setting wcte=1 enables the write combine timer (or store gather timer) in the PowerPC noncacheable unit (NCU). By default, this timer is disabled.

-b The kernel sets RB_NOBOOTRC in its reboot flags variable to indicate that /etc/rc.boot should not be run. Deprecated.

-D mach_init starts in normal mode. Core dumps are not taken for launched servers. Deprecated.

-d mach_init starts in debug mode, with extensive logging. Core dumps are taken for any launched servers that crash. On Mac OS X 10.4 or newer, this argument causes the launchd program to daemonize early during its initialization.

-F mach_init forks during initialization. Note that it always forks if its process ID is 1. Deprecated.

-f This argument is passed to the init program to indicate that a fast boot is desired. Deprecated.

-r mach_init registers itself in a previously running copy of itself. Deprecated.

In addition you can check for ex http://www.opensource.apple.com/release/os-x-10102/

or more particular the XNU kernel for ex: http://www.opensource.apple.com/source/xnu/xnu-2782.10.72/bsd/kern/bsd_init.c

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s