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 -


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!

Monday, 10 October 2011

MacBook Air and Filevault 2 won't sleep together

I've just got a new MacBook Air and I'm not sure if it is mourning Steve's passing last week :( but I've been having a lot of trouble getting it to wake up from hibernate. Hibernate is the state that (by default) the computer will go into when it runs out of battery (after the reserve power warning appears).

In this state it will immediately write the contents of memory to a swapfile on the solid state storage - by default to /var/vm/sleepimage. My theory is that there is a race condition with Filevault that may corrupt the memory image whilst both processes try to do their stuff on the storage. When the MacBook is plugged into a power source and the power button is pressed, the backlight lights but the screen stays black. I can see the backlight through the Apple logo on the lid. It stays in this state forever and needs to be hard reset by holding power for 10 seconds, releasing and pressing it again to switch the computer back on.

I actually brought the MacBook Air back to the Apple Store and got a replacement which exhibits the same problem, so with the second one I did a little bit of experimentation to narrow down on the root cause. I did the following -
  1. A complete Lion clean install (Command-R at bootup).
  2. Let the battery run dry, MacBook Air hibernates and wakes successfully after applying power.
  3. Applied Filevault.
  4. Let the battery run dry, MacBook Air hibernates and crashes on wake after applying power.
  5. Reset both PRAM and the SMC - neither helped.
It's pretty clear Filevault is the problem.

The Workaround

To work around this until Apple (hopefully) fix what is quite a glaring problem (happened on 2 MacBook Airs for me) it is possible to turn off hibernation. This means that the machine will only sleep - contents of memory remain in RAM which remains powered for as long as the battery holds up. Remember, this differs from "SafeSleep" or hibernate - it persists memory to flash storage so that even if the battery runs out, the memory image can be restored and you can just carry on with your work.
  • First off, check your existing hibernate mode (it will usually be 3 - the default)
Open a Terminal window and type -

sudo pmset -g | grep hibernatemode
Password: <enter password>
hibernatemode 3
  • Look at the man page for pmset to see the valid hibernate modes -

    man pmset

    The relevant part -

    We do not recommend modifying hibernation settings. Any changes you make are not supported. If you choose to do so anyway, we recommend using one of these three settings. For your sake and mine, please don't use anything other 0, 3, or 25.

    hibernatemode = 0 (binary 0000) by default on supported desktops. The system will not back memory up to persistent storage. The system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep.

    hibernatemode = 3 (binary 0011) by default on supported portables. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from disk image.

    hibernatemode = 25 (binary 0001 1001) is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want "hibernation" - slower sleeps, slower wakes, and better battery life, you should use this setting.

  • The crash happens for both hibernatemode 3 and 25 (I've tested both). To set hibernatemode to 0 (i.e. turn it off) use the following command -

    sudo pmset -a hibernatemode 0

  • And to switch it back to the default -

    sudo pmset -a hibernatemode 3
Hopefully Apple fix this one soon. With the workaround about just bear in mind that if you go into sleep after the reserve power warning you will have some leeway to get to power, but don't leave it a really long time otherwise you could end up losing work. Best to save if you hit reserve power anyway.

As a side effect of this change it is possible to remove the safe sleep image (which is exactly the size of the memory on your MacBook Air) as obviously Lion won't write to it with hibernation turned off -

sudo rm /var/vm/sleepimage

All these steps at your own risk, but it works for me. Other posts on this topic can be found here -

Apple Discussion 1
Apple Discussion 2

UPDATE Should have mentioned that this testing was done on Mac OS X Version 10.7.1 and I've tested hibernatemode 3 on 10.7.2 and see the same behaviour - so no bug fix yet :(

UPDATE Bug filed at the Apple Bug Reporter (#10288882)

UPDATE Macbook Air EFI 2.3 fixed this issue for me!

Saturday, 8 October 2011

So long Steve and thanks for all the Lulz

5th October was a sad day - Steve Jobs passed away.

I was walking through the Apple Store yesterday and although I had been thinking that Steve's biggest legacy was his contribution to defining the PC market as it is today, something else struck me.  Upstairs a grandmother with her grandson was setting up her first iPad 2, helped by an Apple Store employee.  I walked downstairs and passed an iPad 2 demonstration.  The audience was full of people aged between 60 and 70, all following along on their iPads.  

When I got home, my daughter was playing her games on her iPad - working with the touch screen like she had been born with it.

I think Steve's legacy was really his ability to make technology and communication span generations and make the experience accessable to all.  I'm not sure we have anyone to take his place.  RIP Steve.

Friday, 15 April 2011

Bob's Most Useful Apps - Part 1- Camscanner+

Camscanner+ is a really clever idea that can be used in a number of ways to improve your day to day workflow. At it's heart it is a really simple app - take photos of anything - documents, whiteboards, receipts - and Camscanner+ will store images of them on your phone for later reference.

Thats not all though. First off, Camscanner+ will enhance images with a clever algorithm that identifies only the relevant part of an image and zooms, flattens and centres the subject to produce a very readable document. After that, it applies an enhancement filter to up the clarity of the final image.


Take a photo of a document or receipt...

... and Camscanner+ automatically enhances and aligns the image

The application also allows folder based grouping of documents so that you can, for example, record all the receipts for a particular business trip together. You can also add metadata tags to the content to further categorise documents.


Camscanner+ folder view

The app has a large number of export options to choose from. As well as the usual email option, Camscanner+ integrates Google Docs, Evernote, iDisk,, Dropbox. My favourite workflow is scanning all my receipts for a particular business trip into a folder, exporting a PDF of all the documents in the folder to Dropbox for safekeeping and then sending that directly to our expenses people for remittance. No more posting receipts for me! My only complaint is that it appears to be impossible to control the image size of the documents within the PDF, potentially creating a very large file depending on the number of documents you have.

The other great use for Camscanner+ is scanning whiteboards and the enhancement tools generally produce a very clear result. If you are looking for something to quickly scan documents, receipts and diagrams Camscanner+ is the tool of choice.

Camscanner+ can be found on the Apple App Store for £2.99.  I'm not affiliated with the app in any way ... I just really like it!


Sunday, 20 February 2011

This week vs last

I was in Lanzarote last week, weather much the same as this.

And this week I'm back home and can look forward to this.

Enough said...


Tuesday, 20 April 2010

The Big Wheel Test continues...

A major test this weekend for the new Harry Rowland wheels - towing a Chariot child trailer with baby inside. No problems yet after 4 commutes with alot of curb bumping and the towing. Whilst heavy, the wheels are definitely strong and smooth. I reckon it'll take about 3 months for a full long term test but so far I'm impressed.

As far as the trailer goes, it's amazing! Really comfortable for the baby with good safety harnesses. Folds down and wheels are removable to fit in the boot. It is a bit heavy but that just adds to the training!