Resizing an OSX partition on a VM hosted on ESXi.
One of the great things in vSphere 5.1 is that the Mac Pro is a fully supported server for ESXi. That means you can virtualize OSX on supported and recent hardware.
While the templating and integration is not as great as with Windows and Linux, you can deploy VMs in a reasonably short amount of time. Just make sure you don’t check the “Edit virtual hardware (Experimental)” box as it may blow your template up.
If you attempt to grow the disk, you will get a “Partition failed” error message in OSX “MediaKit reports partition (map) too small.”. No matter how many times you try it won’t work…
At this point you have 4 options:
- Build a VM from scratch (long and annoying).
- Use the terminal to move the recovery partition so you can resize the main one (hard, error prone).
- Use PartedMagic to fix the issue (free, simple and quick).
- Acquire iPartiton and let it do its magic to fix your issue (very quick).
Since I didn’t have time to place a purchase request and didn’t have much time, I used a PartedMagic iso I already had in one of my Datastores. Only to notice that the iso wouldn’t boot. This is due to the fact that OSX VMs are running in EFI boot mode only.
Fear not, there is a way to get it to boot:
- Shut your VM down.
- Right click > Edit Settings.
- Increase the disk space to the capacity you want.
- Go to the options tab, change the “Guest Operating System” to Windows and select any flavor of Windows in the drop down menu.
- Then, still in the Options screen, under “Advanced > Boot Options”, change the boot firmware from EFI to BIOS.
- Your VM should now be able to boot from the ISO.
- In PartedMagic, start Partition Editor, you should see an error message similar to this:
Click Fix. If another dialog prompts you to fix something else, click Fix again.
- Add a FAT32 partition in the empty space.
- Click Apply.
- Shut down and revert the Guest OS and Boot Firmware options.
- Boot into OSX, delete the FAT32 partition and resize your main partition.
- You’re done.