Skip to main content
Solved

EA for checking for recovery partition?

  • November 3, 2015
  • 4 replies
  • 9 views

Forum|alt.badge.img+14

Any chance someone has already done the work to write an EA that can detect if a system has a recovery partition?

Best answer by hkabik

There's "Recovery HD Present" in the EA templates in the JSS.
Provides a simple "Present/Not Present" result.

#!/bin/sh

recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery HD" | grep disk0`

if [ "$recoveryHDPresent" != "" ]; then
    echo "<result>Present</result>"
else
    echo "<result>Not Present</result>"
fi

4 replies

Forum|alt.badge.img+16
  • Honored Contributor
  • Answer
  • November 3, 2015

There's "Recovery HD Present" in the EA templates in the JSS.
Provides a simple "Present/Not Present" result.

#!/bin/sh

recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery HD" | grep disk0`

if [ "$recoveryHDPresent" != "" ]; then
    echo "<result>Present</result>"
else
    echo "<result>Not Present</result>"
fi

Forum|alt.badge.img+16
  • Valued Contributor
  • November 4, 2015

If you want it to be very simple (and potentially easy to trick if one was inclined).

#!/bin/bash
if [ "$(diskutil list | awk '/Recovery HD/')" ]; then
echo "<result>TRUE</result>"
else
echo "<result>FALSE</result>"
fi

Forum|alt.badge.img+14
  • Author
  • Valued Contributor
  • November 4, 2015

Thanks!

@hkabik, I must have fat fingered my search when I was looking through those. I've been doing that a lot lately. lol


Forum|alt.badge.img+17
  • Valued Contributor
  • March 8, 2018

For anyone running 10.13.x the Recovery partition is no longer "Recovery HD" and it's not at disk0. Might be good to put an OS check to run a modified version if it's on 10.13, or just loosen up the search by using "Recovery"* and drop the disk0 grep.