Hiding Recovery partition

MarcosMunoz
New Contributor III

Has anyone figured out how to hide the recovery partition while still retaining the ability to boot to it for troubleshooting or restoring the system?

I used the hideRecoveryHD.sh script found on JAMFNation that has the following syntax:

*#!/bin/sh

RecoveryHDName="Recovery HD"
RecoveryHDID=/usr/sbin/diskutil list | grep "$RecoveryHDName" | awk 'END { print $NF }'

/usr/sbin/diskutil unmount /dev/"$RecoveryHDID"
/usr/sbin/asr adjust -target /dev/"$RecoveryHDID" -settype Apple_Boot
/usr/sbin/diskutil info /dev/"$RecoveryHDID"*

The script works great. It hides the Recovery partition as intended. However, it also makes it so that you can no longer boot to it.

Is anyone using a different script/method for hiding the recovery partition with the ability to still boot into it (if needed)?

Thanks.

13 REPLIES 13

pblake
Contributor III

If you reboot and hold option you cannot boot to it? If you are trying to boot from it from the startup disk system preference, you need a script to mount it again since your script is unmounting the volume. That's my thinking :)

GaToRAiD
Contributor II

Here's something I found, in the process of testing it. Will confirm on Monday.

https://discussions.apple.com/thread/3250922

fabian_ulmrich
Contributor

Hi there,

Using the same syntax to hide other partitions on my systems as well as Recovery HD and everything works fine.

What I figured out is, that booting to any parttype: Apple_Boot partition won't work by using bless command, but it should work through Startup/ Boot Manager by keep holding the Option button at the point of POWER ON.

How did you create your BaseImage? Try using AutoDMG, it creates a Recovery Partition as well and you don't need to hide anything manually.

Cheers.

Joseph_Morris
Contributor

If your recovery partition is hidden when you hold down Option on startup, you can press Command+R at the boot picker in order to boot into the recovery partition. It may not show up, but it will still boot into it. My MacBook Pro hasn't shown the recovery partition since 10.8.

Sanchi
Contributor

I added this script to a login hook I was already using. Its hooked the manual (old) way rather than using the JSS method of adding login hooks. Did the job for me

lsmc08
Contributor

@mmunoz2,

I use this in a Configuration as part of my Casper Imaging process and it works pretty well.

#!/bin/sh 

RecoveryHDName="Recovery HD" 
RecoveryHDID=`/usr/sbin/diskutil list | grep disk0 | grep "$RecoveryHDName" | awk 'END { print $NF }'` 

/usr/sbin/diskutil unmount /dev/"$RecoveryHDID" 
/usr/sbin/asr adjust -target /dev/"$RecoveryHDID" -settype Apple_Boot

rm3305
New Contributor

Here's the one I used for many OS configs

!/bin/sh

/usr/sbin/diskutil unmount /dev/disk0s3
/usr/sbin/asr adjust -target /dev/disk0s3 -settype Apple_Boot

Reboot2611
New Contributor

Is there a way to use the same script for a Fusion drive and normal drive?

daniel_kaminski
New Contributor III

Hello everyone :)

Originally I was always using the first mentioned script, but on El Capitan it does not seem to be working for me, so I tried the one rm3305 posted. This failed as well. Both would unmount the Recovery Partition, but neither would change it to Apple_Boot.

I tried to do it manually via terminal to see what was going on. After I unmount the Recovery Partition, which is disk0s3 for me and run the command /usr/sbin/asr adjust -target /dev/disk0s3 -settype Apple_Boot it returns asr: Volume adjustment failed: Operation not permitted.

I tried running it as root and it returns the same message: asr: Volume adjustment failed: Operation not permitted.

Anyone have any ideas?

m_entholzner
Contributor III
Contributor III

I assume that SIP (=System Integrity Protection) prevents changes to the Recovery HD here. I would recommend to use AutoDMG for creating a never-booted, clean base OS for imaging. The AutoDMG image will already include the Recovery HD and there will be no need for using the script afterwards.

daniel_kaminski
New Contributor III

Thanks for getting back to me. I just read up on SIP and it is very possible that this is what is causing me not to be able to change the Recovery partition's type.

Beyond using it in training I haven't used AutoDMG to create a base because in my environment I have to heavily customize nearly everything about the base before deployment for the users.

This includes Finder preferences, Desktop & Screen Saver settings, Security and Privacy options, Energy Saver, Sound, Sharing (for enabling Remote Management for the local hidden account), pretty much nearly everything in System Preferences has a change that needs to happen without user interaction.

What would be the best method of getting these custom System Preference settings onto a the computers after they are imaged with a base made in AutoDMG?

bpavlov
Honored Contributor

The first step is to make a list of all the settings/preferences you need to manage. The second step is to research how you can set those settings via a configuration profile and/or a script. The third step is to implement the configuration profile and/or script and test. Once you broken everything out, you will wonder how you ever did things the way you are doing it now. The reason is that because you've broken everything up into pieces you no longer have to worry about recreating everything from scratch each time you want to make a change or you need to update your image. This is the first step to going modular. You will find that most often you will only need to deploy a new base OS and maybe test and confirm that your workflow behaves as expected with each new release of OS X.

To get you started with System Preferences: https://derflounder.wordpress.com/2014/02/16/managing-the-authorization-database-in-os-x-mavericks/

Good luck!

wbennin
New Contributor

First time posting so bare with me. I was able to change the Recovery HD from Apple_HFS to Apple_Boot. the steps are pretty simple but require some pre-reqs

  1. create a recovery USB there a multiple tools out there.
  2. reboot with option, select recovery USB
  3. unmount the recovery HD usually (/dev/disk0s3). I initially used terminal to unmount and that failed so I went into disk utility to unmount 4 . after unomunt is successful enter command "asr adjust -target /dev/disk0s3 -settype Apple_Boot" should be successful as it was for me and reboot. SIP is not enforced while in recovery mode.

Thanks

GOod Luck!!