Skip to main content

Automating Intel Mac Erase and Restore

You are here:

I have been working on a project to erase and restore any Mac from 2013 to the present. I revisited Mac Intel restores and added a new feature to MDS that works well, though it took some prep. It was challenging because there was no documented way to determine if a macOS version would install on a Mac before restoring. So through some investigating and testing, I came up with a set of rules:

  1. If the major version of macOS to be installed is earlier than the currently booted macOS, the install will fail.
  2. If the major version of macOS is earlier than macOS 11, installing macOS 12 or later will fail. Only up to macOS 10.15 can be installed.
  3. If the major version of macOS is later than the latest supported version of the Mac that is being restore, the install will fail.

The first rule is a well-known rule. You can’t go backwards easily when installing macOS. The second rule took a while to figure out, and I have not tested on all Macs in all configurations, but it appears there is something special about macOS 11 (Big Sur). Prior to Big Sur, you can update to Big Sur, but not later. If the current Mac is on Big Sur, you can upgrade the OS to the latest (or the latest that the hardware supports, which is the last rule).

To implement this in an automated way, MDS Deploy had to discover 4 pieces of information:

  1. The model identifier or product id of the hardware to figure out the the latest version of macOS that could be installed on that Mac
  2. The currently booted OS
  3. The version of macOS that is going to be installed
  4. A way to know what the latest version of macOS that can be installed based on the hardware

Obtaining the model identifier was easy:

/usr/sbin/sysctl -n hw.model

For the currently booted OS:

sw_vers -productVersion

The version to be installed proved to be a bit tricky, since the installer can be in a disk image, on a remote server, or in a local installer. I opted to have the OS version specified explicitly when creating the workflow:

With all the information, the only missing part was knowing what is the latest macOS version that can be installed on a Mac. The information is available but not in a way that is comprehensive or easily parsable. We were already working on a deterministic way to identify the DFU port of Apple Silicon Macs, so we expanded it to include the latest macOS version that can be installed.

The result makes it very easy to restore any Intel Mac. The Mac is booted into Internet Recovery, then an MDS Deploy utility is run. The utility determines what macOS versions are available, what hardware it is running on and what version of macOS it is booted into, and automatically selects the correct installer:

MDS Deploy also now displays the infomation:

The workflows also show if it can be installed to assist manual selection:

To set this up, all of the installers are included in the MDS workflows, and there is a new setting to run automatically:

In the end, for someone to erase a Mac is simple:

  1. Boot to Internet Recovery
  2. Open Terminal and run a command to launch MDS Deploy.

Those two steps can be automated further by using our Automaton to reduce it to two button presses.


Connect With Us


Sign Up for MDS Security and Product Updates

Enter your information below to receive email updates when there is new information specifically regarding this product and how to use it. Alternatively, to receive email updates for general information from Twocanoes Software, please see the Subscribe page.

Name
Tags: