Shrink VirtualBox Vdi On Mac With Windows 10 Guest OS

I came across a situation to shrink VirtualBox vdi file having my Windows 10 virtual machine. My host is MacOS Sierra.

The vdi file size grew rapidly while I was doing data manipulation in SQL Server database in Windows 10. Even after shrinking the database size in windows, the vdi file was not reducing in size. So, I’ve done the below steps to manually shrink the size of the virtual machine vdi file.

I thought of publishing the steps to shrink virtualbox vdi on mac with windows guest, so as it may be helpful for someone else.

Software & Tools Involved

  • Host OS: MacOS Sierra
  • Hypervisor: VirtualBox 5.0.26
  • Guest OS: Windows 10
  • SDelete V2.0

Steps to Shrink VirtualBox Vdi On Mac OS

  1. Check the free space in Windows 10 and the size of the virtual machine vdi file.
    shrink virtualbox vdi On Mac with Windows 10 as guest02shrink virtualbox vdi On Mac with Windows 10 as guest03
  2. Login to the Windows 10 guest OS.
  3. Perform a disk cleanup using the Disk Cleanup tool.
    shrink virtualbox vdi On Mac with Windows 10 as guest01
  4. Once the disks are cleaned, you have to zero out the free space. To zero out the free space, use the SDelete tool. Download the SDelete V2.0 from Windows Sysinternals. Extract the downloaded SDelete.zip file. You will see 2 executables sdelete.exe and sdelete64.exe. One for 32-bit os and another for 64-bit os.
    shrink virtualbox vdi On Mac with Windows 10 as guest 04
  5. Open Command Prompt and go to the folder where you have extracted the SDelete files.
  6. Execute the command “sdelete64 -z c:” to zero out the free space in the windows virtual machine. Wait till the cleaning free space process reach 100%. (NOTE: I’ve used the 64-bit version of SDelete and my Windows 10 is 64-bit)
    shrink virtualbox vdi On Mac with Windows 10 as guest 05
  7. Now, shut down windows 10
  8. Open Terminal in host MacOS.
  9. Execute the virtualbox manage command “VBoxManage modifyhd <>> –compact”. Instead of <<<vdi file path>>> use the full path of the location of VDI file.
    shrink virtualbox vdi On Mac with Windows 10 as guest 06
  10. Wait till the compact process reaches 100%.
  11. Check the size of the vdi file. In my case, I’ve gained more than 21 GB of free space.
    shrink virtualbox vdi On Mac with Windows 10 as guest 07

Related

Reference

Refer https://technet.microsoft.com/en-us/sysinternals/sdelete.aspx for more details on using sDelete.


6 thoughts on “Shrink VirtualBox Vdi On Mac With Windows 10 Guest OS”

  1. Needed to sudo su in terminal before it would work OSX High Sierra 10.13.6 , great guide otherwise though. Thanks

    Reply

Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.