How to Clean-Install OS X Mountain Lion But Still Have an Upgraded Recovery Partition

I have a 2011 MacBook Air with OS X Lion preinstalled. For the past year I've done quite a few projects and tried many things on it. When OS X Mountain Lion came out, I felt it was about time to start over.

It turned out to be more complicated than I had imagined.

What I want is really simple: I want my recovery partition to be also Mountain Lion-based. This will some day be handy when I need to reinstall the system or to repair something.

Mountain Lion's installer actually upgrades the recovery partition if you do an upgrade install. Well I didn't want an upgrade install, so I followed the instructions here and made a bootable Mountain Lion partition on an external drive.

I booted into the installer, wiped my (FileVault-encrypted) disk, and installed the new cat… only to find that when it was done, the recovery partition was gone!

There are two issues here. First, wiping out your main volume also wipes out the recovery partition, even if you go to Terminal and use diskutil to reformat you main volume alone. The recovery partition has a different id, but it doesn't matter: it's removed once the main volume is reformatted. Second, the Mountain Lion installer on an external drive doesn't install the recovery partition, and there is no tool that installs the recovery tool after you've installed the OS.

I finally found the combination that worked. I had to boot into the Internet recovery system that comes with my MacBook Air and re-install Lion. This installed Lion and the recovery partition. Then I did a upgrade install of Mountain Lion, and booted into the now upgraded recovery partition, wiped out the drive again, then install Mountain Lion from the recovery system. Now I have a clean-installed OS X with a new recovery partition.

The only two cases where you get a new recovery partition seem to be (1) if you upgrade-install and (2) if you clean-install Mountain Lion from the recovery system thet you get after you upgrade-installed! It took me a few hours of re-installing the two versions to figure this out. So I'm writing my experinces down in hopes that it will save your time if you also want a clean-installed OS X with an upgraded recovery system.