Cannot remove bootcamp partition

bootcampdisk-utilitypartition

My mac (running El Capitan) has recently run out of storage space so I have been trying to remove my bootcamp partition to restore the full capacity of the OS X partition.

When I try to remove it through the bootcamp assistant I receive a message saying

An error occurred while verifying the file system. Please reboot into
recovery, repair the disk with Disk Utility, then try the operation
again.

I have tried to boot into recovery and repair the disk, however, it says everything has been repaired and the bootcamp assistant still fails.

After this I went into terminal and ran diskutil list with the output:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            174.4 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   4:       Microsoft Basic Data BOOTCAMP                75.6 GB    disk0s4
/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           +174.0 GB   disk1
                                 Logical Volume on disk0s2
                                 01CA9FDB-EE71-4B65-9216-2A7EB5CBA511
                                 Unlocked Encrypted

Next, I tried to erase the disk with diskutil eraseVolume fat32 BOOTCAMP disk0s4 which worked, however, I am still unable to merge the partition in Bootcamp assistant and I am given the same error message.

Any ideas on how to merge the partitions and remove the Bootcamp partition?

Best Answer

This answer has been posted many times before. Why not once more. The commands are given below.

diskutil  eraseVolume  free  n  disk0s4
diskutil  cs  resizeStack  01CA9FDB-EE71-4B65-9216-2A7EB5CBA511  0

If any of the above commands fail, you can try to repair macOS volume by entering the following command.

sudo diskutil repairVolume disk0s2

If the repair command does not resolve issues, then you have the following options:

  • Erase the disk and reload from a time machine backup.
  • Backup your files, reformat the partition, reinstall the macOS, the reload your files.