Jump to content

VMware Workstation - How to compress/cleanup VMDK?


  • Please log in to reply
6 replies to this topic

#1
besweeet

besweeet

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 111 posts

My 10.8.3 VM ended up using the entire 150GB VMDK space, even though the OS itself uses less than 10GB. Since VMware Workstation can't compress/reclaim space/cleanup HFS+ VMDKs, how would one get the space back without having to start over? I've tried adding an empty VMDK to the VM and cloning it using a number of different methods (Disk Utility, Carbon Copy Cloner, SuperDuper!, Terminal), yet none of them managed to get the new VMDK to boot properly.

 

Any ideas?



#2
Zenith432

Zenith432

    InsanelyMac Sage

  • Developers
  • 420 posts
  • Gender:Male

You need to zero unused sectors before compressing.  When compressing a vmdk, it eliminates sectors only if they're all zero.  Otherwise it can't know if the sector is occupied or not.

So go to any folder on the volume in the guest and run

cat /dev/zero >zero.fill; sleep 1; sync; sleep 1; /bin/rm -f zero.fill

Then shutdown the guest and run VMware's compression on the vmdk.

 

Edit: note that it is not perfect, because there's some discarded space inside HFS metadata - like free inodes and such that are no longer used - but will not be zeroed with this.  Not sure whether there's a tool for HFS to free unused metadata space.



#3
besweeet

besweeet

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 111 posts

Thanks, but after a while, Terminal said this:

cat: stdout: No space left on device
 
Not sure how to continue.


#4
Zenith432

Zenith432

    InsanelyMac Sage

  • Developers
  • 420 posts
  • Gender:Male

quit terminal, shutdown the virtual machine, and run the VMware compact on the vmdk.

Not sure how to continue.

 



#5
besweeet

besweeet

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 111 posts

quit terminal, shutdown the virtual machine, and run the VMware compact on the vmdk.

Oops, forgot to post this earlier: I ended up doing exactly that, and it worked! Went from nearly 150GB for the VMDK down to less than 9GB.



#6
MSoK

MSoK

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 941 posts
  • Gender:Male
  • Location:Darlington UK

I use Disk Utility to "Erase Free Space", select your virtual hard disk in DU select the Erase tab and click on the "Erase Free Space..." button I leave the default setting of "Fastest" and click on the "Erase Free Space" button and wait for the Erasing Free space to complete, it will take some time. Once complete shutdown the OS X VM, and edit Virtual Machine Settings, select the Hard Disk and select "Compact" from the "Utilities" pull down menu, a progress bar will appear to indicate the "Compacting virtual disk..." has started, again this will take some time, but at the end of the process the hard drive VMDK should have shrunk in size.



#7
besweeet

besweeet

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 111 posts

I use Disk Utility to "Erase Free Space", select your virtual hard disk in DU select the Erase tab and click on the "Erase Free Space..." button I leave the default setting of "Fastest" and click on the "Erase Free Space" button and wait for the Erasing Free space to complete, it will take some time. Once complete shutdown the OS X VM, and edit Virtual Machine Settings, select the Hard Disk and select "Compact" from the "Utilities" pull down menu, a progress bar will appear to indicate the "Compacting virtual disk..." has started, again this will take some time, but at the end of the process the hard drive VMDK should have shrunk in size.

I remember using Erase Free Space when the VMDK was at around 55GB, and it ended up filling the entire thing... I probably had the wrong setting. I'll try that the next time it fills itself up, thanks.







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy