Monday 16 December 2013

Clean Installation of a Fusion Drive equipped Mac

Arrgghh!  I have just been through the pain of a Fusion drive logical volume group having some unallocated space, and not being able to reclaim it through Disk Utility.  How I got there is a long story involving many failed attempts at installing Bootcamp Windows 8, and I'm not going to go into it because at the moment it is too painful...  Just one lesson - don't create unallocated space on a Fusion Drive (or perhaps any other configuration) as you may not be able to reclaim it without erasing the drive.

The situation with the unallocated space is apparently a "feature" of Mac OS X's recovery partition.  On my 1TB physical disk I had 3 partitions -

1.  The EFI boot partition.
2.  The bulk of the actual disk for real files.
3.  The hidden recovery partition <-- this is between 2 and 4 and prevents 2 from being resized to absorb the unallocated space.
4.  Some unallocated space.

So to fix this, I decided to go the extreme route and reformat the hard drive and reinstall Mac OS X.  Not as easy as it sounds.  A reformat of the "drive" really only reformats (2) - as the EFI and recovery partitions are hidden in Disk Utility.  You'll get the same problem even if you boot into recovery with Command-R or Internet Recovery with Command-Shift-R.

To actually reformat an entire Fusion Drive, the easiest thing to do is break the Fusion Drive and then open Disk Utility.  Disk Utility detects to bad state of the Fusion Drive and can restore the Logical Volume Group and Logical Volume configuration for you.

Do this -

1. Boot to Internet Recovery - hold down Command-Alt-R when you hear the boot chime.
2. Open Terminal under the Utilities menu.
3. Issue the command -

diskutil cs list

4.  Find the UUID after the text "Logical Volume Group" and copy it -
5.  Issue the command -

* WARNING THIS WILL ERASE DISKS IN YOUR VOLUME GROUP AND YOU WILL LOSE DATA *

diskutil cs delete <Paste UUID>

6.  Exit Terminal and return to Disk Utility.
7.  Disk Utility will see that the drive configuration is incorrect.  When prompted allow it to repair the Fusion Drive - practically this is creating a Logical Volume Group again, containing your SSD and physical hard disk.

Now that's done it's time to get the OS up and running again.  These are the instructions for a Time Machine backup -

1.  Exit Disk Utility.
2.  If your Time Machine backup is from a different version of OS X from your Recovery Partition forget about restoring from it directly in recovery.  e.g. I had a Mavericks backup, and my recovery partition/Internet recovery has Mountain Lion.  If you do the restore from the Time Machine backup, it will look like it has worked, but on reboot it will boot straight back to the recovery partition.
3.  Choose a full install of OS X.
4.  Once the full install completes go through the setup - create a temporary user so that when Time Machine restores your original user, the names won't clash!
5.  Immediately go to the App Store and upgrade to the latest OS (the one that matches your Time Machine Backup) e.g. in my case Mavericks.
6.  Once upgraded, open the Migration Assistant.
7.  Select the Time Machine option, select your backup and proceed with the restore.  This is when you wish you had a Thunderbolt external drive.
8.  Once the restore finishes, log in as your old user, ensure they have administrator rights and then delete the temp user using System Preferences.

Done.  Now never mess around with unallocated space again!