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.

18
Leave a Reply

Please Login to comment
12 Comment threads
6 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
13 Comment authors
jonny_sattsthombamfordAkshat Recent comment authors

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

  Subscribe  
newest oldest most voted
Notify of
Member
Steve Gringer

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
Member
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 »

Member
thombamford

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

Akshat
Member
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
Member
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

Member
WonderBrad

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

Member
Javier Rugel

Exactly the same problem here, trying to install bootcamp.

Member
Javier Rugel

*when trying to install bootcamp

Member
Tyler Rheaume

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.

Member
sebastianginter

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

Member
Travis Jacob

please

Member
Travis Jacob

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