How to quickly switch between Mavericks and Yosemite beta

By , Jul 29, 2014

how-to-switch-os-header

Following Apple’s release of a public beta of OS X Yosemite, iDB reader Antony Verros sent us some code he wrote in AppleScript, which allows users to quickly restart a computer and automatically boot up in the installed OS of choice. For anyone who installed the OS X Yosemite beta on a separate partition, this is an easy solution for booting up into Yosemite or Mavericks without having to hold down the Option key on boot to select the desired partition. The script can even be tweaked to work with BootCamp.

While it’s mostly a matter of time-saving convenience, this method can prove to be quite advantageous over time, particularly for users who find themselves frequently switching between OSs, whether it be a Yosemite beta, Mavericks, or Windows 7. Having an easily accessible application for booting into another OS while making a sandwich or refilling a cup of coffee, versus having to wait around to hold down Option, can be highly useful…

Step 1: To begin, open Script Editor (Applications > Utilities > Script Editor.app) on your Mac and make a new document.

Step 2: Paste the following code into a blank AppleScript document. I realize the code is running slightly off the page, but selecting it, copying it, and then pasting it into Script Editor should work regardless.

set deviceID to (do shell script "diskutil list | awk '/Yosemite/ {print $NF}'")
do shell script "bless -device /dev/" & deviceID & ¬
" -setBoot -nextonly" with administrator privileges
tell application "Finder" to restart

In the first line, change “Yosemite” to the name of the partition on which the OS you want to automatically boot into is installed. For example, your main OS is likely installed on “Macintosh HD,” so to boot into Mavericks on Macintosh HD, the first line would read:

set deviceID to (do shell script "diskutil list | awk '/Macintosh HD/ {print $NF}'")

I have OS X Yosemite installed on a SSD drive, aptly named “SSD”, so my application looks like the screenshot below.

how-to-switch-os-applescript

Step 3: Save the script as an application with a name of your choice (I named mine “Switch to Yosemite”). You can then store it in a convenient location, such as on your desktop or in a stack on your dock.

Note 1: Running the app will throw up an administrator password dialog each time, but this can be avoided by adding in the word “password” and your administrative password in the third line of code. The downside to this is that there’s no stopping your computer from rebooting if you accidentally trigger the application. However, if that’s not a concern for you, skipping the password dialog box is certainly convenient.

do shell script "bless -device /dev/" & deviceID & ¬
" -setBoot -nextonly" password MyPassword123 with administrator privileges

Note 2: The code for booting into Windows on BootCamp is slightly different, as it adds ” -legacy” just before ” -setBoot.” Again, be sure to change the directory from “BOOTCAMP” if your partition uses a different name, and refer to Note 1 for instructions on how to remove the administrative password prompt.

set deviceID to (do shell script "diskutil list | awk '/BOOTCAMP/ {print $NF}'")
do shell script "bless -device /dev/" & deviceID & ¬
" -legacy -setBoot -nextonly" with administrator privileges
tell application "Finder" to restart

Note 3: If you keep one or more variations of these scripts in a visible place such as your desktop or dock, you may want to consider changing the application’s icon to something more attractive and “glanceable” than the default AppleScript scroll, which you can easily do with this guide.

I recommend configuring scripts to switch among all the OSs on your computer and placing them appropriately in each system partition to take full advantage of the convenience this method offers. If you’re feeling adventurous, you might try using Automator to set up triggers for running the script to further streamline your workflow.

What do you think of this technique? Have you written any scripts of your own? Feel free to send them to timothy@idownloadblog.com or share them in the comments below, and we may feature them in future articles on iDB.

  • Share:
  • Follow:
  • https://twitter.com/aidanharris1 Aidan Harris

    Neat bit of code but it’s easy enough to restart in the “Startup Disk” section of “System Preferences” or simply hold the alt button down when booting…

    • Tony

      I do the same. :)

  • Tony Trenkle Jr.

    This article needs to be renamed to include (For those who installed on a separate partition)

    • Guest

      so for example I could use this, in order to quickly switch between mavericks and my windows 8 partition right?

  • CS

    10.10 beta on my SSD partition and am loving it so far. For me, it isn’t near as bad as others have said. Mac mini 8gb of ram on a samsung SSD is just as stable as mavericks :P

  • Yujin

    I have installed it and been playing with it. I have yet to install applications to see what works and what format. It so far it seems very stable. Having it on a totally different partition is great as you can easily switch, but as always back up everything before just in case you get any issues with your partition

  • Tom Mermul

    since i installed yosemite on another partition, i cannot choose between mavericks, yosemite and windows if i hold down alt.
    all i have is 2 recovery and the yosemite partition.
    and my windows says no boot up device, while booting.

  • K_pow3ll

    I’ve tried everything every article and still unable to create a seperate partion on my late 2013 15 retina MacBook Pro. It always says partion failed every time

  • longeroute

    Make sure you bracket the password with quotations (i.e: “password”). Otherwise the code wont work. Thanks for this hack

  • Jse Lopez P

    Since I installed Yosemite on a separate partition, I can´t switch to Mavericks, I´ve tried going to Startup Disk, but it does´t show me the other partition (the one of Mavericks). Can someone please help me?

    • jaysoncopes

      If all of your files from Mavericks were imported to Yosemite without you doing anything:

      You didn’t install a separate partition, you upgraded Mavericks.

      Otherwise:

      It’s impossible to know the different variations of problems that could be going on. Sorry.

  • Benjamin Sasso

    I installed Yosemite on an external drive, how must I edit the script to be able to boot from it? I tried /Volume/Yosemite but did not work.

    • Kr00

      Try adding the whole Macintosh HD directory before the volume, as its mounted on your Mac HD.

  • DamithH

    work like calm

  • Jack

    -legacy flag sets the firmware to boot a legacy BIOS-based operating system. As you said you have an EFI install of Windows, you should try it without the -legacy flag.

    • http://buffaloseven.tumblr.com Brad

      Hmm…if I remove the legacy flag then my computer just restarts into OS X. Odd.

  • FreeBSD

    Making a separate partition on a mac is easy

    1. open diskutility -> partition
    2. highlight partition in use
    3. click the + , which make a 2nd partition with the same name
    4. reduce size existing partition if need be
    5.reduce partition size (Mac is using Non-destructive Repartitioning)
    6. rename 2nd partition to the OS (ie Yosemite) you want to install
    7. format 2nd partition

    8. there ye go….have fun

    • DogeCoin

      Well, MacOSX does have a BSD core.

  • Tim Farris

    only useful if you got a 300GB HDD or larger if you have the 128GB Drive this is useless because dual booting takes to much space

    • Utrarunner5

      Hey, I have a 128GB SSD and I dual boot Windows 8 and Mavericks. Just can’t have massive amounts of music and movies on it. I just have a 1TB external drive to hold everything. Even my steam games.