Title: How to Merge APFS Containers on Mac: Fix Storage Issues & Optimize Space

Introduction

Managing storage on macOS can become challenging when dealing with multiple APFS containers. Users often struggle with fragmented disk space or accidentally created containers that limit flexibility. This guide provides a clear walkthrough for merging APFS containers (e.g., merging disk1 into disk2), troubleshooting common errors, and optimizing your Mac’s storage.


Understanding APFS Containers and Volumes

Before proceeding, clarify these key concepts:

  1. Physical Disk: The hardware storage unit (e.g., a 256GB SSD).
  2. APFS Container: A logical partition that acts as a storage pool for volumes.
  3. Volume: A sub-section within a container (e.g., disk2s1), sharing the container’s total space.

Key Differences

  • Containers (e.g., disk1, disk2) are physical disk partitions and cannot be directly merged.
  • Volumes (e.g., disk1s1, disk2s5) are logical units within a container and share its allocated space.

Step-by-Step Guide to Merge APFS Containers

Prerequisites

  1. Backup Data: Use Time Machine or an external drive to prevent data loss.
  2. Check Disk Structure: Open Terminal and run:

    diskutil list  

    Identify container identifiers (e.g., disk0s2, disk0s4).


Scenario 1: Merging Containers on the Same Physical Disk

If disk1 and disk2 are partitions on the same disk (e.g., disk0s2 and disk0s4):

  1. Delete the Target Container

    diskutil apfs deleteContainer disk1  

    Note: This erases all data in disk1. Ensure backups exist.

  2. Expand the Destination Container

    diskutil apfs resizeContainer disk2 0  

    The 0 parameter maximizes the container’s size using freed space.

Verification
Run diskutil list again. The deleted container (e.g., disk0s4) should disappear, and disk2’s capacity will increase.


Scenario 2: Handling Containers on Separate Disks

If disk1 and disk2 are on different drives (e.g., external SSDs):

  1. Migrate Data: Use rsync to copy files:

    rsync -av /Volumes/disk1/ /Volumes/disk2/  
  2. Reformat disk1: Use Disk Utility to erase disk1 if needed.

Scenario 3: Volumes in the Same Container

Volumes within one container share space automatically—no merging required. Manage files via Finder.


Troubleshooting Common Errors

Error 1: Unmerged Space Shows as “Untitled”

Cause: Incorrectly targeting volumes instead of containers.
Fix:

  1. Ensure you’re deleting the container (e.g., disk1), not its volume (disk1s1).
  2. Force-free the partition:

    diskutil eraseVolume free free disk0s4  
  3. Re-run the resize command.

Error 2: “-69519: Target Disk Too Small”

Cause: Non-contiguous partitions or gaps in the partition table.
Fix:

  1. Boot into Recovery Mode (hold Cmd + R during startup).
  2. Open Disk Utility → Select the physical disk → Click Partition → Drag the partition handle to absorb free space.

Error 3: Corrupted System Volume (“ERROR -69808”)

Cause: Damaged file system metadata.
Fix:

  1. In Recovery Mode, repair the volume:

    fsck_apfs -y /dev/disk2s5  
  2. If unresolved, reinstall macOS or rebuild the container (back up first!).

Best Practices and Warnings

  1. Backup Religiously: Never skip backups before partition operations.
  2. Verify Commands: Double-check identifiers (e.g., disk2 vs. disk2s1).
  3. Avoid Interruptions: Ensure stable power to prevent mid-operation failures.

Conclusion

Merging APFS containers on Mac requires precision but is manageable with Terminal commands or Disk Utility. Always prioritize backups, confirm disk identifiers, and validate results with diskutil apfs list. For complex issues, share your diskutil list output in forums for targeted help.

Pro Tip: Bookmark Apple’s official APFS documentation for quick reference.