How to manage OS X boot options with wireless keyboards

If you have a Bluetooth keyboard, OS X may ignore keystrokes at startup for booting into Safe mode and other optional boot environments.

Apple offers several alternative boot environments for OS X that can help you troubleshoot problems you might be experiencing, which can be invoked by holding various key combinations at startup. Of these, Safe Mode is perhaps the most common; it offers a limited boot environment and can be started by holding the Shift key. In addition there is Single User mode (Command-S) for a command-line interface, Apple's hardware diagnostics tests (the "D" key), Target Disk mode (the "T" key), and holding the Option key will bring up the boot loader for choosing a startup disk.

These options can be invoked by holding their respective key combinations immediately when powering on the system; however, if you use Apple's Bluetooth keyboard, you could find that the system may ignore these inputs and boot normally. While you might assume that these options require a USB keyboard or other physical connection, this is not always the case. There are a couple of workarounds if you find yourself in this situation.

Apple's Bluetooth hardware controllers activate after all of the system's self-tests at boot complete and the EFI firmware loads successfully, which is indicated by the system playing the standard Mac startup sound. It is at this point that the system will accept boot variables, either stored in the PRAM or those being sent via keyboard inputs. These are then passed to the OS X kernel to invoke the desired startup sequence.

If any inputs are being sent via the Bluetooth keyboard before the controllers are active, then they will not be recognized by the system. However, if these inputs are performed after the controllers are activated, then they will be properly read. Therefore, for Bluetooth keyboards, be sure to press the desired key sequences after you hear the boot chimes and not before.

While this approach for wireless keyboards should work, it may not in all situations. Should that happen, you can try various alternative approaches, such as using a spare USB keyboard to connect and send the desired boot argument to your system. Alternately, you can manually adjust the system's PRAM variables to invoke these boot arguments the next time the system starts up.

Setting the boot arguments PRAM variable requires administrative access, and is done from the Terminal using the following command:

sudo nvram boot-args="VALUE"

In this command, the VALUE component is one or more of the following flags separated by spaces, that will tell the kernel to load in the corresponding way:

-s -- Single User Mode
-v -- Verbose Mode
-x -- Safe Mode
rd=DISKID -- force booting to a specific partition.

In the "rd=DISKID" option, DISKID is a BSD device ID such as "disk0s1" for the first partition or "slice" of the disk0 device. The DISKID value can also be "*hd:NUMBER" where NUMBER is the partition of the drive to use as the boot volume. For example, if you would like to load the system in Single User mode and boot from the first partition on the second hard drive in the system, then you would issue the following version of the command:

sudo nvram boot-args="-s rd=disk1s2"

OS X Startup Disk system preferences
The Target Disk mode and startup disk can be set in the system preferences, which may be preferable to using Terminal commands. Screenshot by Topher Kessler/CNET

The "boot-args" variable can be used for setting the above modes. but in addition if you need to load the system into Target Disk mode, you can do so by setting the "target-mode" PRAM variable in the following way (this will be enabled only once for the next time the system is started):

sudo nvram target-mode=1

The option for rebooting the system into Target Disk mode or choosing an alternative boot partition can be done in the Startup Disk system preferences pane, so using the Terminal for these options is not a requirement for those with wireless keyboards. If you want to boot to Safe, Verbose, or Single User modes and cannot do so at startup with a key command, you will need to use one of these Terminal command options.

A final word of note when adjusting PRAM values is how to revert any changes you make. By default the PRAM variables mentioned here are empty, so you can delete them by running the following commands:

sudo nvram -d boot-args

sudo nvram -d target-mode

A final approach to clearing these is to simply reset the system's PRAM by rebooting and holding down the Option-Command-P-R keys at startup. Again for a Bluetooth keyboard, this needs to be done after you hear the boot chimes, or using an alternative keyboard.



Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.

About the author

    Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.

     

    Join the discussion

    Conversation powered by Livefyre

    Show Comments Hide Comments
    Latest Galleries from CNET
    Uber's tumultuous ups and downs in 2014 (pictures)
    The best and worst quotes of 2014 (pictures)
    A roomy range from LG (pictures)
    This plain GE range has all of the essentials (pictures)
    Sony's 'Interview' heard 'round the world (pictures)
    Google Lunar XPrize: Testing Astrobotic's rover on the rocks (pictures)