10

After creating a "DIY Fusion Drive" using the methods below in 10.8, I'm now wondering how to add a RecoveryHD partition to the internal drive.

Here's what I did to create a Logical Volume Group across two physical volumes (128G SSD/750GHD)

(make a clone / backup of all your data first)
diskutil list (take note of the disk## of the two drives. In my case: disk0/disk1)
diskutil corestorage create fusion_volume_group disk0 disk1
diskutil corestorage list (take note of the Logical Volume Group UUID)
diskutil corestorage createVolume <UUID> jhfs+ FusionHD 749g
restore the clone onto the FusionHD

This worked great, but now my RecoveryHD is gone. I'd like to add it back (it's on the external drive I cloned from my original HD)

Here's what the partition layout looks like right now:

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *120.0 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:          Apple_CoreStorage                         119.7 GB   disk0s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *750.2 GB   disk1
   1:                        EFI                         209.7 MB   disk1s1
   2:          Apple_CoreStorage                         749.3 GB   disk1s2
   3:                 Apple_Boot Boot OS X               650.0 MB   disk1s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS FusionHD               *744.5 GB   disk2

Does anyone know the diskUtil commands to add the recovery HD? Ideally after the fact, which is where I'm at now?

6 Answers 6

6

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.

5
  • Do you know what the diskutil commands would be to do that operation? Commented Nov 3, 2012 at 16:52
  • I added some more info should work, but I don't have a set up I can actually test it on. The Fusion drive stuff is pretty undocumented at this point, and we're just working off what a few people have come up with by trial and error. Be sure to post any results you get here.
    – robmathers
    Commented Nov 3, 2012 at 17:15
  • I think you're right about specifying the disk0s2 rather than disk0. I cannot verify this today, as the weekend was my 'tear my machine apart and rebuild' time. Now I have to work! I'll try to test this soon. Commented Nov 5, 2012 at 14:34
  • I just installed 10.8.2 onto a brand new empty CS volumes (120GB SSD + 640GB HDD) to see if the ML installer would add a new Recovery partition - it didn't. So the instructions above should be correct, will try on next test deploy.
    – da4
    Commented Nov 5, 2012 at 20:01
  • SUCCESS! Late-2008 MacBook Pro, 2nd HD in optical drive slot: I replaced the main 320GB HD with a 256GB SSD. Following @robmather: I installed Mountain Lion on the SSD; booted the MBP from an external drive; studied the diskutil list output to get the disk IDENTIFIER for "Macintosh HD" on the SSD. Used that with diskutil's corestorage commands to create fusion volume. Booted from Recovery Volume, installed ML and migrated entire original disk to my new 560GB fusion volume. Everything works, even Ubuntu on VMWare. Ordered a slow/cheap 1TB HD; soon my 4-yr-old MBP powers on w 8GB, 1.25TB, SSD! Commented Nov 11, 2012 at 18:31
5

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

1
  • update: this setup has been running flawlessly for me since 11/12. Commented Aug 1, 2013 at 17:07
0

I find some good answers in this post. I have worked out a step-by-step guide on repartitioning the harddrive with a windows partition (for Windows 7/8 Bootcamp) within the first 2.2 TB space and rebuilding the fusion drive using three partitions.

You will find my guide usefull on http://jochem.ke-works.com/post/38498466700/bootcamp-on-3tb-fusion-drive-macosx

1
  • 1
    Answers on Ask Different need to be more than just a link. It's okay to include a link, but please summarize or excerpt it in the answer. The idea is to make the answer stand alone.
    – Daniel
    Commented Dec 22, 2012 at 7:17
0

Jess Bowers posted a really nice solution but it worked well for me only until this one:

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

And the output was:

Error: -69720: There is not enough free space in the Core Storage Logical Volume Group for this operation

The solution is to resize Logical Volume first. For the following command, lvUUID is the UUID of the Logical Volume and size is equal to current size of the Logical Volume - size of the Recovery partition (or 1GB less than the current size if you follow Jess Bowers' solution word by word):

diskutil coreStorage resizeVolume <lvUUID> <size>

And right after that resizeDisk... and the rest of his solution worked just like a charm.

PS. Just signed up so I can't comment directly, sorry.

0

Trying to Recover Mac Mini from Time Machine Backup

I have a Mac Mini 2012 with a ~120GB + 1TB fusion drive.

I borked it up a little while trying to install an Ubuntu dual boot and was unable to restore it from my Time Machine backup due to "There was an error creating recovery disk".

To fix that I removed all volumes of all types from the disk and started over, leaving 5gb of space for the recovery partition to be created.

Since I now know what the table ended up looking like (which I'll post back... tomorrow after the backup is restored), I'm confident that I could have done this by resizing as well.

DANGER

All of these commands are very dangerous if you have data on your disk(s).

I'm using the actual commands that I would use, which are the actual commands that someone else with a factory-installed fusion drive would need to use.

Unless the reason that you're trying to add a recovery drive happens to be that your drive is already utterly messed up, I would NOT recommend following these steps.

HOWEVER, they may come in as a handy references in addition to other instructions in these posts.

Inspecting Volumes

Look to see what's there and make proper judgements first:

# See all physical partitions
diskutil list

# See all core storage volumes
diskutil cs list

Removing all volumes

Then delete whatever needs to be deleted:

# Delete a Logical Volume
diskutil cs deleteVolume <lvUUID>

# Delete a Physical Volume
diskutil cs deleteDisk <pvUUID>

# Delete a Logical Volume Group (everything)
diskutil cs delete <lvgUUID>

Recreate the partition table from scratch, if needed:

# Re-partition and format the HDD
# `R` means Remainder
# `5G` means ~4.7GiB
diskutil partitionDisk disk0 2 GPT \
    JHFS+ Macintosh\ HD R \
    JHFS+ Recovery\ HD 5G

# Re-partition and format the SSD
# the remainder, `R`, is 100% of the usable disk space
diskutil partitionDisk disk1 1 GPT \
    JHFS+ Macintosh\ HD R

Create Core Storage

This will be "Macintosh HD" as you know and love

# Create a logical volume group named "Macintosh HD"
diskutil cs create Macintosh\ HD disk0s2 disk1

# Create a volume (of the same name) using 100% of the group
diskutil cs createVolume <lvgUUID> jhfs+ Macintosh\ HD 100%

Note: you may want to reboot at this stage to ensure that the volumes are in the right order.

Unmount all-the-things

diskutil unmount "Macintosh HD"
diskutil unmount "Recovery HD"
diskutil unmountDisk /dev/disk0
diskutil unmountDisk /dev/disk1

Free up space

The purpose of creating "Recovery HD" previously - assuming the scenario where you want to restore from a Time Machine backup - is just to reserve extra space at the end of one of the disks so that it doesn't get absorbed into any other volume.

Now it's time to free it back up so that the restore process can create it again.

First check again to see what partitions exist. The numbers should match the output of diskutil, but if not either reboot or trust gpt over diskutil.

The sizes are not listed in bytes but sectors, which are probably 4KiB. It may be better to tell which is which by ratio than by exact size.

gpt -r show /dev/disk0

Now remove the partition corresponding to "Recovery HD". After a reboot that had changed from disk0s3 to disk0s4 for me.

gpt remove -i 4

After that I stopped getting the error about not being able to create a recovery partition. I'll find out tomorrow if the TM recovery actually worked. I'm not sure it will as I don't hear much in the way of disk activity on the backup drive. :-/

Resources

Note: resizing core storage

Many of the things I looked at only showed how to resize AND create a new volume, but you can resize without creating a new volume.

# First resize the logical volume
diskutil coreStorage resizeVolume <lvUUID> 1T

# Next resize the physical volume
diskutil coreStorage resizeDisk <pvUUID> 997G

# Tada! You have free space!

Note: Set Recovery HD`s type

I was not able to get success by creating a blank recovery volume. However, if you have the BaseSystem.dmg and are able to restore it, you may want to set the volume type to be a hidden recovery partition.

# Unmount to be able to make changes
diskutil unmount /dev/disk0s3

# Change the type from Apple_HFS to Apple_Boot
asr adjust -target /dev/disk0s3 -settype Apple_Boot
-1

Here's a video outlining the process, plus some benchmarks : http://www.youtube.com/watch?v=I_odnNpv-FQ

Commands you'll need in order:

diskutil list

diskutil cs create Fusion diskx diskx

NOTE: You can replace Fusion with whatever you'd like to name your Logical Volume Group

diskutil cs list

diskutil coreStorage createVolume YOUR_DEVICE_ID_HERE jhfs+ "Macintosh Fusion" 100%

NOTE: You can replace "Macintosh Fusion" with whatver you want to name your drive. Remember to use ""'s if you want a space in your name like we did, otherwise you do not need them.

After installation is finished, open terminal and turn of indexing:

sudo mdutil -i off

If you would like to revert back to 2 separate drives, boot into the installer again, open Terminal and type:

diskutil cs delete YOUR_DEVICE_ID

You will then be able to format them however you'd like using Terminal or Disk Utility

1
  • It's not clear what you are doing here to make the recovery HD. Could you edit out the unrelated items to keep this thread lean and mean?
    – bmike
    Commented Nov 5, 2012 at 18:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .