This command allows you to merge two or more existing partitions into one. The partitions will be merged and all data will be lost except for the first one. Run the command diskutil mergePartitions for more details.
Steps I used to extend my partition are explained below. The commands below are for my disk setup and may have to be modified to suit your configuration.
1) Show the partitions installed on your mac:
macbook-pro:~ mactimes$ sudo diskutil list
Password:
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.1 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS MacBook 449.8 GB disk0s2
3: Microsoft Basic Data WINDOWSXP 50.0 GB disk0s3
2) Merge the partitions by running the following command. Be very careful of the syntax and order.
macbook-pro:~ mactimes$ sudo diskutil mergePartitions "Journaled HFS+" New disk0s2 disk0s3
Password:
Merging partitions into a new partition
Start partition: disk0s2 MacBook
Finish partition: disk0s3 BOOTCAMP
Started partitioning on disk0
Merging partitions
Waiting for disks to reappear
Growing disk
Finished partitioning on disk0
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *500.1 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS MacBook 499.8 GB disk0s2
Once done, you will see that the partition table has been merged and you are able to recover the wasted space of your Boot camp partition.