Thursday, June 13, 2013

Creating OSX FusionDrive with Recovery Partition

Today I received several 2010 model iMacs which were upgraded with an additional 3rd party SSD by an Apple reseller. The reseller created a FusionDrive by using the HDD and the SSD.

After reception, I recognized that no Recovery Partition was available. The whole disks were occupied by the CoreStorage volume.

Almost every instruction I found on the web for creating a FusionDrive was without also preserving a Recovery Partition. So I rebuilt the FusionDrive with a working Recovery Partition on my own to be as most compliant to the default stock Apple Fusion Drive configuration you get on a Mac with a preconfigured Fusion Drive. (Original Apple partitioning of a 27" late 2012 iMac Fusion Drive see end of this article).

Warning: This procedure is deleting your data from the disks! Use on own risk.
Note: Take a backup of all your data before proceeding, as all the data will be wiped. I take backups using TimeMachine and by using CarbonCopyCloner.

Prerequistes:

  • Install CarbonCopyCloner
  •  CarbonCopyCloner clone of your internal HDD to an external USB HDD (we will boot that later). If you receive a warning that no Recovery HD exists on the target USB drive, open the CarbonCopyCloner Windows > Disk Utility > Recovery HD > Select your USB drive and clone the Recovery Partition onto the USB drive.

Did I mention to take a TimeMachine Backup as well? Do that to be on the safe side.

After you made your backups, proceed with this steps:

1. Boot from your CarbonCopy USB clone by pressing the option (ALT) key during power up (or boot the recovery partition using CMD-R key after power on).
2. Start a Terminal
3. Check your current disk partitions and CoreStorage setup:

# sudo diskutil cs list 
CoreStorage logical volume groups (1 found)

|
+-- Logical Volume Group 78E316BB-911C-4456-9128-6925CDC3AE5F
    =========================================================
    Name:         FusionDrive
    Status:       Online
    Size:         1127552614400 B (1.1 TB)
    Free Space:   19023224832 B (19.0 GB)
    |
    +-< Physical Volume A3B20C13-4576-4FDF-A40D-F23BAA493C4C
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk0s2
    |   Status:   Online
    |   Size:     127691702272 B (127.7 GB)
    |
    +-< Physical Volume 2E75ED2E-909F-44AF-A58E-57F94ABAD85C
    |   ----------------------------------------------------
    |   Index:    1
    |   Disk:     disk1s2
    |   Status:   Online
    |   Size:     999860912128 B (999.9 GB)
    |
    +-> Logical Volume Family FE296C1B-9152-42FE-8C6A-40DE18D747FA
        ----------------------------------------------------------
        Encryption Status:       Unlocked
        Encryption Type:         None
        Conversion Status:       NoConversion
        Conversion Direction:    -none-
        Has Encrypted Extents:   No
        Fully Secure:            No
        Passphrase Required:     No
        |
        +-> Logical Volume 2B4753CB-7D8C-4E57-BA81-C643AE84BF4F
            ---------------------------------------------------
            Disk:               disk2
            Status:             Online
            Size (Total):       1100000002048 B (1.1 TB)
            Size (Converted):   -none-
            Revertible:         No
            LV Name:            Macintosh HD
            Volume Name:        Macintosh HD
            Content Hint:       Apple_HFS


4. Note the UUID identifier of the Logical Volume group (marked in red)
5. Split up the existing FusionDrive CoreStorageVolume. If you do not have a CoreStorage volume set up, you can skip this step

# sudo diskutil cs delete <YOUR_UUID>, example:
# sudo diskutil cs delete 78E316BB-911C-4456-9128-6925CDC3AE5F

6. Format the internal HDD using Disk Utility
7. Start CarbonCopyCloner, then open Window > Hard Disk Management. Tab on "Recovery HD", select your internal HDD volume and click on the Create Recovery-HD partition button.
8. Now it is time to create your CoreStorage Logical Volume Group. But in contrast to many instructions on the net, we will not use the whole internal HDD, but only the free partition on the HDD! It is also important to state the SSD drive as the first disk to have optimum speed.
9. Check your current paritioning:

# diskutil list
/dev/disk0
   #:                       TYPE NAME        SIZE     IDENTIFIER
   0:      GUID_partition_scheme             *128.0GB disk0
   1:                        EFI             209.7 MB disk0s1
   2:                  Apple_HFS Untitled    127.7 GB disk0s2
/dev/disk1
   #:                       TYPE NAME        SIZE     IDENTIFIER
   0:      GUID_partition_scheme             *1.0 TB  disk1
   1:                        EFI             209.7 MB disk1s1
   2:                  Apple_HFS hdd         999.2 GB disk1s2
   3:                 Apple_Boot Recovery HD 784.2 MB disk1s3

/dev/disk3
   #:                       TYPE NAME        SIZE     IDENTIFIER
   0:                  Apple_HFS CarbonCopy  *998.7GB disk4

The partition disk1s2 is the free partition on the internal disk we will use for the FusionDrive.
The partition disk1s3 is the newly created Recovery Partition.

10. Create a new CoreStorage Volume. Disk0 in this example is the SSD drive.

# sudo diskutil cs create FusionDrive disk0 disk1s2
Password:
Started CoreStorage operation
Unmounting disk0
Repartitioning disk0
Unmounting disk
Creating the partition map
Rediscovering disk0
Adding disk0s2 to Logical Volume Group
Unmounting disk1s2
Touching partition type on disk1s2
Adding disk1s2 to Logical Volume Group
Creating Core Storage Logical Volume Group
Switching disk0s2 to Core Storage
Switching disk1s2 to Core Storage
Waiting for Logical Volume Group to appear
Discovered new Logical Volume Group "71377E10-7126-4E7B-A52D-F96F383F56BA"
Core Storage LVG UUID: 71377E10-7126-4E7B-A52D-F96F383F56BA
Finished CoreStorage operation

11. Now create the CoreStorage Logical Volume:
Note the LVG UUID printed by the command in step 10 (marked in red) and use that id:

diskutil cs createVolume <YOUR_LVG_UUID> jhfs+ "Macintosh HD" 100%

Example:
diskutil cs createVolume 71377E10-7126-4E7B-A52D-F96F383F56BA jhfs+ "Macintosh HD" 100%

Started CoreStorage operation
Waiting for Logical Volume to appear
Formatting file system for Logical Volume
Initialized /dev/rdisk6 as a 1 TB HFS Plus volume with a 90112k journal
Mounting disk
Core Storage LV UUID: 04085D2E-D630-4EED-BED4-B0EFDF6C7834
Core Storage disk: disk6
Finished CoreStorage operation


11a. Check the CoreStorage setup:

#diskutil cs list
CoreStorage logical volume groups (3 found)
|

+-- Logical Volume Group 71377E10-7126-4E7B-A52D-F96F383F56BA
    =========================================================
    Name:         FusionDrive
    Status:       Online
    Size:         1126902611968 B (1.1 TB)
    Free Space:   73728 B (73.7 KB)
    |
    +-< Physical Volume 4512A812-D998-4A45-AF5E-CB6F8EE4BD2D
    |   ----------------------------------------------------
    |   Index:    0
    |   Disk:     disk0s2
    |   Status:   Online
    |   Size:     127691702272 B (127.7 GB)
    |
    +-< Physical Volume 2344BA4E-2460-4631-B52A-BFFB6DBBA9C7
    |   ----------------------------------------------------
    |   Index:    1
    |   Disk:     disk1s2
    |   Status:   Online
    |   Size:     999210909696 B (999.2 GB)
    |
    +-> Logical Volume Family 6994CC0B-958C-4CF1-A4BF-7B7553478619
        ----------------------------------------------------------
        Encryption Status:       Unlocked
        Encryption Type:         None
        Conversion Status:       NoConversion
        Conversion Direction:    -none-
        Has Encrypted Extents:   No
        Fully Secure:            No
        Passphrase Required:     No
        |
        +-> Logical Volume 04085D2E-D630-4EED-BED4-B0EFDF6C7834
            ---------------------------------------------------
            Disk:               disk6
            Status:             Online
            Size (Total):       1118375247872 B (1.1 TB)
            Size (Converted):   -none-
            Revertible:         No
            LV Name:            Macintosh HD
            Volume Name:        Macintosh HD
            Content Hint:       Apple_HFS

12. Start CarbonCopyCloner and clone back the USB boot drive to your newly created FusionDrive (named "Macintosh HD" in step 11).
13. Reboot your system and try to boot the recovery partition by pressing the ALT key during reboot.
14. Reboot your system from the FusionDrive.
15. Enable Trim support, to keep your SSD speed high over time. You can patch the OSX driver yourself, or you use tools like http://www.groths.org/trim-enabler/ or Chameleon Trim Enabler.



For reference, here is the partition printout of a stock Apple 2012 iMac with original FusionDrive configuration:
# diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *121.3 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:          Apple_CoreStorage                         121.0 GB   disk0s2
   3:                 Apple_Boot Boot OS X               134.2 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk1
   1:                        EFI                         209.7 MB   disk1s1
   2:          Apple_CoreStorage                         999.3 GB   disk1s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk1s3
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           *1.1 TB     disk2