MacOS – How to merge System partition with another HFS+ partition without data loss

disk-utilityhard drivemacospartition

My hard drive is split in three visible partitions: System, Data and Backup.
I'd like to merge System (OS X Lion) and Data into one partition without data loss.

Disk Utility won't let me resize the system partition:

partitions in disk utility

That's my complete setup:

enter image description here

Apparently, I can't use mergePartitions because diskutil man says:

mergePartitions [force] format name fromDevice toDevice

Merge two or more partitions on a disk.
All data on merged partitions other than the first will be lost.

I can imagine decreasing Data size, creating a New partition, moving all files from Data to New and proceeding with mergePartitions, thus merging System and Data into System+Data. Then I probably can move stuff from New to the merged System+Data partition and merge them all.

However I'm unsure what will happen to Recovery HD that stands between System and Data. Will it get erased? If so, how can I restore it?

Best Answer

There is absolutely no way that you should even think about doing any of this without a complete backup on a separate disk. Verify the backup before beginning.

1) If you have a complete backup, the easiest way to do this would be to wipe everything, make the partitions you want, and then copy the information back from your backup. If your Recovery HD is deleted, there is no way to re-create it without reinstalling the OS. (At least none that I could find when I was searching recently.)

2) Assuming you have a backup OTHER than that Backup partition, if you want to attempt to merge these, I would try it in this order:

a. Delete the 'Backup' partition.

b. Merge 'Data' partition and former 'Backup' partition.

c. Merge System partition and other partition.

d. Re-create the 'Backup' partition and restore it from whatever backup you have.

I have done several live-system partition resizings with no problems. However, the one time that there was a problem, I had to reformat the entire drive and start over.