Restarting to Bootcamp Via Policy

monosodium
Contributor

Hello All,

I have a script that works great for restarting my iMacs to Bootcamped Windows. I use it in Casper Remote and Self-Service just fine. Here is the script:

#!/bin/sh
sudo bless -mount "/Volumes/BOOTCAMP" -legacy -setBoot -nextonly
sudo shutdown -r now

When I try to run this in a policy though, I cannot get it to work at all. What is the difference here? I need to have my iMacs reboot at set times for Windows maintenance, policies seem like the way to go.

Any help appreciated!

  • Jason
8 REPLIES 8

thoule
Valued Contributor II

It should work.. Any policy output? Two changes I'd make though. First, drop the sudo. All scripts run with root privs when executed via jamf policy. Second, use full path names to commands.

bash-3.2# which bless
/usr/sbin/bless

so use:

/usr/sbin/bless -mount "/Volumes/BOOTCAMP" -legacy -setBoot -nextonly
/sbin/shutdown -r now

You could also put '/usr/sbin/bless --info' in between the two lines to see what it's set to before reboot. Might also need to run jamf recon to get that data back though...

stevewood
Honored Contributor II
Honored Contributor II

And you really should be able to do this without a script. Use the Restart Options tab in the policy to set the volume to boot to:

http://cl.ly/1u2F2u1j2d1p/Screen%20Shot%202016-04-20%20at%204.37.40%20PM.png

Look
Valued Contributor III

I suspect none of this will work if SIP is enabled though.
Do you use any kind of bootpicker like refind or similar? This would also likely break that as well.

bentoms
Release Candidate Programs Tester

TwoCanoes have detailed some of SIP's changes & BootCamp here.

bsuggett
Contributor II

We have over 400 iMac's duel booting into Windows... (BootCamp)

We've tried using the Casper's built in option to bless the Windows partition as mentioned by @stevewood however have never been able to get it to work.

We've developed a script to do exactly what you want and works flawlessly (with the exception to new machines and SIP)

#!/bin/sh
bless --mount "/Volumes/WINDOWS" --setBoot --legacy

Obviously you would replace "/Volumes/WINDOWS" with your volume name...

You then have to set in the policy, Casper Remote, and Self Service... To explicitly DO NOT BLESS as the picture shows below
069c11d8eb7647cb8ee442b509f9c86d

If you don't do this, Casper blesses the currently booted OS....

We also have the machines rebooting to mac from Windows on a schedule too to ensure both OS's get some maintenance using the BootCamp.exe utility.

The BootCamp.exe for Windows works regardless if SIP is enabled or not which is really annoying since Apple's bless binary doesn't... A way around this that has been mentioned is disabling SIP, which we've done to get rebooting backwards and forwards working again. (Hoping Apple will fix the bless command)

Anyways, hope this helps....

Look
Valued Contributor III

We have similarly disabled SIP until Apple fixes it's dual boot functionality, couldn't see any other way around it (plus we were having trouble even deploying Windows with it enabled).
We are using Refind so I just swap to Windows and back by editing the default_selection entry in the refind.conf file

bsuggett
Contributor II

While somewhat related but not directly related, I'll mention it however will cover it in detail should there be demand.

Windows 8 and above can nativity be installed on GPT formatted disk / partitions and is by default on dell's etc.

It is a question to Apple that should be asked... Why on the latest Mac's that Apple enforce a minimum of Windows 8 and diskutil and bootcamp assistant continue to flag the bootcamp partitions as hybrid MBR?.

To setup Windows in UEFI mode, create a partition in OS X formatted as JHFS or JHFS+ (this is to prevent a hybrid MBR partition being created) reboot into Windows UEFI mode installer off a USB key then delete the partition you created in OS X and create a new NTFS partition and follow the installer.

You now have Windows installed running in UEFI mode.

Performing Windows installation Apple's way still forces one to use hybrid MBR which it shouldn't...

bsuggett
Contributor II

This should be the default method of setting up Windows too since Apple have so kindly disabled legacy boot/ BIOS boot/ MBR boot from external devices in their firmware on new Mac's.