Merge partitions with Macintosh HD This is my diskutil list.

I wish to merge Misc (disk0s4) with Macintosh HD (disk0s2) leaving only Macintosh HD (disk0s2). Normally I would use this command to merge the two disks:

diskutil mergePartitions HFS+ Macintosh HD disk0s2 disk0s4


But, I am not sure whether this command will format my Macintosh HD which I do not want. Misc (disk0s4) is already formatted and thus empty. But Macintosh HD (disk0s2) can not get erased.

Can I securely use the command to merge the two disks?

System information:
OS X El Capitan, version 10.11.3
diskutil  erasevolume  "Free Space"  ""  /dev/disk0s4
diskutil  resizevolume  /dev/disk0s2  R


The first command will remove partition /dev/disk0s4.

The second command will move /dev/disk0s3 to the bottom of disk0 while resizing /dev/disk0s2 to maximum size.