Boot Camp with UEFI: In-depth and DeployStudio can do that!

Posted on: 16:34 by Maurits

Since the introduction of the UEFI boot for Windows on modern Apple hardware I wanted to investigate this a little deeper. In this blog post I will explain how UEFI boot impacts macOS and Boot Camp, and show you that DeployStudio can image and restore this configuration.

efi_mbair
The contents of (hidden) EFI partion after installing Windows 10 on an UEFI compatible Mac shown above.

Introduction

Since Apple introduced Boot Camp in the first Intel based Mac’s the technology has changed a lot; from Windows XP to Windows 10, and from Mac OS X 10.5 to macOS Sierra.
There are a lot of small differences in Windows versions supported by the different types of Mac and macOS, (HT205016), and some may prefer Windows in a virtual environment, but that is not the focus of this blog post.

If you dig deep enough you will see that there are (depending on your hardware and software) two main versions to boot Windows on Mac: ‘Hybrid MBR’ and ‘UEFI’ boot (those are my names) which have huge impact when using DeployStudio.

Hybrid MBR booting

The Hybrid MBR is the oldest method, where the GPT partitioned disk ‘emulates’ a MBR partition to the Windows OS that tries to boot from the disk. The implications for users are:

  • Never (ever!) change partitions in windows tools

That will overwrite the GPT partition table with MBR, effectively deleting the ‘Macintosh HD’ partition

  • There is a maximum of 1 Mac partition and 1 Windows partition

Th reason is that MBR supports max 4 primary partitions, and there are two hidden partitions: ‘EFI’ and ‘Recovery HD’, which leave only 2 partitions usable.

UEFI booting

UEFI boot is relatively new: Since Windows 8 Windows can boot UEFI natively, and Mac’s since 2013 support UEFI boot. This is hardly noticeable for the user if you run the bootcamp assistant (which will use EUFI boot if hardware and software supports it), but is very important if you deploy Mac’s with bootcamp, hence this blog post.

The most important difference is that the boot process for Windows starts from the EFI partition (using files like /EFI/Boot/Bootx64.efi, /EFI/Microsoft/Boot/BCD and others), and continues from the NTFS partition (with different files than Hybrid MBR would use).
I am not sure if both limitations of Hybrid MBR are removed, but it looks like it is. I managed to split the Windows 10 C: partition into 1 NTFS and 1 exFAT partition with Windows Disk Manager (resulting in total 5 partitions), the Mac boots both macOS and Windows 10, and the exFAT partition mounts in both OS’es.

It was first documented by Tim Perfett in his blog post for Twocanoes WinClone, and is supported by DeployStudio since version 1.7.4

Behind the scenes

Having EFI based hardware requires the EFI partition to be available on the boot disk per Intel EFI regulations. As far as I know Apple has not used this small partition actively (yet).
(Maybe this 200 or 314 MB FAT formatted partiton is used during firmware upgrades because the files like /EFI/APPLE/UPDATERS/SMC/SmcFlasher.efi can be found there, but I have not seen this confirmed yet).

You can mount it on any Mac, and see the contents in the finder with this set of Terminal commands:
Find the partition number of your EFI partition with diskutil list.

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Mac2HD                  499.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.1 MB   disk0s3

Usually the EFI partition is disk0s1. Mount this partition in the finder with this commmand:
diskutil mount disk0s1
The volume named EFI is mounted, and you can browse this volume in the Finder. The screenshot on the top of this article is made this way.

Impact for DeployStudio

DeployStudio has always had the option to restore a Mac with Boot Camp in one workflow, but before version 1.7.4 this assumed ‘Hybrid MBR’ type. This confused users with newer Mac’s that has an UEFI type of Bootcamp, and if this Mac is imaged, the resulting restore does not boot, since the (U)EFI partition is missing.
Since 1.7.4 DeployStudio can create and restore UEFI Boot Camp partitions.

For this lab we used DeployStudio 1.7.5 on 10.12.1/Server 5.2. We started with a MacBook Air (11″ mid 2013) (MacBookAir6.1), ran a clean install of macOS 10.12.1, ran the Boot Camp Assistant, created a 39 GB windows partition, used a Windows 10 _x64.iso to create a USB stick to install Windows. This MacBook Air netbooted from the DeployStudio .nbi (using the Apple Thunderbolt GBit Ethernet adapter) and ran the default ‘Create a master from a volume’ workflow.

The image created (Win10_UEFI) results in only 2 files:

  • one with .efi extension presumably containing the contents of the EFI partition (12.3 MB)

On my system this file is 12.3 MB in size, while the EFI partition has (uncompressed) 42 MB of files.

  • A second file with the extension .ntfs.gz, and is 4.3 GB in size.

This 4.3 GB may seem small, but the source volume only contains a basic Windows 10 installation which shows 17 GB in use, and there was a temporary file (seen during imaging) that was 13.6 GB in size before compression.

For comparison I have included a windows 10 installation from an older MacBookPro9.1 (2012 model), Hybrid MBR, named WIN10_BC6_hybrid_x64. This Image has 4 files:

  • .bcd file: the Boot Configuration Data file (25KB)
  • .bootstrap file: (446 Bytes)
  • .id file: containing a number (07) (3 Bytes)
  • .ntfs file: the actual image (5.49 GB, was 14 GB before compression)

Screenshot from the NTFS folder inside Masters showing both images:
content-master_ntfs-comp

Using this image, and an AutoDMG created image for the macOS partition I set up this workflow:

Step 1: Partition Disk

uefi-wf1

Step 2: Restore Windows 10

uefi-wf2

Step 3: Restore macOS

uefi-wf3

Step 4, 5 and 6 : install Munki software, enroll into Profile Manager, copy configuration profile are not shown here.

I ran this workflow succesfully on an iMac 21.5″(Mid 2014) (iMac14.4), and it created the following partitions:

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            309.3 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:       Microsoft Basic Data BOOTCAMP                190.0 GB   disk0s4

/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            Macintosh HD           +308.9 GB   disk1
                                 Logical Volume on disk0s2
                                 FD4486F7-2C79-4712-BA8E-566A03DD7687
                                 Unencrypted

The Windows partition (created on a 39 GB sized partition) is expanded to 190 GB.
In Windows 10 Disk Management the same information looks like this:
disk-management-win10-imac34
Notice the slightly different sizes of the partitions due to GiB and GB.

To Be done

It is good to know that this workflow works, but the issue is that one needs to select the proper workflow (UEFI or Hyprid MBR) with related images for each type of Mac. And if you have some Mac’s with Fusion Drives, you need to have a workflow for each setup, and some models (since the MacBook 12″ retina) have 4K sectors, which need a different .ntfs image than 512b sectors.
The best solution that comes to my mind is a script that investigates the hardware first, and then selects the proper workflow automatically.
This can be based on the example script ‘ds_workflow_selector.sh’ installed into the scripts folder by default:

#!/bin/sh
# get machine model
MACHINE_MODEL=`/usr/sbin/ioreg -c IOPlatformExpertDevice | grep "model" | awk -F\" '{ print $4 }'`
# echo the workflow ID or title prefixed by "RuntimeSelectWorkflow:" according to the machine model
if [ "${MACHINE_MODEL}" == "MacBookAir3,2" ]
then
  echo "RuntimeSelectWorkflow: 040622200000"
  #echo "RuntimeSelectWorkflow: Create a master"
fi
exit 0

You have to add the list of Machine Models that support UEFI boot to this script and use the UUID of your workflow.
For Fusion Drive detection I will point to the nice script of Calum Hunter, for 512b/4K detection to Richard Purves) and leave it to the reader to combine these scripts.
If you have an example, please let me know, I can include that here.

Summary

Using the DeployStudio 1.7.5 on macOS 10.12.1 (Server 5.2) we created a DSR-10121.nbi image.
Using the default workflow ‘create image’ we imaged a UEFI type Boot Camp MacBook Air, and restored this image to an iMac.
This system can succesfully create and restore an UEFI type Boot Camp Mac.

Related training courses from LAI

Learn about Bootcamp in our Mac Integration training. Learn using DeployStudio in our training Deploying macOS using DeployStudio and Munki.
Questions? See my info on the contact page.

Maurits

Reacties zijn gesloten.