Home > Mac administration, Mac OS X, macOS, Scripting, Virtualization, VMware > Resizing a virtual machine’s boot drive to use all available space

Resizing a virtual machine’s boot drive to use all available space

Every so often, it’s necessary to resize the boot drive of an existing virtual machine. The process of resizing the VM’s boot disk from outside the VM is usually pretty straightforward:

1. Shut down the VM
2. Go into the VM’s drive settings

Screen Shot 2017 03 02 at 5 02 10 PM

3. Resize it to the desired size

Screen Shot 2017 03 02 at 5 02 23 PM

Screen Shot 2017 03 02 at 5 05 45 PM

4. Power on the VM.

However, when the VM boots up, the disk space used by the OS won’t have changed.

Screen Shot 2017 03 02 at 5 07 55 PM

However, the OS can detect that there is available unallocated disk space that it isn’t using.

Screen Shot 2017 03 02 at 5 08 58 PM

Fortunately, this is a correctable condition and the fix can be applied without needing to shut down the VM or boot from another drive. For more details, see below the jump.

The VM disk resizing process is a two-step process, where the first part is resizing the VM boot drive. The second step is resizing the drive partition using the OS’s tools to use some or all of the available unallocated space.

To tell the OS to use all of the available unallocated space, use the procedure described below:

1. Open Terminal

2. Run the command below:

diskutil resizeVolume / R

This command will tell macOS to do a live re-size of the boot partition, with the R flag specifying that all available unallocated space should be used.

Screen Shot 2017 03 02 at 5 23 02 PM

3. The drive partition will resize to fill all available space.

Screen Shot 2017 03 02 at 5 12 26 PM

4. The OS should now recognize and be able to use the now-allocated space.

Screen Shot 2017 03 02 at 5 12 55 PM

I’ve written a script to run the appropriate diskutil command, which is available below and on my GitHub repo:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/resize_vm_boot_partition

The script is below and is also available on my GitHub repo. This script is also available as a payload-free package on my GitHub repo, available for download from the payload_free_package directory available from the link above.

  1. Dan Farnworth
    March 6, 2017 at 11:30 am

    Thanks Richard, I was looking to do exactly this the other day. This should save me from having to completely recreate my VM next time

  2. Oliver Jeckel
    March 31, 2017 at 9:39 am

    Hi Rich, from my experience, Disk Utility under Sierra is now able to show the added space on the virtual harddrive as “Free” (iirc), which was not the case under El Capitan. In the gui, you can now add the space to a volume without the need of the cli.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: