Skip to main content

First: This is not Apple approved. I know that, you know that, do it at your own risk. I do, this works fine.
UPDATE: I have added my imager for download to the bottom of this post with instructions

This is not a discussion about why or opinions :). Some of us have this need, this is a solution!

Thought I would share as I have seen a number of folks looking for these answers. Some of you are just looking for a certain piece of this, and thats great. Some of you are looking for a way to make an imager and that is here too. If you want to take the whole thing and make a fully automated USB Imager than that is also here :). If you don't like imaging, don't want to use this, or don't like it. That is okay! We each have our own thoughts and way of doing things, this isn't for you :).

If you are interested, dabble in this, or have other thoughts/ways to make it better PLEASE post and share below!

APFS / High Sierra Imaging: (Steps 1 and 3 are assuming your machines have never been on 10.13 and are missing the new firmware. If they are already upgraded you can skip Step 1 and 3)

STEP 1: Make a Firmware update Package for/from the device you want to deploy:

From the type of device you want to deploy to, have full High Sierra install App in application folder and run: (doesn't have to be from a 10.13 machine)

#!/bin/sh
# Based on investigations and work by Pepijn Bruienne
# Expects a single /Applications/Install macOS High Sierra*.app on disk

IDENTIFIER="com.foo.FirmwareUpdateStandalone"
VERSION=1.0

# find the Install macOS High Sierra.app and mount the embedded InstallESD disk image
echo "Mounting High Sierra ESD disk image..."
/usr/bin/hdiutil mount /Applications/Install macOS High Sierra*.app/Contents/SharedSupport/InstallESD.dmg

# expand the FirmwareUpdate.pkg so we can copy resources from it
echo "Expanding FirmwareUpdate.pkg"
/usr/sbin/pkgutil --expand /Volumes/InstallESD/Packages/FirmwareUpdate.pkg /tmp/FirmwareUpdate

# we don't need the disk image any more
echo "Ejecting disk image..."
/usr/bin/hdiutil eject /Volumes/InstallESD

# make a place to stage our pkg resources
/bin/mkdir -p /tmp/FirmwareUpdateStandalone/scripts

# copy the needed resources
echo "Copying package resources..."
/bin/cp /tmp/FirmwareUpdate/Scripts/postinstall_actions/update /tmp/FirmwareUpdateStandalone/scripts/postinstall
# add an exit 0 at the end of the script
echo "" >> /tmp/FirmwareUpdateStandalone/scripts/postinstall
echo "" >> /tmp/FirmwareUpdateStandalone/scripts/postinstall
echo "exit 0" >> /tmp/FirmwareUpdateStandalone/scripts/postinstall
/bin/cp -R /tmp/FirmwareUpdate/Scripts/Tools /tmp/FirmwareUpdateStandalone/scripts/

# build the package
echo "Building standalone package..."
/usr/bin/pkgbuild --nopayload --scripts /tmp/FirmwareUpdateStandalone/scripts --identifier "$IDENTIFIER" --version "$VERSION" /tmp/FirmwareUpdateStandalone/FirmwareUpdateStandalone.pkg

# clean up
/bin/rm -r /tmp/FirmwareUpdate
/bin/rm -r /tmp/FirmwareUpdateStandalone/scripts

Firmware package will be located at:

/tmp/FirmwareUpdateStandalone/FirmwareUpdateStandalone.pkg

AGAIN THAT IS DEVICE SPECIFIC
(supposedly, I haven't tested it and don't plan to for obvious reasons)

Step 2: Making an AFPS Image:
Have a good 10.13 master machine. in Disk utility resize partition to smallest size if you want to have an image that isn't the entire size of the hard drive (It will expand on restore)

Apple has made this no longer work. Instead use terminal to resize the Container.
diskutil apfs resize Container disk2s2 30g
(change disk2s2 to the partition of the container you want to shrink and 30g to whatever size you can shrink to)

Target disk Master to another machine or use USB drive.

In Disk Utility (must be High Sierra UPDATE: Must be 10.13.3 or Lower. Apple botched something in 10.13.4+ for capturing a container image) - View - Show all devices

Unmount APFS Volume under Container of drive you want to make image

File - New image - from Container (DO NOT COMPRESS)

Don't forget to scan image for restore

Other Random Details:

You Will not see any volumes when Alt-Booting etc.. until Firmware is updated, APFS volumes will not show at all.

After running Firmware package, firmware updates on next boot (Typical apple loading slider), then reboots into startup disk

You can update firmware on a 10.12 machine and 10.12 will still boot fine.

STEP 3: Making an Imager USB without APFS: (super important if you want to boot to your "imager" on a machine that does not yet have the firmware!)

Need a machine with SIP Disabled
(boot to recovery / MacOS install USB and in terminal: "csrutil disable" , then reboot)

Boot to good OS of SIP Disabled machine (doesn't have to be 10.13) and download High Sierra installer App / copy from USB to Applications folder.

From terminal Run:

/Applications/Install macOS High Sierra.app/Contents/Resources/startosinstall --converttoapfs NO --volume /Volumes/DestinationDriveName

STEP 4: IMAGING!

Either make sure you run the Firmware package on the machine before you image it (you can install at in 10.12 before you image it), or use a USB drive to boot to a good OS (again doesn't have to be 10.13) and run the firmware package you made originally .

First Manually:

From Disk Utility on 10.13 machine/usb - erase drive to APFS
Unmount Volume Under Container
Click on Container and choose restore and Choose image made originally

SCRIPT:
Here is the script I use from a USB Drive. Fully automated. Drive does not have to be prepped in any way script will erase the entire drive and make it APFS with correct containers from Image and upgrade the firmware, as well as set startup disk. It also copies a FirstBoot script to enroll using QuickAdd. (Uses Applescript to set startup disk VIA System Preferences. No longer able to set startup disk via Bless or systemsetup due to SIP)

If you want it to be truly automated, you need to run the script as the root user. Otherwise there is user interaction. (To Enable Root: Directory Utility - unlock button - Edit in menu - Enable Root). With High Sierra you can no longer set Root as auto login in OSX. If, like me, you want the USB fully automated you can set root as auto login with the following:

sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser root  
sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUserUID 0 

Script assumes that A.) you have the image you want to use in /Configurations B.) The Firmware is in /Packages C.) In order for startup disk via Applescript to work you must put Terminal in Security - Privacy - Accessibility on your "imager", and you must be Root user (otherwise you would have to unlock the preference pane) - OPTIONAL D.) If you want to have it enroll on firstboot you must put quickadd.pkg in /Data

#!/bin/bash
sleep 2
#   Restore AFPS Image to internal container from /Configurations
asr restore -s /Configurations/*.dmg -t /dev/disk0s2 -erase -noverify -noprompt

#   Install Firmware package from /Packages IF needed
current_efi_version=$(/usr/libexec/efiupdater | grep "Raw" | cut -d ':' -f2 | sed 's/ //') 
echo "current_efi_version $current_efi_version"
latest_efi_version=$(ls -La /usr/libexec/firmwarecheckers/eficheck/EFIAllowListShipping.bundle/allowlists/ | grep "$current_efi_version")
echo "latest_efi_version $latest_efi_version"
if [ "$latest_efi_version" == "" ]; then
echo "EFI Outdated"
installer -pkg /Packages/*.pkg -target / -allowUntrusted
else echo "EFI Current"
fi

#mount Volume - MUST CHANGE VOLUME NAME TO NAME OF YOUR IMAGE
Diskutil mount "VOLUMENAME"
Sleep 2

#Copy Firstboot Files so that machine Automatically Enrolls on First Boot - MUST CHANGE VOLUME NAME TO VOLUME NAME OF YOUR IMAGE
cp /Volumes/Imager18/Data/com.imager.firstboot.plist /Volumes/VOLUMENAME/Library/LaunchDaemons/
mkdir /Volumes/VOLUMENAME/usr/local/data
cp /Volumes/Imager18/Data/firstboot.sh /Volumes/VOLUMENAME/usr/local/data/
cp /Volumes/Imager18/Data/quickadd.pkg /Volumes/VOLUMENAME/usr/local/data/
chmod 644 /Volumes/VOLUMENAME/Library/LaunchDaemons/com.imager.firstboot.plist
chmod 777 /Volumes/VOLUMENAME/usr/local/data/firstboot.sh
chmod +x /Volumes/VOLUMENAME/usr/local/data/firstboot.sh

#Set Startup disk using AppleScript
#Requires Terminal in Security - Privacy - Accessibility
#DO NOT TOUCH MACHINE WHILE THIS IS HAPPENING

osascript -e 'tell app "System Preferences" to Activate'
Sleep 2
osascript -e 'tell app "System Preferences" to set current pane to pane id "com.apple.preference.startupdisk"'
Sleep 3
osascript -e 'tell app "System Events" to tell process "System Preferences" to click radio button 2 of radio group 1 of scroll area 1 of group 1 of splitter group 1 of window 1'
osascript -e 'tell application "System Events" to tell process "System Preferences" to click button 1 of window "Startup Disk"'
Sleep 1
osascript -e 'tell app "System Events" to tell process "System Preferences" to set frontmost to true'
Sleep 2
osascript -e 'tell app "System Events" to keystroke return'
exit 0

Fully Automated Checklist:
1.) USB Drive with HFS+ High Sierra Installed (NOT APFS)
2.) Root Enabled
3.) Root set to Autologin
4.) Script set to run on Login (Easiest way is just drag it in to login items)
5.) APFS Image in /Configurations
6.) Firmware Package in /Packages
7.) Optional: quickadd.pkg in /Data

Congratulations you have a USB that you will boot to and 4-5 minutes later when it is done you will have a freshly imaged machine on 10.13 with the correct Firmware and APFS!

MY IMAGER: https://tinyurl.com/APFSimager
LINK FIXED

To use: Download DMG and restore to USB Thumb drive.
Place Firmware package in /Packages
Place quickadd.pkg in /Data
Place APFS Container image in /Configurations

If you do not want to use Quickadd portion of imager simply delete the /Data folder.

Hey Chris,

First of all...thanks for this resource! Now, for the newbie question. I'm new to Jamf and unfamiliar with their imaging process. I used Deploystudio in the past.

So I have mostly iMacs from Late 2013 to present. Most are running Fusion drives, but a few have mechanical drives. So no SSDs. I just want to wipe the iMacs and get them to a fresh copy of 10.13 and get picked up by the Jamf server via Apple's School Manager, that way they get enrolled and ready to deploy the Jamf configurations/policies. Does your method here work for that? ;)

Thanks for any assistance you can offer.


@pfrancois That is a situation! Normally I would use the startos --eraseinstall command but that only works for APFS and only once you are already on 10.13.4+

In your case I THINK the best bet is to use AutoDMG. This will give you your clean install of 10.13 and if you are using DEP/ASM for enrollment anyway you don't need anything packaged for that. https://github.com/MagerValp/AutoDMG Obviously that isn't 100% automated since you will have to click through the User creation and enrollment, but it sounds like what you are looking for.


@chrisdaggett That does sound best. Do you think once I drag the High Sierra installer in AutoDMG and build it, I can upload to Deploystudio and push it from there?


@pfrancois Absolutely, should be no issues at all there.


Reminder - do not compress images or it will not work. I have made images through 10.13.6 with no issues. Apple has made it so you can not resize partitions using disk util for APFS drives, so you must use:

diskutil apfs resize Container disk2s2 30g

This assumes Disk2s2 is the APFS contrainer you want to resize and 30g is the smallest you can make it, obviously YMMV.


#!/bin/sh

@pfrancois We're in a similar position to you, a mix of Fusion, HDD and SSD devices that need flattening for this years Lab Builds.

I built the installer package containing the installer .app renamed without the version number in Composer. This can be deployed and scripted either Via JAMF or to follow a 10.12 install done with DeployStudio, this method means I can effectively Image to 10.13.6 with DeployStudio

For Fusion Macs:

#!/bin/bash

# Bless Boot Drive
bless -mount /Volumes/"$2" -setBoot #Reduces the incidence of Kernel Panics during Fusion Upgrades.

# install-macOS
/Applications/Install macOS High Sierra.app/Contents/Resources/startosinstall --applicationpath /Applications/Install macOS High Sierra.app --agreetolicense --nointeraction --converttoapfs NO

$2 needs to be replaced with the Volume name your Mac will have when this runs, I use ${DS_COMPUTERNAME} in DeployStudioafter renaming the boot-drive the the Computer name.

For SSD or HDD Macs:

#!/bin/bash
# install-macOS
/Applications/Install macOS High Sierra.app/Contents/Resources/startosinstall --applicationpath /Applications/Install macOS High Sierra.app --agreetolicense --nointeraction --converttoapfs YES

I've made these available to staff as Self Service policies. For Lab Macs we now have an APFS work around for Fusion Macs.


Why do I have no 'postinstall_action' directory inside of my FirmwareUpdate.pkg? Did Apple change something?


Hello @chrisdaggett ,

First off THANK YOU for putting this thing together. This is going to be a huge help, and a great solution, while we are trying to build out our thin imaging solution.

That being said I am running into the same issue as @jmcmahon1 where I am getting an error in the script that says "cp: /tmp/FirmwareUpdate/Scripts/postinstall_actions/update: No such file or directory"

Here is the whole thing if it helps:

Mounting High Sierra ESD disk image...
/dev/disk2              GUID_partition_scheme           
/dev/disk2s1            EFI                             
/dev/disk2s2            Apple_HFS                       /Volumes/InstallESD
Expanding FirmwareUpdate.pkg
Ejecting disk image...
"disk2" unmounted.
"disk2" ejected.
Copying package resources...
cp: /tmp/FirmwareUpdate/Scripts/postinstall_actions/update: No such file or directory
Building standalone package...
pkgbuild: Adding top-level postinstall script
pkgbuild: Wrote package to /tmp/FirmwareUpdateStandalone/FirmwareUpdateStandalone.pkg

It appears that the pkg is created without issue, however I just wanted to make sure that this is not something that we need to be concerned about.


@Austin.Hicks I apologize I just saw your post. I just tried it again and I do not get any errors.

Mounting High Sierra ESD disk image...
expected   CRC32 $1D0A7164
/dev/disk4              GUID_partition_scheme           
/dev/disk4s1            EFI                             
/dev/disk4s2            Apple_HFS                       /Volumes/InstallESD
Expanding FirmwareUpdate.pkg
Ejecting disk image...
"disk4" unmounted.
"disk4" ejected.
Copying package resources...
Building standalone package...
pkgbuild: Adding top-level postinstall script
pkgbuild: Wrote package to /tmp/FirmwareUpdateStandalone/FirmwareUpdateStandalone.pkg

Using. My current test was on 10.13.6 machine (my machine) using a 10.13.3 Install App.

I will try it again with a 10.13.6 fresh download and see if I get any errors.

#!/bin/sh
# Based on investigations and work by Pepijn Bruienne
# Expects a single /Applications/Install macOS High Sierra*.app on disk

IDENTIFIER="com.foo.FirmwareUpdateStandalone"
VERSION=1.0

# find the Install macOS High Sierra.app and mount the embedded InstallESD disk image
echo "Mounting High Sierra ESD disk image..."
/usr/bin/hdiutil mount /Applications/Install macOS High Sierra*.app/Contents/SharedSupport/InstallESD.dmg

# expand the FirmwareUpdate.pkg so we can copy resources from it
echo "Expanding FirmwareUpdate.pkg"
/usr/sbin/pkgutil --expand /Volumes/InstallESD/Packages/FirmwareUpdate.pkg /tmp/FirmwareUpdate

# we don't need the disk image any more
echo "Ejecting disk image..."
/usr/bin/hdiutil eject /Volumes/InstallESD

# make a place to stage our pkg resources
/bin/mkdir -p /tmp/FirmwareUpdateStandalone/scripts

# copy the needed resources
echo "Copying package resources..."
/bin/cp /tmp/FirmwareUpdate/Scripts/postinstall_actions/update /tmp/FirmwareUpdateStandalone/scripts/postinstall
# add an exit 0 at the end of the script
echo "" >> /tmp/FirmwareUpdateStandalone/scripts/postinstall
echo "" >> /tmp/FirmwareUpdateStandalone/scripts/postinstall
echo "exit 0" >> /tmp/FirmwareUpdateStandalone/scripts/postinstall
/bin/cp -R /tmp/FirmwareUpdate/Scripts/Tools /tmp/FirmwareUpdateStandalone/scripts/

# build the package
echo "Building standalone package..."
/usr/bin/pkgbuild --nopayload --scripts /tmp/FirmwareUpdateStandalone/scripts --identifier "$IDENTIFIER" --version "$VERSION" /tmp/FirmwareUpdateStandalone/FirmwareUpdateStandalone.pkg

# clean up
/bin/rm -r /tmp/FirmwareUpdate
/bin/rm -r /tmp/FirmwareUpdateStandalone/scripts

@Austin.Hicks @jmcmahon1 Confirmed the Script to build the firmware package does get an error with anything above 10.13.3 (same time Imaging stopped working as well. Seems obvious apple is trying to botch this method IMO)

So you need a 10.13.0-10.13.3 Install App to use that script.

I am going to look at it when I get back from a meeting and see if it is possible to update the script to work with newer installer apps.


I was also having the same issue where the postinstall_actions folder doesn't exist. Are we able to just use the "/tmp/FirmwareUpdate/Scripts/Postintall" instead? Whats the difference between the root postinstall and the postinstall_actions subfolder? Also what happens if we just run the Firmware Package straight out of the InstallESD file instead of going through the extra steps?


Thanks for this

can you upload your image again


@cruncx Link fixed! Sorry about that. https://tinyurl.com/APFSimager


I have begun creating a Mojave 10.14.4 imager. So far it APPEARS 10.14.4 will make an image OF and Image 10.14.4 just fine. Lot of testing to do though. So far it is looking positive.

Once I have fully tested and had success I will make a new, similar, post with the link to a full imager as well as instructions for those who want to modify/create/etc..


New thread created for imaging with Mojave. Shorter and to the point with out all the original how-to/etc.. After testing there is no reason to create a new imager, as it still works great with 10.14.4 based images. One new step is to create the image FROM 10.14.4.

https://www.jamf.com/jamf-nation/discussions/31932/how-to-imaging-mojave-10-14