EA for checking for recovery partition?

jhuls
Contributor III

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

1 ACCEPTED SOLUTION

hkabik
Valued Contributor

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

View solution in original post

4 REPLIES 4

hkabik
Valued Contributor

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

Look
Valued Contributor III

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

jhuls
Contributor III

Thanks!

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

cwaldrip
Valued Contributor

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.