Using Munki to make sure Macs have a recovery partition

If you're using Munki and you have Macs you want recovery partitions on (they're on there by default, but you may have accidentally deleted a recovery partition by reformatting the entire drive instead of just the main partition), here's one way you can approach it.

First, definitely use Create Recovery Partition Installer to create the installer. More details at Recreating a deleted recovery partition on a Mac.

Thing is—it creates a package, which installs receipts. In most cases, you don't want to reinstall the recovery partition, because the recovery partition is already there and doesn't need to be reinstalled. By default for .pkg files, Munki will check for receipts to see if a package is installed. We don't really need the package installed. We just need to see if there is a recovery partition or not.

Munki actually has several ways to check if a package is "installed," and one of those is an install check script.

So I just created recovery partition packages for Yosemite and El Capitan, and then gave them this install check script:

<key>installcheck_script</key>
<string>#!/bin/bash

# Create a variable to see if a recovery partition exists
testVariable=$(diskutil list | grep "Apple_Boot")

# If it's empty, it's not installed
if [ -z "$testVariable" ]; then
exit 0

# If it's not empty, it's installed
else
exit 1

fi</string>
So it basically looks for, in the partition table, a partition of type Apple_Boot. If it sees that type there, it means the recovery partition is installed. Otherwise, it means the recovery partition is not installed.

2 thoughts on “Using Munki to make sure Macs have a recovery partition”

  1. The Create Recovery Partition Installer listed in this article does not currently work with munki as the package contains a bom file, I tried this with 10.10, 10.11 and 10.12, any idea of any tools that make a file that works with munki or some way to convert the ones I have?

    1. It’s working for me and has been for all of those releases. Why would a bill of materials prevent it from working with Munki? A bom file is pretty standard in a .pkg. What’s the problem you’re encountering exactly?

Leave a Reply

Your email address will not be published. Required fields are marked *