Skip to content

Increasing the virtual machine's disk

Simon B. Støvring edited this page Nov 7, 2024 · 2 revisions

The following guide describes how the size of a virtual image can be increased to obtain more disk space in the virtual machine.

Note that this involves erasing the recovery volume to ensure the container can be resized.

From the host machine

  1. Run truncate -s 150g ~/.tart/vms/my-vm/disk.img to increase the disk size to 150 GB. Replace 150 with the size you'd like to resize to. Truncating to a smaller image size may cause data loss.
  2. Run the virtual machine with tart run my-vm.
  3. Obtain the IP address of the virtual machine with tart ip my-vm.
  4. SSH into the virtual machine with ssh runner@{IP_ADDRESS}.
  5. Run diskutil repairDisk disk0 on the virtual machine.
  6. Shut down the virtual machine.
  7. Run the virtual machine in recovery mode with tart run my-vm —-recovery.

In the virtual machine running in recovery mode

  1. Open the Terminal app.
  2. Run diskutil list to identify the identifier of the volume named Apple_APFS_Recovery. We'll assume the identifier is disk0s3.
  3. Erase the recovery volume with diskutil eraseVolume free free disk0s3.
  4. Resize the primary APFS container with diskutil apfs resizeContainer disk0s2 0.
  5. Shut down the virtual machine.

The disk space has now been increased.