As a Mac user, you’re probably aware of Mac OS X’s “Disk Utility” program for mounting volumes, repairing permissions, creating disk images, etc. However, the command line version of the tool, “diskutil” is also very handy and has functions that aren’t available in the GUI application.
Let’s say you have 2 HFS+ partitions; 1 called “Music” on disk0s1 and the other called “Photos” on disk0s2. Then, at some point decide that you don’t want those 2 partitions separated anymore and want to combine them into one partition called “Music_and_Photos.” It’s easy with the “diskutil” tool.
Open a command line and type :
“diskutil mergePartitions hfs+ Music_and_Photos disk0s1 disk0s2”
The partition disk0s1 (Music) and the partition disk0s2 (Photos) would at this point now be merged as disk0s1 (Music_and_Photos)
Keep in mind that only HFS partitions can be merged without data loss, and that the partitions being merged must be “next to each other” in the partition map. (Meaning that if you tried to merge disk0s1 and disk0s3 that s2 which is in the middle would also be merged.) If you don’t know where each partition’s place is in the partition map, simply type “diskutil list” on the command line to find out.
More info on DiskUtil can be found HERE.