DIY Fusion Drive: Adding Recovery HD to a CoreStorage Volume Group

You'll need to partition the drives first, putting the Recovery partition on one of your physical drives. It can't be part of the Fusion drive as its unlikely you can boot directly into a Core Storage logical volume (you need a boot loader separately).

Take note of the partition structure in this Ars Technica article about the Fusion drive.

The best way to do this is probably to start fresh by reinstalling Mountain Lion on either the SSD or HDD, then repeat the Fusion process with just the proper partition.

Once you've done a standard install, check your partitions by running diskutil list, which should give output similar to this:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *120.0 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            119.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

Make note of the identifier of the Macintosh HD partition (disk0s2 in this case).

Then do the same steps you performed before, but change the diskutil corestorage create fusion_volume_group command so to specify the disk0s2 (or whatever the equivalent in your case is), and the identifier of the drive you didn't install OS X on. The resulting command should be similar to diskutil corestorage create fusion_volume_group disk0s2 disk1 but make sure you've got the identifiers correct. The key is that we want to make a volume group out of just the Macintosh HD partition, not the whole drive (so that the EFI and Recovery partitions don't get wiped out). Then follow the rest of the procedure as you did before.


Ok so I have solved the problem without re-formatting or re-installing. Hopefully most people won't wind up in this situation. See @robmathers answer for tips on how to avoid deleting your Recovery HD in the first place.

WARNING the following commands are fairly low-level and may cause you to loose data. Take proper precautions (backup, clone, etc).

But for anyone in my situation after the RecoveryHD is already gone, here is what I did:

  1. Backup all data / clone your drive
  2. Create a bootable USB (or use an existing HD) with 10.8
  3. Boot into that alternate drive (so you're not modifying the HD you've currently mounted)
  4. Unmount the Fusion HD
  5. Open terminal, switch to superuser and follow these instructions:

List the current configuration, and make a note of which drives you'll be modifying. Your exact sizes and GUIDs will be different than mine. It is crucial to use your numbers instead of mine.

diskutil corestorage list

Take note of the UUID of the physical drive you're adding the Recovery to.

diskutil list

Take note of the exact size in bytes of the Recovery on the current startup disk (disk2s3 might be different for you).

diskutil info disk2s3

Resize the Physical Volume for the drive you want to add the Recovery partition to. To determine the size, look @ the existing Recovery partition on the USB. In my case it was just under 1GB. For the following command, pvUUID is the UUID of the drive you're adding the Recovery to, size is 1GB less than the current size.

diskutil coreStorage resizeDisk <pvUUID> <size> JHFS+ Recovery 784220160B

NOTE: you may need to unmount the volumes repeatedly in the following steps. OSX tends to aggressively re-mount the volumes.

Repartition the new "Recovery" partition from a jHFS+ to Apple_Boot. First, take note of the exact start/size of the partition.

gpt show disk0

     start       size  index  contents
        0          1         PMBR
        1          1         Pri GPT header
        2         32         Pri GPT table
       34          6
       40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
   409640  246725744      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
247135384     262144
**247397528    1269528       3  GPT part - 48465300-0000-11AA-AA11-00306543ECAC**
248667056    1402591
250069647         32         Sec GPT table
250069679          1         Sec GPT header 

Now remove the partition, and re-add it with a different UUID (the UUID is what determines the type of partition)

gpt remove -b 247397528 -s 1269528 -t 48465300-0000-11AA-AA11-00306543ECAC disk0
gpt add -b 247397528 -s 1269528 -t 426F6F74-0000-11AA-AA11-00306543ECAC disk0

Now copy the entire Recovery partition from the good one to this new one:

dd if=/dev/disk2s3 of=/dev/disk0s3

Many thanks to the following sites for reference. Read up on them before diving in, if you don't understand any of these steps.

http://blog.fosketts.net/2011/08/05/undocumented-corestorage-commands/

http://www.dmitry-dulepov.com/2011/09/how-to-create-mac-os-x-lion-recovery.html