Today I tried to remove the unused bootcamp partition on macOS to get more space but unfortunately it turned out to be not so simple.
After deleting the bootcamp partition from Disk Utility, I was greeted with an error that says the bootcamp partition cannot be merged into the main partition.
I then run First Aid and found some corruptions. Following the guide on Internet I booted into Recovery mode and fixed those errors, but the empty space was still not given to me.
Until I found this answer on the Internet and turns out the magic is just one command:
1 |
$ sudo diskutil apfs resizeContainer disk0s2 0 |
disk0s2 is the existing macOS IDENTIFIER as shown in diskutil list
Here is the full 3-step terminal log for anyone interested in my recovery process:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
[~/workspace] $ diskutil list /dev/disk0 (internal): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme 251.0 GB disk0 1: EFI EFI 314.6 MB disk0s1 2: Apple_APFS Container disk1 190.0 GB disk0s2 /dev/disk1 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +190.0 GB disk1 Physical Store disk0s2 1: APFS Volume Macintosh HD 168.1 GB disk1s1 2: APFS Volume Preboot 45.0 MB disk1s2 3: APFS Volume Recovery 510.4 MB disk1s3 4: APFS Volume VM 1.1 GB disk1s4 [~/workspace] $ sudo diskutil apfs resizeContainer disk0s2 0 Password: Started APFS operation Aligning grow delta to 60,678,385,664 bytes and targeting a new physical store size of 250,685,575,168 bytes Determined the maximum size for the targeted physical store of this APFS Container to be 250,684,547,072 bytes Resizing APFS Container designated by APFS Container Reference disk1 The specific APFS Physical Store being resized is disk0s2 Verifying storage system Using live mode Performing fsck_apfs -n -x -l -S /dev/disk0s2 Checking the container superblock Checking the EFI jumpstart record Checking the space manager Checking the space manager free queue trees Checking the object map Checking volume Checking the APFS volume superblock The volume Macintosh HD was formatted by hfs_convert (945.220.38) and last modified by apfs_kext (945.275.7) Checking the object map Checking the snapshot metadata tree Checking the snapshot metadata Checking the extent ref tree Checking the fsroot tree Checking volume Checking the APFS volume superblock The volume Preboot was formatted by hfs_convert (945.220.38) and last modified by apfs_kext (945.275.7) Checking the object map Checking the snapshot metadata tree Checking the snapshot metadata Checking the extent ref tree Checking the fsroot tree warning: directory valence check: directory (oid 0xc0043): orphan directory record warning: directory valence check: directory (oid 0xc0043): orphan directory record Checking volume Checking the APFS volume superblock The volume Recovery was formatted by diskmanagementd (945.220.38) and last modified by apfs_kext (945.275.7) Checking the object map Checking the snapshot metadata tree Checking the snapshot metadata Checking the extent ref tree Checking the fsroot tree Checking volume Checking the APFS volume superblock The volume VM was formatted by apfs.util (945.220.38) and last modified by apfs_kext (945.275.7) Checking the object map Checking the snapshot metadata tree Checking the snapshot metadata Checking the extent ref tree Checking the fsroot tree Verifying allocated space The volume /dev/disk0s2 appears to be OK Storage system check exit code is 0 Growing APFS Physical Store disk0s2 from 190,007,189,504 to 250,685,575,168 bytes Modifying partition map Growing APFS data structures Finished APFS operation [~/workspace] $ diskutil list /dev/disk0 (internal): #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme 251.0 GB disk0 1: EFI EFI 314.6 MB disk0s1 2: Apple_APFS Container disk1 250.7 GB disk0s2 /dev/disk1 (synthesized): #: TYPE NAME SIZE IDENTIFIER 0: APFS Container Scheme - +250.7 GB disk1 Physical Store disk0s2 1: APFS Volume Macintosh HD 168.1 GB disk1s1 2: APFS Volume Preboot 45.0 MB disk1s2 3: APFS Volume Recovery 510.4 MB disk1s3 4: APFS Volume VM 1.1 GB disk1s4 |