-1

enter image description here

Since I have allocated 2 partition for installing windows. Now i want to get space back to the macintoh HD Disk, I just followed by the method online and tried several commands like:

jhdeMacBook-Pro:~ jh$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       
   IDENTIFIER
    0:      GUID_partition_scheme                        *121.3 GB   disk0
    1:                        EFI                         1.1 GB     disk0s1
    2:                  Apple_HFS macintoh HD             42.3 GB    disk0s2
    3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

sudo diskutil eraseVolume free none disk0s4

the disk0s4 & disk0s5 was installed with windows system before. But when i want to resize disk0s2 and let it have all the space:

sudo diskutil apfs resizeContainer disk0s2 0
diskutil: did not recognize APFS verb "resizeContainer"; type "diskutil apfs" for a 
list

It does not work. I also tried sudo diskutil resizeVolume disk0s2 R It does not work as well and gives output below:

Resizing to full size (fit to fill)
Started partitioning on disk0s2 macintoh HD
Error: -69743: The new size must be different than the existing size

It seems that the missing space is not associated with Apple_HFS type disk now.

This is my first time to run diskutil commands, please help!

update1: the driveinfo is incompatible with the current version of macOS.

It seems that the missing space is not following the Apple_HFS type disk.

jhdeMacBook-Pro:~ jh$ ~/Downloads/driveinfo-1.0.3/driveinfo disk0
driveinfo: This script is incompatible with the current version of macOS.

update2: I tried sudo gpt -r show /dev/disk0 and sudo fdisk /dev/disk0 and get the output like that:

enter image description here

  • 2
    Please don't add screenshots from Terminal, it makes it hard to read and prevents its content from becoming searchable. Copy/paste the text instead and apply code formatting (select the pasted text and click on the `{}´ at the top of the edit window. – nohillside Jul 10 at 14:44
1

This is a duplicate of a question asked many time before. Perhaps a better explanation is required.

The command sudo diskutil eraseVolume free none disk0s4 preforms at least the following tasks.

  1. Erases enough of disk0s4 to make any volume or container stored in this partition difficult to recover.
  2. Removes the partition associated with disk0s4 from the Guid Partition Table (GPT).
  3. Reorders the remaining partitions is ascending sequential order.
  4. Depending on the version of macOS, either correctly hybrid partitions for BIOS booting Windows installation or removes all hybrid partitioning.

The command does not add the free space back to another partition. To do this you must execute another command.

The sudo diskutil apfs resizeContainer disk0s2 0 will add all the free space immediately following the partition associated with disk0s2 to the container associated with disk0s2, but only if the type is Apple_APFS. In your case the type is Apple_HFS.

The correct command would be sudo diskutil resizeVolume disk0s2 R. This command will add all the free space immediately following the partition associated with disk0s2 to the container associated with disk0s2, but only for certain partition types such as Apple_HFS. If a partition of type Apple_HFS is followed immediately by a Apple_Boot type partition, then the following occurs.

  1. The Apple_Boot type partition contents is moved to the bottom of any free space immediately following this partition.
  2. The Apple_HFS type partition (and the volume it contains) is expanded to include the free space between itself and the Apple_BOOT type partition.

I should note that after using the diskutil command there could still be a small amount of free space between partitions. The macOS operating system has various rules regarding the requirement of this free space which are not worth mentioning.

The diskutil command does not have a way to directly show the free space between partitions in the GPT. A command that can show the free space is called driveinfo, which you can download. This utility is a bash script which uses the diskutil command to determine and display the free space. In your case after downloading, you would need to enter the following command to display the free space.

~/Downloads/driveinfo-1.0.3/driveinfo disk0
  • thanks for your explanation! I tried the command given before. and it gives me a result like 'Error: -69743: The new size must be different than the existing size'. In addition, I download the driveinfo by the link and it mentioned that this script is not compatible with my current version of macOS.(it's running macOS Sierra version 10.12.6) – kiri CHENG Jul 11 at 4:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .