VMware Communities
TomsCat
Enthusiast
Enthusiast
Jump to solution

Ventura Guest with Fusion 13, reclaiming disk space

Hi All,

I want to shrink my Ventura Guest VM. But I find no way to erase the free space on the guest system. 

sudo diskutil secureErase freespace 0 ...

does not work. I always get the message

Error with secure disk erase: Secure erase by writing a run of bytes to an APFS Volume makes no sense due to its possibly-unbounded size (-69489)

I understand, what it means, but finally this results in a 27 GB disk for a system without any installed apps and no data, without a change to reduce this size.

I'd be happy if someone has an idea how to resolve this problem.

Greetings and thank you!

 

Reply
0 Kudos
2 Solutions

Accepted Solutions
ColoradoMarmot
Champion
Champion
Jump to solution

Not Fusion snapshots - time machine/APFS snapshots  inside the guest OS.

 

The command to find them is

tmutil listlocalsnapshots /

from terminal inside the guest

then you

tmutil deletelocalsnapshots /

to purge them

View solution in original post

Reply
0 Kudos
gringley
Hot Shot
Hot Shot
Jump to solution

I am still using these instructions I got from an older message in this forum I think:

  1. From inside the VM using a terminal session I issue the following command
    cat /dev/zero > wipefile; rm wipefile
  2. Shutdown the VM and exit VMware Fusion
  3. Execute the following command to defragment the disk (substitute VM name/Disk Name)
    /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -d macOS\ 10.15\ 64-bit.vmwarevm/Virtual\ Disk.vmdk
  4. Execute the following command to shrink the disk (substitute VM name/Disk Name)
    /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k macOS\ 10.15\ 64-bit.vmwarevm/Virtual\ Disk.vmdk

You would need to substitute your VM folder's names in there.  I usually navigate to the VM folder so I do not have to type all that out to run the commands.  I have had some problems with Big Sur VMs but everything else shrinks.

View solution in original post

Reply
0 Kudos
17 Replies
Technogeezer
Immortal
Immortal
Jump to solution

IMO APFS with its copy-on-write behavior, snapshots, lack of defragmentation (remember APFS is built for SSDs where defrags are not necessary) and multiple volumes sharing the same APFS container disk space is a poor candidate for shrinking with VMware's vmdk implementation. 

You might be better off writing a file full of zeros (cat /dev/zero > filefullofzeros) until the APFS file system fills up, delete the file, then manually run vmware-vdiskmanager -k after shutting down the VM and Fusion. However this might not get you as much back as you think. 

 

- Paul (Technogeezer)
Editor of the Unofficial Fusion Companion Guides
Reply
0 Kudos
ColoradoMarmot
Champion
Champion
Jump to solution

the only other thing I'd add is to remove any snapshots in the guest using tmutil from terminal both and after doing the zero out.

Reply
0 Kudos
TomsCat
Enthusiast
Enthusiast
Jump to solution

Thank you! But there are no snapshots.

Reply
0 Kudos
ColoradoMarmot
Champion
Champion
Jump to solution

Not Fusion snapshots - time machine/APFS snapshots  inside the guest OS.

 

The command to find them is

tmutil listlocalsnapshots /

from terminal inside the guest

then you

tmutil deletelocalsnapshots /

to purge them

Reply
0 Kudos
gringley
Hot Shot
Hot Shot
Jump to solution

I am still using these instructions I got from an older message in this forum I think:

  1. From inside the VM using a terminal session I issue the following command
    cat /dev/zero > wipefile; rm wipefile
  2. Shutdown the VM and exit VMware Fusion
  3. Execute the following command to defragment the disk (substitute VM name/Disk Name)
    /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -d macOS\ 10.15\ 64-bit.vmwarevm/Virtual\ Disk.vmdk
  4. Execute the following command to shrink the disk (substitute VM name/Disk Name)
    /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k macOS\ 10.15\ 64-bit.vmwarevm/Virtual\ Disk.vmdk

You would need to substitute your VM folder's names in there.  I usually navigate to the VM folder so I do not have to type all that out to run the commands.  I have had some problems with Big Sur VMs but everything else shrinks.

Reply
0 Kudos
TomsCat
Enthusiast
Enthusiast
Jump to solution


@Technogeezer wrote:

You might be better off writing a file full of zeros (cat /dev/zero > filefullofzeros) until the APFS file system fills up, delete the file, then manually run vmware-vdiskmanager -k after shutting down the VM and Fusion. However this might not get you as much back as you think. 

 


Writing a file of this size would first produce a VM of 80 GB because this is the minimum size that vmware allows for a macOS VM. Or am I wrong?

Reply
0 Kudos
TomsCat
Enthusiast
Enthusiast
Jump to solution


@gringley wrote:

I am still using these instructions I got from an older message in this forum I think:

Execute the following command to defragment the disk (substitute VM name/Disk Name)
/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -d macOS\ 10.15\ 64-bit.vmwarevm/Virtual\ Disk.vmdk

But doesn't defragmenting a VM on an SSD do a lot of unnecessary write access on the disk? I ask because SSD's don't have an endless life.

Reply
0 Kudos
Technogeezer
Immortal
Immortal
Jump to solution


@TomsCat wrote:

Writing a file of this size would first produce a VM of 80 GB because this is the minimum size that vmware allows for a macOS VM. Or am I wrong?


You are not wrong. VMware’s virtual disks do not implement anything like the “TRIM” functions present on physical disks. TRIM enables an operating system to tell storage that a given area of disk is unused. Unfortunately without TRIM support VMware has to resort to this copy method in conjunction with defrag to release the most amount of space space back to the host OS. 

Shrinking virtual disks will hurt SSD lifetime if you do it frequently. Doing it rarely won’t be as bad.

As a side note, Windows will no longer perform a full defrag on a file system it knows resides on SSD media for the same reason. It’s unneccary and shortens SSD life span. 

- Paul (Technogeezer)
Editor of the Unofficial Fusion Companion Guides
Reply
0 Kudos
gringley
Hot Shot
Hot Shot
Jump to solution

Maybe...but I am only doing this 2-3 times a year so it is not high on my list for SSD wear.  I looked today for the first time and after 3.5 years my VM SSDs are at 99% so I think its OK.

Reply
0 Kudos
Technogeezer
Immortal
Immortal
Jump to solution

@gringley I definitely would consider what you do as “rarely”.  I would be concerned about someone doing shrinks daily or weekly.

 

- Paul (Technogeezer)
Editor of the Unofficial Fusion Companion Guides
Reply
0 Kudos
TomsCat
Enthusiast
Enthusiast
Jump to solution

@Technogeezer@gringley 

Thank you very much for these great hints!

I did what you described, but copied the VM to a hard drive to preserve my SSD, and copied it back after the whole process. Reduced the Ventura VM from 27GB to 19GB. This is fine for a VM that I back up and use infrequently for some software development testing, etc.

Reply
0 Kudos
TomsCat
Enthusiast
Enthusiast
Jump to solution

BTW, the VM boots faster after this.

Reply
0 Kudos
S7v3n
Contributor
Contributor
Jump to solution

Do you mind showing screenshots?

 

The command cat /dev/zero > wipefile; rm wipefile does not work for me.

 

It says cat: cannot find path 'c:/dev/zero because it does not exist.

 

i have 2 partition here C: drive consist of window 11 and E: drive as backup to save additional files, i have shrink about 40GB from E drive and they are now shown as grey or "Recovery Partition" under Disk Management.

Reply
0 Kudos
TomsCat
Enthusiast
Enthusiast
Jump to solution

Screenshots of what? And who do you mean?

Reply
0 Kudos
RDPetruska
Leadership
Leadership
Jump to solution

Well, it won't work for you because that is a *nix command and you are attempting to run it on a Windows machine.

Reply
0 Kudos
Technogeezer
Immortal
Immortal
Jump to solution

You may be able to reclaim space in a Windows VM if you are running the VM with the default of splitting disks:

  • Run a defrag from within Windows on your C: (and E:) drive.
  • Shut down the VM, and go to Fusion. Select the VM in the Virtual Machine Library.
  • Refresh the disk usage by clicking on the (small) button to the right of the area that's showing your disk usage.
  • If it says at the bottom of the window "Clean Up Recommended", click on that text. It will then open the VM's Settings.
  • In the Settings dialog, at the bottom. look for the "Clean Up Virtual Machine" at the button of the General settings window, and click on it.

If you wish to prevent the VM from using the entire allocated amount of the virtual disk, try reducing the size of the C: (and E:) partitions using WIndows Disk Management. Right click on the partitionin Disk Management, and select "Shrink". Don't shrink the size too far or else you'll run out of space - leave the partition reasonably sized so that you can accommodate reasonable  anticipated growth. 

Then run the steps again (you can skip the defrag). The VM won't consume disk space for unallocated partitions because it won't write anything there. 

 

- Paul (Technogeezer)
Editor of the Unofficial Fusion Companion Guides
S7v3n
Contributor
Contributor
Jump to solution

Thank you for your guidance, you are a Legend! The solution worked like a charm. I have recently started using VM and still getting my head around it, it makes much more sense to me now.

  1. Begin by defragmenting the Windows drives, C: and E:.
  2. After defragmentation is complete, shut down the virtual machine (VM) and navigate to the VM settings.
  3. Under 'Hard Disk (NVMe),' I have noticed two options: 'Pre-allocated disk space' (ticked) and 'Split into multiple files' (unticked). I have reversed them, which now appear to allow you to transfer files between your Mac and Windows seamlessly.
  4. Within the 'General' section, I was able to see the 'Reclaimable' space displayed on my hard disks. I then click on 'Clean Up Virtual Machine' to reclaim this space, effectively freeing up storage on my Mac.

Regarding your other comments about reducing the size of a virtual disk, you were absolutely correct: it's not possible to shrink or reduce the pre-allocated space under 'Hard Disks.' Fortunately, this shouldn't be a concern as it only affects the C: drive space. This space is pre-allocated when you install the Window to the VM. The remaining space on the E: drive functions as shared storage between your VM and Mac without occupying space in the same way the C: drive does. So you can allocate the entire space and it still wouldn't really affect your Mac.

-Ben

Reply
0 Kudos