How to easily switch between startup volumes

startup pref

Reader Robert Kapp would like a shortcut for a tedious task. He writes:

I haven’t fully committed to running OS X Yosemite on my Mac, but I do it often enough that I find myself having to change from my Mavericks startup disk to the Yosemite disk every couple of days. Is there a faster way to do this than through the Startup Disk system preference?

There is. I bounce between a couple of startup volumes each day and, like you, I find the required journey to this system preference a little tiresome. Because I do, I’ve created an AppleScript application that goes a little something like this (copy and paste it into the AppleScript Editor app):

do shell script ¬
	¬
		"bless -mount \"/Volumes/name of volume\" -setBoot" with administrator privileges
tell application "Finder"
	restart
end tell

Replace “name of volume” with the name of the drive you want to boot from. For example, if you’re running the script from your Mavericks volume (which you’ve named “Mavs”) and want to boot from the Yosemite volume you’ve named “Macintosh HD,” the first bit would read:

"bless -mount \"/Volumes/Macintosh HD\" -setBoot" with administrator privileges

The first bit of the script asks for your administrator password so that it can change startup volumes. The restart command is there to ensure that you’re prompted to save any unsaved changes in open applications before the Mac restarts.

choose volume applescript

As seen in AppleScript Editor.

You’ll want to create two copies of this—one for the Mavericks volume to boot into Yosemite, and another for the Yosemite volume to boot into Mavericks. Save each one as an application and place them on the appropriate drive. When you’re ready to switch, just double-click the appropriate copy of the app you created.

property targetVolumePath : "/Volumes/name of volume"

set AppleScript's text item delimiters to "/"
set targetVolumeName to last text item of targetVolumePath
set AppleScript's text item delimiters to ""

set dialogPrompt to "This script will reboot this computer to volume “" & targetVolumeName & "”." & return & return

do shell script "bless -mount " & (quoted form of targetVolumePath) & " -setBoot" with prompt dialogPrompt with administrator privileges

tell application "System Events"
	restart with state saving preference
end tell

This takes advantage of two AppleScript features introduced with Yosemite—the “with prompt” parameter and the “save state” option. The first allows us to create the prompt that tells you what will happen when the app runs. The second allows you to configure how things are saved when the app restarts or shuts down your Mac.

yosemite boot to mavs

The fancier Yosemite version with prompt.

Have a question of your own? Drop a line to mac911@macworld.com.

To comment on this article and other Macworld content, visit our Facebook page or our Twitter feed.
Related:
Shop Tech Products at Amazon
Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.