MacOS – Can an APFS volume be moved

apfsmacosmojave

I have two APFS volumes on one disk. I wanted to shrink them to make a new volume for Bootcamp, but shrinking each one has left the free space separated.

Is there a way to move the second volume forward or backwards to combine the free space I've created?

current partition layout

  $ diskutil list
/dev/disk0 (internal):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                         1.0 TB     disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk2         500.0 GB   disk0s2
   3:                 Apple_APFS Container disk1         101.0 GB   disk0s3
   4:                 Apple_APFS Container disk3         350.0 GB   disk0s4
   5:                 Apple_APFS Container disk4         49.3 GB    disk0s5

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +101.0 GB   disk1
                                 Physical Store disk0s3
   1:                APFS Volume Untitled                2.1 MB     disk1s1

/dev/disk2 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +500.0 GB   disk2
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            343.9 GB   disk2s1
   2:                APFS Volume Preboot                 23.7 MB    disk2s2
   3:                APFS Volume Recovery                515.0 MB   disk2s3
   4:                APFS Volume VM                      5.4 GB     disk2s4

/dev/disk3 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +350.0 GB   disk3
                                 Physical Store disk0s4
   1:                APFS Volume Games                   253.2 GB   disk3s1
   2:                APFS Volume Preboot                 52.1 MB    disk3s2
   3:                APFS Volume Recovery                517.0 MB   disk3s3
   4:                APFS Volume VM                      1.1 GB     disk3s4

/dev/disk4 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +49.3 GB    disk4
                                 Physical Store disk0s5
   1:                APFS Volume Untitled                1.8 MB     disk4s1

/dev/disk5 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        +322.1 GB   disk5
   1:                        EFI EFI                     209.7 MB   disk5s1
   2:                  Apple_HFS tm-dhawke-mac           321.8 GB   disk5s2
$ diskutil apfs list
APFS Containers (4 found)
|
+-- Container disk1 00C000F2-BA75-4A4D-9132-31C112F3E0EA
|   ====================================================
|   APFS Container Reference:     disk1
|   Size (Capacity Ceiling):      100989980672 B (101.0 GB)
|   Capacity In Use By Volumes:   126013440 B (126.0 MB) (0.1% used)
|   Capacity Not Allocated:       100863967232 B (100.9 GB) (99.9% free)
|   |
|   +-< Physical Store disk0s3 B2E63010-C52A-43F8-B31E-852C867908E3
|   |   -----------------------------------------------------------
|   |   APFS Physical Store Disk:   disk0s3
|   |   Size:                       100989980672 B (101.0 GB)
|   |
|   +-> Volume disk1s1 92BABD1E-8102-4810-B423-FA8E4D07C034
|       ---------------------------------------------------
|       APFS Volume Disk (Role):   disk1s1 (No specific role)
|       Name:                      Untitled (Case-insensitive)
|       Mount Point:               Not Mounted
|       Capacity Consumed:         2076672 B (2.1 MB)
|       FileVault:                 No
|
+-- Container disk2 6D03E285-ABE4-4FEF-8A60-E0DB057B6F8A
|   ====================================================
|   APFS Container Reference:     disk2
|   Size (Capacity Ceiling):      499999997952 B (500.0 GB)
|   Capacity In Use By Volumes:   349957828608 B (350.0 GB) (70.0% used)
|   Capacity Not Allocated:       150042169344 B (150.0 GB) (30.0% free)
|   |
|   +-< Physical Store disk0s2 84CBF38D-9B66-492C-BE77-45360E1F1D98
|   |   -----------------------------------------------------------
|   |   APFS Physical Store Disk:   disk0s2
|   |   Size:                       499999997952 B (500.0 GB)
|   |
|   +-> Volume disk2s1 84F55A00-849E-3555-B407-07DE1C150CCD
|   |   ---------------------------------------------------
|   |   APFS Volume Disk (Role):   disk2s1 (No specific role)
|   |   Name:                      Macintosh HD (Case-insensitive)
|   |   Mount Point:               Not Mounted
|   |   Capacity Consumed:         343888941056 B (343.9 GB)
|   |   FileVault:                 Yes (Locked)
|   |
|   +-> Volume disk2s2 D51FC5E9-5E22-46C6-8093-746FDDBA59D9
|   |   ---------------------------------------------------
|   |   APFS Volume Disk (Role):   disk2s2 (Preboot)
|   |   Name:                      Preboot (Case-insensitive)
|   |   Mount Point:               Not Mounted
|   |   Capacity Consumed:         23707648 B (23.7 MB)
|   |   FileVault:                 No
|   |
|   +-> Volume disk2s3 88F3D613-4637-4485-8BCA-0DC325F37AAE
|   |   ---------------------------------------------------
|   |   APFS Volume Disk (Role):   disk2s3 (Recovery)
|   |   Name:                      Recovery (Case-insensitive)
|   |   Mount Point:               Not Mounted
|   |   Capacity Consumed:         514990080 B (515.0 MB)
|   |   FileVault:                 No
|   |
|   +-> Volume disk2s4 49FD5E60-9F57-4043-9B3E-25741FFB8385
|       ---------------------------------------------------
|       APFS Volume Disk (Role):   disk2s4 (VM)
|       Name:                      VM (Case-insensitive)
|       Mount Point:               Not Mounted
|       Capacity Consumed:         5368737792 B (5.4 GB)
|       FileVault:                 No
|
+-- Container disk3 6E4EF914-EFAB-47B9-A424-A86FFDCC8B44
|   ====================================================
|   APFS Container Reference:     disk3
|   Size (Capacity Ceiling):      349999996928 B (350.0 GB)
|   Capacity In Use By Volumes:   251810066432 B (251.8 GB) (71.9% used)
|   Capacity Not Allocated:       98189930496 B (98.2 GB) (28.1% free)
|   |
|   +-< Physical Store disk0s4 2BC6F79E-C8B9-49DE-BCDE-37D4D30C1960
|   |   -----------------------------------------------------------
|   |   APFS Physical Store Disk:   disk0s4
|   |   Size:                       349999996928 B (350.0 GB)
|   |
|   +-> Volume disk3s1 D3BEFD7E-0CC9-30EC-B21A-9ABAB9340CE5
|   |   ---------------------------------------------------
|   |   APFS Volume Disk (Role):   disk3s1 (No specific role)
|   |   Name:                      Games (Case-insensitive)
|   |   Mount Point:               /
|   |   Capacity Consumed:         250019598336 B (250.0 GB)
|   |   FileVault:                 Yes (Unlocked)
|   |
|   +-> Volume disk3s2 4FD2FB71-E249-431A-90E1-25B8F3594425
|   |   ---------------------------------------------------
|   |   APFS Volume Disk (Role):   disk3s2 (Preboot)
|   |   Name:                      Preboot (Case-insensitive)
|   |   Mount Point:               Not Mounted
|   |   Capacity Consumed:         52137984 B (52.1 MB)
|   |   FileVault:                 No
|   |
|   +-> Volume disk3s3 DC708E4E-98B7-4FC8-A740-91C000A24345
|   |   ---------------------------------------------------
|   |   APFS Volume Disk (Role):   disk3s3 (Recovery)
|   |   Name:                      Recovery (Case-insensitive)
|   |   Mount Point:               Not Mounted
|   |   Capacity Consumed:         516988928 B (517.0 MB)
|   |   FileVault:                 No
|   |
|   +-> Volume disk3s4 6C922CFE-507C-41C5-A649-56ED4AD35D54
|       ---------------------------------------------------
|       APFS Volume Disk (Role):   disk3s4 (VM)
|       Name:                      VM (Case-insensitive)
|       Mount Point:               /Volumes/VM
|       Capacity Consumed:         1073762304 B (1.1 GB)
|       FileVault:                 No
|
+-- Container disk4 AF6C6446-3299-4C07-B0D6-FE4A68ABB6D7
    ====================================================
    APFS Container Reference:     disk4
    Size (Capacity Ceiling):      49250988032 B (49.3 GB)
    Capacity In Use By Volumes:   112414720 B (112.4 MB) (0.2% used)
    Capacity Not Allocated:       49138573312 B (49.1 GB) (99.8% free)
    |
    +-< Physical Store disk0s5 9E5D6CAB-996F-4D2C-96D0-F6711DC35233
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk0s5
    |   Size:                       49250988032 B (49.3 GB)
    |
    +-> Volume disk4s1 59E24CCE-2837-48A2-BB81-535008CDEC0D
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk4s1 (No specific role)
        Name:                      Untitled (Case-insensitive)
        Mount Point:               Not Mounted
        Capacity Consumed:         1765376 B (1.8 MB)
        FileVault:                 No

Best Answer

No - you can't move partitions around, but you can shrink them to make space where they once were set and you can grow them if there is free space after then and the next limit.

If you've painted yourself into a corner, you would have to copy the data off to a new drive (USB) and then remove all the containers except one. At that point, you should be able to grow the one container back to full use of the disk. Should that fail, an erase / reinstall / then not make multiple containers going forward is the path for you to get where you can put BootCamp after the APFS Container is large enough for the Apple files and volumes.

That being said, your details are superb and it looks like you might be able to iterate to a spot where you can move the files and have two copies of all the data and then retire all the containers except for one.

If you like this, start by retiring by deleting the APFS containers marked in RED. It looks like they are Untitled and from comments, you don’t want those and you don't need to get any data saved from them.

Listing of APFS containers to be retired and data migrated

The green containers should remain - don’t delete them. Once you retire disk0s3 and disk0s5 - you will want to see if you can resze disk0s2 to be larger. In the end, you want it to be 1.0 TB (or as close to that as you can grow) before you let BootCamp shrink it to carve out space for windows.

Please look at this thread for much better information on cleaning up APFS Containers:

Once that's done you can attempt to expand the main container disk0s2 in your case so you can copy data over from disk0s4 and then clean that container up as well and then finally expand to have one container at 1.0 TB

diskutil apfs resizecontainer disk0s2 0

The last command with a size 0 should try and expand container disk2 as much as possible. We might need to revisit things or better - ask a follow on question with the new listing rather than us keep editing the question then the answer back and forth.


I'm not even sure how you made all 4 containers - when I tried to reproduce your setup so I could check the syntax to delete the extra containers - I get this warning.

Disk Utility warning to create volumes and not partitions

Once you get things cleaned up - be sure to just make volumes for your Mac storage so the simple clean up of deleting files will free space.