2

There are two partitions currently allocated on my 100 GiB hard disk. However, only ~85GB is formatted and I cannot expand /dev/disk0s2 to the maximum size with various attempts such as diskutil and gpt. The last ~20 GB free space does exist, but it cannot be partitioned. disk0 is a VMware vmdk resized from 85 GB to 107 GB with vmware-vdiskmanager.

What may cause this? And how should I achieve the goal?

screenshot

  • 2
    You should have mentioned VMware (and macOS being a VM) previously ;-). Here I recommend to download a gparted-live iso, attach it to the VM, change the type of the VM temporarily to Linux, boot from the iso and expand disk0s2. You may also try to repair disk0 (diskutil repairDisk disk0) booted from a 2nd bootable macOS vmdk (which can be a renamed copy of the original) and try to expand it then. – klanomath Jul 2 '17 at 17:31
  • Please write an answer... ;-) – klanomath Jul 3 '17 at 14:33
  • @klanomath I answered my question below. – Kevin Dong Jul 3 '17 at 14:55
2

Since resizing the partition that is currently mounted for the operating system is impossible and the filesystem (FS) may be corrupted. One of the solutions is to use a live CD, especially GParted Live ISO which has installed many tools related to disk management such as partition.

However, GParted can check the integrity of the FS, but it is not able to resize the partition to the maximum size. Hence, parted, a command-line tool, is used. (Thanks for @klanomath 's hints.)

Step 1: Find out which partition has to be expanded.

$ sudo parted /dev/sd[x]
(parted) unit s print free  # unit: sectors

Step 2: Expand the selected partition to the designated sector.

(parted) resizepart <partition> <end>s

Step 3: Shutdown the Live system.

Step 4: Restart the macOS VM, and repair the disk.

$ sudo diskutil repairDisk disk[y]

You must log in to answer this question.

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