I tried to install Ubuntu on my MacbookPro (mid 2015, OS X Yosemite) dual boot, using the following: How to Dual-Boot OS X and Ubuntu (PDF)

I was finishing up part 3 and Ubuntu was starting to download, until everything froze. Nothing was responding so I force shutdown my computer and now OS X seems to be working fine. However I have a partition disk0s3 (Linux Swap) and a bunch of Free Space I can't get rid of.

#:                       TYPE NAME                    SIZE       IDENTIFIER
0:      GUID_partition_scheme                        *251.0 GB   disk0
1:                        EFI EFI                     209.7 MB   disk0s1
2:                  Apple_HFS Macintosh HD            182.6 GB   disk0s2
3:                 Linux Swap                         16.4 GB    disk0s3

I tried getting rid of them through Internet Recovery but that didn't work either. How can I get rid of the partition and the Free Space?

2 Answers 2


If you are using El Capitan (OS X 10.11), then the document you are referencing will not work as expected.

As for your question. The command below will remove the Linux Swap partition.

sudo diskutil erasevolume "Free Space" "" /dev/disk0s3

The next command expands your Macintosh HD volume to contain the free space.

sudo diskutil resizevolume /dev/disk0s2 R

Note: I am not sure if the prefix sudo is necessary. (But, it will do no harm if you include the sudo)

  • The first command didn't work (something about not being able to find that partition) but the second command got rid of the Free Space. Aug 6, 2016 at 17:36
  • What version of OS X are you using? Yosemite (OS X 10.10) will generate an error message when the first command is used, but the command still removes the partition. Aug 6, 2016 at 17:39
  1. Try: open Disk Utility, select the Linux Swap partition, in the toolbar there should be a delete disk option, try that, and try to remove the partition.

  2. If 1 didn't work, try use First Aid in Disk Utility (first on the partition and then on the main drive)

  3. If 2 didn't work, try to boot in to Recovery Mode, select Disk Utility from the menu, and try option 1 and 2 again.

  • In DiskUtility, I selected the partition and choose "Erase" at the top. But it failed with the error "MediaKit reports no such partition." Aug 6, 2016 at 17:16
  • Did you try in recovery mode?
    – Harcker
    Aug 6, 2016 at 17:17
  • Recovery mode wasn't able to start up. The estimated time to start kept going up. David's solution worked for me, however Aug 6, 2016 at 17:35
  • You have no recovery partition to boot to. If you did, then the partition would have appeared in your posted output of the diskutil list command. Aug 6, 2016 at 17:44
  • Actually, the OS X Recovery over the Internet keys are Command-Option-R. Other key combinations can be found at the Apple web site: Startup key combinations for Mac. Aug 7, 2016 at 3:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .