How to Resize Your APFS Container on macOS High Sierra

2 minute read
| Deep Dive

If you’re running one of the macOS High Sierra betas and have tried to resize your APFS container without success, I’ve got the answer for you. You can’t currently do this from Disk Utility, so it requires some Terminal geekery. Of course, if you haven’t already migrated over to APFS, you might want to look into that first, with the help of John Martellaro.

resize your apfs partition

You’ve moved over to APFS under the High Sierra beta, and want to resize that partition, so here’s what you need to do (Image Credit: Pagefact)

Finding Where Your APFS Partition Lives

I’m confident that by the time High Sierra ships in the fall, this will be possible within the graphical Disk Utility. It’s a pretty common requirement, so Cupertino is bound to incorporate it more easily into the final version of macOS 10.13 High Sierra. For now, though, the Terminal is our friend.

To do this, you’ll need to open Terminal from Applications -> Utilities. Once there, issue this command to find out where your APFS container lives:

diskutil list

My output looks like the image below. Note that my APFS container is named /dev/disk1, and resides at /dev/disk0s2.

Locate, then resize your APFS container

Locating your APFS container prior to resizing it

Resizd Your APFS Container (the Hard Way)

Let’s talk about shrinking the APFS partition, or container, first. You use the same command for both processes, but you might be likely to want to reduce the size of your APFS partition first, perhaps to install another operating system on your Mac. To shrink my 1TB APFS container to 750GB, I’d issue the following command in Terminal:

sudo diskutil apfs resizeContainer disk0s2 750g jhfs+ Extra 250g

That command would resize the APFS container from 1TB to 750GB, also creating a 250GB journaled HFS+ partition with the freed space. We need to use sudo here, to take administrative privileges over the Terminal session.

I could have also issued the command like this, and diskutil would automatically determine the size for my new partition:

sudo diskutil apfs resizeContainer disk0s2 750g jhfs+ Media 0b

The output of the command will look something like this:

Resize your APFS container from Terminal

Resize you APFS container from Terminal

I could also create multiple partitions, using a command like this:

sudo diskutil apfs resizeContainer disk0s2 750g jhfs+ Media 200g FAT32 Windows 50g

Note that in my case, I could replace disk0s2 with disk1 for either command, since my APFS container is located at disk1. The diskutil command automatically locates the physical store for my APFS container, and resizes things accordingly.

Shrinking Your APFS Partition to Reclaim Space

If you decide you want to reclaim that space into your APFS container, you can do that using diskutil as well. First, though, you have to delete the JHFS+ or other partition and set it as free space on your hard drive. This command will do the trick, assuming your volume is named disk0s3.

sudo diskutil eraseVolume "Free Space" %noformat% /dev/disk0s3

Next, resize your APFS container:

diskutil apfs resizeContainer disk0s2 0

In this case, diskutil automatically claims all available free space on the physical storage device, but you can also replace 0 with a size value.

Yes, You Can Resize Your APFS Container on a Live Filesystem

Before you ask, yes, I’ve verified this process works even when you’re booted into High Sierra on that APFS volume. You will notice that your Mac becomes unresponsive for a time, as it verifies the filesystem, checks everything out, and then carries out the resize operation. For the best file integrity, though, I’d probably recommend doing this from Recovery Mode. I live on the bleeding edge, though, and did this from the live filesystem without any data corruption.

Subscribe
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

19 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
musdscience

I understand this is an old thread, but I figured I would chance it anyways. It would be great to see the same example but with an existing BootCamp partition in place within the APFS container to use unallocated space outside of the APFS container to expand. Attempts to use these command lines with a High Sierra partition and its associated BootCamp volume to increase the APFS container to use unallocated space were unsuccessful. BootCamp partition, in this instance, was after the High Sierra volume, after which, was the unallocated space of a larger drive this MacOS High Sierra with… Read more »

Hi Jeff, could you please check what i did wrong? Thanks! diskutil list /dev/disk0 (internal, physical): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *240.1 GB disk0 1: EFI EFI 209.7 MB disk0s1 2: Apple_APFS Container disk1 119.8 GB disk0s2 /dev/disk1 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme – +119.8 GB disk1 Physical Store disk0s2 1: APFS Volume Mac 116.1 GB disk1s1 2: APFS Volume Preboot 19.4 MB disk1s2 3: APFS Volume Recovery 509.8 MB disk1s3 4: APFS Volume VM 2.7 GB disk1s4 PC192-168-1-201:~ Steve$ diskutil apfs resizeContainer disk0s2 0 Started APFS operation Error: -69743: The new size… Read more »

jonny_satts

Hi Jeff, I have been having huge problems even when trying to follow the instructions here and in other APFS related posts. What is unusual for me is that the rogue partition doesn’t appear as an external disk. After erasing it following instructions you gave it converted from APFS and resides now (in disk utility) as: “PCI-Express Internal Physical Volume • Mac OS Extended (Journaled)”. It can be mounted and unmounted but not much else. Here is what I am looking at from the terminal: Jons-MacBook-Pro-2:~ jonsatterley$ diskutil list /dev/disk0 (internal): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme 500.3 GB… Read more »

Was getting quite frustrated before I found this article. Thank you for posting! Worked like a charm.

Akshat

Hi Jeff, I have encountered a peculiar problem. I tried enable writing on my NTFS formatted external drive using Terminal. This is the code I used – sudo nano /etc/fstab LABEL=NAME none ntfs rw,auto,nobrowse Then Ctrl+O, enter and Ctrl+X I didn’t succeed in that, contrary my Mac would hang every time I’d click on Finder after a reboot. So I decided to follow the article and delete the entry I made in fstab and saving and exiting it. After that, I see my disk utility is not listing any disks at all. I can boot the Mac and use all… Read more »

iaboeyad

Hi Jeff.

Thank you for the explanation, it is really helpful

Can I remove disk0s2 and merge it with disk0s4 ?
disk0s2 was my old OS, now I installs OSX on disk0s4 I want to merge disk0s2 into disk0s4 ? is that possible or it should be in order ?

Thanks

Hi Jeff,

When I try to resize the APFS container and create a new volume, using your first example, I get the error:

APFS Container Resize error code is 49153
Error: -69606: A problem occurred while resizing APFS Container structures

Have you come across this before?

Thanks,
Brad

Exactly the same problem here, trying to install bootcamp.

*when trying to install bootcamp

Hi Jeff, Thank you so much for your analysis. And I believe it’s correct. I had this knowledge for HD but the fact that it also applies to SSD didn’t hit me until I read your comment. My problem in short: disk0 (non-APFS logical partition) and disk1 (APFS system drive). disk1 ran out of space. No matter how I re-format/erase disk0, I cannot extend disk1 to use that space. Because disk1 is the last partition, and a partition can only extend “forward”. Here’s what I did to solve the issue: 0. Backup data on your logical partition. (In my case… Read more »

I am getting the error “Error: -69771: The target disk is too small for this operation” when running the last command. I am positive that I have the command correct and I have the APFS container selected.

Hi,
I have a q.
How to delete partition with APFS.? When i try delete from DiskUtility from Sierra Recovery Partition system tell me “cant umnount a disk” (this is the same disk – I have only one 128gb ssd with 3 partitions – Sierra, APFS High sierra and recovery sierra”. Can’t do this!
And can’t resize partition APFS. I have only 25gb and can’t resize to 35GB!.
It’s SAFE ?
Regards
Sebastian

please

polr

Hi Jeff,

I’m having the same issue as Travis, using your latest edit wit the non-curly quotes.

Any idea what might be the issue?

Thanks!
Paul

When I do the final step to claim free space, I get an error saying the target disk is too small for this operation

please help