diskutil – What’s wrong with my disk and apfs volumes?

Let me start by creating a 1 GiB sparse disk image which contains a GPT with single empty APFS container. The commands are given below. Note that for 1 GiB disks, an EFI partition is not created by the diskutil erasedisk verb.

hdiutil create -size 1g -type SPARSE -layout none -ov MyGiB 
hdiutil attach -nomount MyGiB.sparseimage
diskutil erasedisk jhfs+ %noformat% gpt disk2
diskutil apfs createcontainer disk2s1
diskutil list external

Below are the is the output from entering the above commands.

davidanderson@Davids-Mac Desktop % hdiutil create -size 1g -type SPARSE -layout none -ov MyGiB 
created: /Users/davidanderson/Desktop/MyGiB.sparseimage
davidanderson@Davids-Mac Desktop % hdiutil attach -nomount MyGiB.sparseimage
/dev/disk2                                              
davidanderson@Davids-Mac Desktop % diskutil erasedisk jhfs+ %noformat% gpt disk2
Started erase on disk2
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Finished erase on disk2
davidanderson@Davids-Mac Desktop % diskutil apfs createcontainer disk2s1
Creating container with disk2s1
Started APFS operation on disk2s1
Creating a new empty APFS Container
Unmounting Volumes
Switching disk2s1 to APFS
Creating APFS Container
Created new APFS Container disk3
Disk from APFS operation: disk3
Finished APFS operation on disk2s1
davidanderson@Davids-Mac Desktop % diskutil list external   
/dev/disk2 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        +1.1 GB     disk2
   1:                 Apple_APFS ⁨Container disk3⁩         1.1 GB     disk2s1

/dev/disk3 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +1.1 GB     disk3
                                 Physical Store disk2s1

With the disk initialize, I will start adding APFS volumes without reserving space.

newfs_apfs -v "Volume1" -A disk3

OK

newfs_apfs -v "Volume2" -A disk3

OK

newfs_apfs -v "Volume3" -A disk3
newfs_apfs: unable to format volume inside /dev/disk3: Result too large

I think the OP made the assumption that the reserving of 200 MiB per volume was the problem. I think the problem is that a container of only 1 GiB limits the maximum volumes to 2.

Before proceeding, I entered the following command to eject disk2, which also ejects disk3.

diskutil eject disk2

Redoing the Experiment with a 1 TiB Disk and 200 GiB Volumes

Let me start by creating a 1 TiB sparse bundle disk image which contains a GPT with single empty APFS container. The commands are given below. Note that for 1 TiB disks, a 200 MiB EFI partition is created by the diskutil erasedisk verb.

hdiutil create -size 1t -type SPARSEBUNDLE -layout none -ov MyTiB 
hdiutil attach -nomount MyTiB.sparsebundle
diskutil erasedisk jhfs+ %noformat% gpt disk2
diskutil apfs createcontainer disk2s2
diskutil list external

The output from the above commands is basically the same as before, with the exception of the diskutil list external output, which is given below.

davidanderson@Davids-Mac Desktop % diskutil list external
/dev/disk2 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        +1.1 TB     disk2
   1:                        EFI ⁨EFI⁩                     209.7 MB   disk2s1
   2:                 Apple_APFS ⁨Container disk3⁩         1.1 TB     disk2s2

/dev/disk3 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +1.1 TB     disk3
                                 Physical Store disk2s2

Below, I keep making 200 GiB volumes until something goes wrong.

davidanderson@Davids-Mac Desktop % newfs_apfs -v "Volume1" -s 200G -A disk3 
davidanderson@Davids-Mac Desktop % newfs_apfs -v "Volume2" -s 200G -A disk3 
davidanderson@Davids-Mac Desktop % newfs_apfs -v "Volume3" -s 200G -A disk3 
davidanderson@Davids-Mac Desktop % newfs_apfs -v "Volume4" -s 200G -A disk3 
davidanderson@Davids-Mac Desktop % newfs_apfs -v "Volume5" -s 200G -A disk3 
davidanderson@Davids-Mac Desktop % newfs_apfs -v "Volume6" -s 200G -A disk3 
newfs_apfs: unable to format volume inside /dev/disk3: No space left on device

After creating 5 volumes of 214.7 GB each, there is 25.8 GB left, which is more than enough to support the GPT, the 200 MiB EFI partition and any other space needed by the APFS container. The exact computation is shown below.

1 TiB - (5 x 200 GiB) = 24 GiB

Below is the output from diskutil list disk3 and diskutil apfs list disk3.

davidanderson@Davids-Mac Desktop % diskutil list disk3   
/dev/disk3 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +1.1 TB     disk3
                                 Physical Store disk2s2
   1:                APFS Volume ⁨Volume1⁩                 214.7 GB   disk3s1
   2:                APFS Volume ⁨Volume2⁩                 214.7 GB   disk3s2
   3:                APFS Volume ⁨Volume3⁩                 214.7 GB   disk3s3
   4:                APFS Volume ⁨Volume4⁩                 214.7 GB   disk3s4
   5:                APFS Volume ⁨Volume5⁩                 214.7 GB   disk3s5

davidanderson@Davids-Mac ~ % diskutil apfs list disk3
|
+-- Container disk3 02B7FC98-230C-4FCD-8B23-FB1A96081B3F
    ====================================================
    APFS Container Reference:     disk3
    Size (Capacity Ceiling):      1099301871616 B (1.1 TB)
    Capacity In Use By Volumes:   1073958289408 B (1.1 TB) (97.7% used)
    Capacity Not Allocated:       25343582208 B (25.3 GB) (2.3% free)
    |
    +-< Physical Store disk2s2 3FECC3C1-E6B9-41D5-BCA0-6859B6C8819A
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk2s2
    |   Size:                       1099301871616 B (1.1 TB)
    |
    +-> Volume disk3s1 C6D7C2C5-5040-428F-AA4B-9CF348DF48D0
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s1 (No specific role)
    |   Name:                      Volume1 (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         214748364800 B (214.7 GB)
    |   Capacity Reserve:          214748364800 B (214.7 GB)
    |   Capacity Quota:            214748364800 B (214.7 GB) (100.0% reached)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk3s2 8DD3AB61-8F64-41C2-BE12-2229AE73166C
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s2 (No specific role)
    |   Name:                      Volume2 (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         214748364800 B (214.7 GB)
    |   Capacity Reserve:          214748364800 B (214.7 GB)
    |   Capacity Quota:            214748364800 B (214.7 GB) (100.0% reached)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk3s3 CF531006-42ED-46A9-9350-338DEFB95A42
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s3 (No specific role)
    |   Name:                      Volume3 (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         214748364800 B (214.7 GB)
    |   Capacity Reserve:          214748364800 B (214.7 GB)
    |   Capacity Quota:            214748364800 B (214.7 GB) (100.0% reached)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk3s4 5EFD57F0-3FA1-4B7E-B617-B157F8CDFE92
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk3s4 (No specific role)
    |   Name:                      Volume4 (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         214748364800 B (214.7 GB)
    |   Capacity Reserve:          214748364800 B (214.7 GB)
    |   Capacity Quota:            214748364800 B (214.7 GB) (100.0% reached)
    |   Sealed:                    No
    |   FileVault:                 No
    |
    +-> Volume disk3s5 DDA13866-9C0C-4684-9A79-2428648DAAE7
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk3s5 (No specific role)
        Name:                      Volume5 (Case-insensitive)
        Mount Point:               Not Mounted
        Capacity Consumed:         214748364800 B (214.7 GB)
        Capacity Reserve:          214748364800 B (214.7 GB)
        Capacity Quota:            214748364800 B (214.7 GB) (100.0% reached)
        Sealed:                    No
        FileVault:                 No

Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here