APFS Volume does not increase in size
-
30-05-2021 - |
Question
I have an issue with an APFS volume that resides inside a SparseBundle.
I tried to increase its size (similar to this: Is it possible to increase size of an APFS volume?), but failed.
Unfortunately, I have no idea what else to do (except for recreating the whole thing, copying all data, and put it in the place of the existing one).
added (2020-12-08):
I noticed that during the last step of my actions an error occurred and I assume that my problem exists because of the error.
The error happened during "Increase APFS Container" diskutil apfs resizeContainer disk2s2 0
error: (oid 0xa67b) apfs_root: btn: invalid o_cksum (0x5824c5de98a6fb78)
fsroot tree is invalid
The volume /dev/disk2s2 could not be verified completely
Setup
The setup I have an issue with is like this, however I think the relevant part is within the APFS part:
- On Mac OS (now Big Sur)
- SMB network share, usually mounted to
/Volumes/Backup/
- On
/Volumes/Backup/
there is a SparseBundle (/Volumes/Backup/iTunes_iOS_Backup/Backup_sparse_bundle/itunes_backup.sparsebundle
) - Inside the SparseBundle there is a APFS container with one APFS volume,
the volume mounts to/Volumes/itunes_backup/
- On
~/Library/Application\ Support/MobileSync/
I have a link to the mounted volume
lrwxr-xr-x 1 user staff 29 Oct 14 2017 Backup -> /Volumes/itunes_backup/Backup
What I wanted to do was increase the size of the APFS Volume which resides inside the SparseBundle.
Steps I took to increase the APFS volume
Increased the size of the SparseBundle with this command:
hdiutil resize -size 1500g /Volumes/Backup/iTunes_iOS_Backup/Backup_sparse_bundle/itunes_backup.sparsebundle
As far as I could see, no error was thrown.To check, ran
hdiutil imageinfo /Volumes/Backup/iTunes_iOS_Backup/Backup_sparse_bundle/itunes_backup.sparsebundle
Class Name: CSparseBundleDiskImage Size Information: Total Bytes: 1610822492160 Compressed Ratio: 1 Sector Count: 3146137680 Total Non-Empty Bytes: 0 Compressed Bytes: 1610822492160 Total Empty Bytes: 1610822492160 Checksum Type: none Format: UDSB partitions: partition-scheme: GUID block-size: 512 partitions: 0: partition-name: Protective Master Boot Record partition-start: 0 partition-synthesized: true partition-length: 1 partition-hint: MBR 1: partition-name: GPT Header partition-start: 1 partition-synthesized: true partition-length: 1 partition-hint: Primary GPT Header 2: partition-name: GPT Partition Data partition-start: 2 partition-synthesized: true partition-length: 32 partition-hint: Primary GPT Table 3: partition-name: partition-start: 34 partition-synthesized: true partition-length: 6 partition-hint: Apple_Free 4: partition-UUID: 131BB16B-9C17-4ADE-BA9C-19A43E3F42F3 partition-name: EFI System Partition partition-hint-UUID: C12A7328-F81F-11D2-BA4B-00A0C93EC93B partition-start: 40 partition-number: 1 partition-length: 409600 partition-hint: C12A7328-F81F-11D2-BA4B-00A0C93EC93B partition-filesystems: FAT32: EFI 5: partition-UUID: D528609D-5A45-4146-92A8-871B833293BD partition-name: disk image partition-hint-UUID: 7C3457EF-0000-11AA-AA11-00306543ECAC partition-start: 409640 partition-number: 2 partition-length: 3145728000 partition-hint: Apple_APFS partition-filesystems: APFS: Untitled 6: partition-name: partition-start: 3146137640 partition-synthesized: true partition-length: 7 partition-hint: Apple_Free 7: partition-name: GPT Partition Data partition-start: 3146137647 partition-synthesized: true partition-length: 32 partition-hint: Backup GPT Table 8: partition-name: GPT Header partition-start: 3146137679 partition-synthesized: true partition-length: 1 partition-hint: Backup GPT Header burnable: false Format Description: sparse Checksum Value: Properties: Encrypted: false Kernel Compatible: false Checksummed: false Software License Agreement: false Partitioned: false Compressed: no Segments: 0: /Volumes/Backup/iTunes_iOS_Backup/Backup_sparse_bundle/itunes_backup.sparsebundle Backing Store Information: URL: file:///Volumes/Backup/iTunes_iOS_Backup/Backup_sparse_bundle/itunes_backup.sparsebundle/ Name: itunes_backup.sparsebundle Class Name: CBundleBackingStore Resize limits (per hdiutil resize -limits): min cur max 1679163392 3145728000 18014398509072303
Mount SparseBundle
hdiutil attach /Volumes/Backup/iTunes_iOS_Backup/Backup_sparse_bundle/itunes_backup.sparsebundle
/dev/disk2 GUID_partition_scheme /dev/disk2s1 EFI /dev/disk2s2 Apple_APFS /dev/disk3 EF57347C-0000-11AA-AA11-0030654 /dev/disk3s1 41504653-0000-11AA-AA11-0030654 /Volumes/itunes_backup
Increase APFS Container:
diskutil apfs resizeContainer disk2s2 0
added: I noticed that during this step an error occurredStarted APFS operation Aligning grow delta to 510.612.738.048 bytes and targeting a new physical store size of 1.610.612.736.000 bytes Determined the maximum size for the targeted physical store of this APFS Container to be 1.610.611.707.904 bytes Resizing APFS Container designated by APFS Container Reference disk3 The specific APFS Physical Store being resized is disk2s2 Verifying storage system Performing fsck_apfs -n -x /dev/disk2s2 Checking the container superblock Checking the space manager Checking the space manager free queue trees Checking the object map Checking volume Checking the APFS volume superblock The volume itunes_backup was formatted by newfs_apfs (748.1.47) and last modified by apfs_kext (1677.50.1) Checking the object map Checking the snapshot metadata tree Checking the snapshot metadata Checking the extent ref tree Checking the fsroot tree error: (oid 0xa67b) apfs_root: btn: invalid o_cksum (0x5824c5de98a6fb78) fsroot tree is invalid The volume /dev/disk2s2 could not be verified completely Storage system check exit code is 0 Growing APFS Physical Store disk2s2 from 1.099.999.997.952 to 1.610.612.736.000 bytes Modifying partition map Growing APFS data structures Finished APFS operation
diskutil apfs list
APFS Containers (2 found) | +-- Container disk1 | +-< Physical Store disk0s2 | +-> Volume disk1s1 | +-> Volume disk1s2 | +-> Volume disk1s3 | +-> Volume disk1s4 | +-> Volume disk1s5 | +-- Container disk3 E79238FB-8BB4-44AB-AFD9-4990B9B70F23 ==================================================== APFS Container Reference: disk3 Size (Capacity Ceiling): 1610612736000 B (1.6 TB) Capacity In Use By Volumes: 845079302144 B (845.1 GB) (52.5% used) Capacity Not Allocated: 765533433856 B (765.5 GB) (47.5% free) | +-< Physical Store disk2s2 D528609D-5A45-4146-92A8-871B833293BD | ----------------------------------------------------------- | APFS Physical Store Disk: disk2s2 | Size: 1610612736000 B (1.6 TB) | +-> Volume disk3s1 424805EF-477B-4C7B-9688-9A46612478D9 --------------------------------------------------- APFS Volume Disk (Role): disk3s1 (No specific role) Name: itunes_backup (Case-sensitive) Mount Point: /Volumes/itunes_backup Capacity Consumed: 844815552512 B (844.8 GB) Sealed: No FileVault: No
The trouble
The issue I have is that the volume seems not be enlarged or at least the space is not usable. When I tried to copy data to the drive it failed due to not enough space.
When I check with df -h /Volumes/itunes_backup/
I see
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk3s1 1.5Ti 787Gi 285Gi 74% 647844 15727992156 0% /Volumes/itunes_backup
Any ideas how I can proceed to increase also the APFS volume would be much appreciated
Solution 2
In the end I managed to get rid of the error error: (oid 0xa67b) apfs_root: btn: invalid o_cksum (0x5824c5de98a6fb78)
by creating a new SparseBundle and copying all data over to the new one.
My process
A)
Create a new SparseBundle including APFS container.
That gave me the possibility to use larger band size of ~60MB (instead of default 8MB).
hdiutil create -size 1t -type SPARSEBUNDLE -tgtimagekey sparse-band-size=131072 -fs APFS -volname itunes_backup_new -attach itunes_backup_new.sparsebundle
/dev/disk4 GUID_partition_scheme
/dev/disk4s1 EFI
/dev/disk4s2 Apple_APFS
/dev/disk5 EF57347C-0000-11AA-AA11-0030654
/dev/disk5s1 41504653-0000-11AA-AA11-0030654 /Volumes/itunes_backup_new
B)
Clone all data from old APFS volume to new APFS volume.
I used the good old Carbon Copy Cloner, because it allows for incremental cloning. That means I could stop the cloning in the middle and continue without starting fresh.
Because it is content aware it only clones actual data. The result was a smaller SparseBundle.
Alternative step B)
I also tried asr
out of curiosity on a copy of the original SparseBundle.
It worked fine as far as I can tell. The process is to create a new SparseBundle as described above in step A) and then run asr
.
Because I wanted to get rid of the error of the APFS Container, it seems a good idea to use the option --useInverter
, which copies data instead of replicating it.
asr --source /dev/disk3 --target /dev/disk5 --erase --useInverter --buffers 1 --buffersize 1g
What did not help me
Diskutil repairVolume was unable to correct the error:
diskutil repairvolume disk5
Started file system repair on disk5 Repairing storage system Performing fsck_apfs -y -x /dev/disk4s2 Checking the container superblock Checking the space manager Checking the space manager free queue trees Checking the object map Checking volume Checking the APFS volume superblock The volume itunes_backup was formatted by newfs_apfs (748.1.47) and last modified by apfs_kext (1677.50.1) Checking the object map Checking the snapshot metadata tree Checking the snapshot metadata Checking the extent ref tree Checking the fsroot tree error: (oid 0xa67b) apfs_root: btn: invalid o_cksum (0x5824c5de98a6fb78) fsroot tree is invalid The volume /dev/disk4s2 could not be verified completely Storage system check exit code is 0 Finished file system repair on disk5
On reddit (Disk Utility First Aid Error) is was suggested to run
fsck_apfs -y /dev/yourdisk
. Basically the same as diskutil repairVolume with more options, but did not help me.Tried
hdiutil convert
and it completed, but it was unable to correct the error. I assume this is because it has no awareness of the APFS container.
However, without the error in my source the conversion works, of course.
hdiutil convert itunes_backup.sparsebundle -format UDSB -tgtimagekey sparse-band-size=131072 -o itunes_backup_131072.sparsebundle
OTHER TIPS
The accepted answer you reference did not include the
-imageonly
option in thehdiutil
command shown in step 3.
I am using High Sierra. Here is an Example.
First, I create a sparse bundle.
Marlin-3:~ davidanderson$ hdiutil create -type SPARSEBUNDLE -size 100g -fs APFS -volname MyAPFS -attach ~/Desktop/test
/dev/disk1 GUID_partition_scheme
/dev/disk1s1 EFI
/dev/disk1s2 Apple_APFS
/dev/disk2 EF57347C-0000-11AA-AA11-0030654
/dev/disk2s1 41504653-0000-11AA-AA11-0030654 /Volumes/MyAPFS
created: /Users/davidanderson/Desktop/test.sparsebundle
Marlin-3:~ davidanderson$ diskutil list disk1
/dev/disk1 (disk image):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme +107.4 GB disk1
1: EFI EFI 209.7 MB disk1s1
2: Apple_APFS Container disk2 107.2 GB disk1s2
Next, I eject.
Marlin-3:~ davidanderson$ diskutil eject disk1
Disk disk1 ejected
Here, is the resize command.
Marlin-3:~ davidanderson$ hdiutil resize -size 200g -imageonly ~/Desktop/test.sparsebundle
nx_kernel_mount:1359: : checkpoint search: largest xid 5, best xid 5 @ 9
nx_kernel_mount:1359: : checkpoint search: largest xid 5, best xid 5 @ 9
nx_kernel_mount:1359: : checkpoint search: largest xid 5, best xid 5 @ 9
nx_kernel_mount:1359: : checkpoint search: largest xid 5, best xid 5 @ 9
Next, I mount.
Marlin-3:~ davidanderson$ hdiutil attach ~/Desktop/test.sparsebundle
/dev/disk1 GUID_partition_scheme
/dev/disk1s1 EFI
/dev/disk1s2 Apple_APFS
/dev/disk2 EF57347C-0000-11AA-AA11-0030654
/dev/disk2s1 41504653-0000-11AA-AA11-0030654 /Volumes/MyAPFS
Marlin-3:~ davidanderson$ diskutil list disk1
/dev/disk1 (disk image):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme +214.7 GB disk1
1: EFI EFI 209.7 MB disk1s1
2: Apple_APFS Container disk2 107.2 GB disk1s2
Finally, I increase the size of the APFS container.
Marlin-3:~ davidanderson$ diskutil apfs resizecontainer disk1s2 0
Started APFS operation
Aligning grow delta to 107,374,182,400 bytes and targeting a new physical store size of 214,538,608,640 bytes
Determined the maximum size for the targeted physical store of this APFS Container to be 214,537,580,544 bytes
Resizing APFS Container designated by APFS Container Reference disk2
The specific APFS Physical Store being resized is disk1s2
Verifying storage system
Performing fsck_apfs -n -x /dev/disk1s2
Checking volume
Checking the container superblock
Checking the space manager
Checking the object map
Checking the APFS volume superblock
Checking the object map
Checking the fsroot tree
Checking the snapshot metadata tree
Checking the extent ref tree
Checking the snapshots
Verifying allocated space
The volume /dev/disk1s2 appears to be OK
Storage system check exit code is 0
Growing APFS Physical Store disk1s2 from 107,164,426,240 to 214,538,608,640 bytes
Modifying partition map
Growing APFS data structures
Finished APFS operation
Marlin-3:~ davidanderson$ diskutil list disk1
/dev/disk1 (disk image):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme +214.7 GB disk1
1: EFI EFI 209.7 MB disk1s1
2: Apple_APFS Container disk2 214.5 GB disk1s2