VMWare Fusion Reclaim Free Space of OS X Guest: Difference between revisions

From Wurst-Wasser.net
Jump to navigation Jump to search
 
(15 intermediate revisions by the same user not shown)
Line 2: Line 2:


=== The Problem ===
=== The Problem ===
As pointed out [https://communities.vmware.com/thread/272457 here], the [[OS X]] guest does not actually delete files, it just won't remember, where the file is stored on the disk. So all the file's data is still stored on the disk. We need to permanently delete the file's data, and then the space can be reclaimed.
As pointed out [https://communities.vmware.com/thread/272457 here] and [http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1001934 here], the [[OS X]] guest does not actually delete files, it just won't remember where the file is stored on the disk. So all the file's data is still stored on the disk. We need to permanently delete the file's data, and then the freed space can be reclaimed.


=== The Solution ===
=== The Solution (more like a Workaround) ===
* Startup your guest os
* Startup your guest os
* Log in as administrator
* Log in as administrator
* Overwrite all deleted files with zeroes…
* Get your root-device (the <tt>/</tt>):
** Get your root-device (the <tt>/</tt>):
  Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$ <i>mount</i>
  Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$ mount
  <b>/dev/disk0s2</b> on <b>/</b> (hfs, local, journaled)  
  <b>/dev/disk0s2</b> on <b>/</b> (hfs, local, journaled)  
  devfs on /dev (devfs, local, nobrowse)
  devfs on /dev (devfs, local, nobrowse)
Line 16: Line 15:
  .host:/VMware Shared Folders on /Volumes/VMware Shared Folders (vmhgfs)
  .host:/VMware Shared Folders on /Volumes/VMware Shared Folders (vmhgfs)
  Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$  
  Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$  
** Erase the free space:
* Erase the free space:
  Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$ sudo diskutil secureErase freespace 0 /dev/disk0s2
  Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$ <i>sudo diskutil secureErase freespace 0 <b>/dev/disk0s2</b></i>
  Started erase on disk0s2 Macintosh HD
  Started erase on disk0s2 Macintosh HD
  Creating a temporary file
  Creating a temporary file
Line 29: Line 28:
* Now, reclaim the free space:<br>[[Image:VMWareFusion6ReclaimSpace01.png]]
* Now, reclaim the free space:<br>[[Image:VMWareFusion6ReclaimSpace01.png]]


=== The Solution ===
Thanks to Marco, there is another way<ref>not tested yet</ref>:
sudo /Library/Application\ Support/VMware\ Tools/vmware-tools-cli disk shrinkonly
=== And one more method… ===
They claim<ref>http://superuser.com/questions/325233/can-you-shrink-the-sparse-disk-image-of-a-mac-os-x-guest-os-in-vmware-fusion</ref> this might work:
1. Erase formerly used space on your guest OS' disk:
diskutil secureErase freespace 0 Macintosh\ HD
sudo halt
or
sudo diskutil secureErase freespace 0 /
sudo shutdown -h now
2. Then shrink the sparse image:
[ -d "/Library/Application Support/VMware\ Fusion" ] && alias vmware-vdiskmanager="/Library/Application Support/VMware Fusion/vmware-vdiskmanager" || alias vmware-vdiskmanager="/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager"; vmware-diskmanager -k <path-to-disk-image-of-your-guest-os>
or simply:
/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k <path-to-disk-image-of-your-guest-os>
f.e.:
/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k /Volumes/EsDeh/Documents/Virtual\ Machines/OS\ X\ 10.11.vmwarevm/Virtual\ Disk.vmdk
----
Footnotes:
<references/>


[[Category:Mac OS X]]
[[Category:Mac OS X]]

Latest revision as of 17:00, 14 November 2015

After installing OS X in a VMWare Fusion v6, I noticed that the disk images are continously growing. And VMWare Fusion won't let me reclaim the free space.

The Problem

As pointed out here and here, the OS X guest does not actually delete files, it just won't remember where the file is stored on the disk. So all the file's data is still stored on the disk. We need to permanently delete the file's data, and then the freed space can be reclaimed.

The Solution (more like a Workaround)

  • Startup your guest os
  • Log in as administrator
  • Get your root-device (the /):
Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$ mount
/dev/disk0s2 on / (hfs, local, journaled) 
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
.host:/VMware Shared Folders on /Volumes/VMware Shared Folders (vmhgfs)
Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$ 
  • Erase the free space:
Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$ sudo diskutil secureErase freespace 0 /dev/disk0s2
Started erase on disk0s2 Macintosh HD
Creating a temporary file
Securely erasing a file
Creating a secondary temporary file
Mounting disk
Finished erase on disk0s2 Macintosh HD
Mac-OS-X-108-Mountain-Lion-VM:~ appleadmin$

The Solution

Thanks to Marco, there is another way[1]:

sudo /Library/Application\ Support/VMware\ Tools/vmware-tools-cli disk shrinkonly

And one more method…

They claim[2] this might work:

1. Erase formerly used space on your guest OS' disk:

diskutil secureErase freespace 0 Macintosh\ HD
sudo halt

or

sudo diskutil secureErase freespace 0 /
sudo shutdown -h now

2. Then shrink the sparse image:

[ -d "/Library/Application Support/VMware\ Fusion" ] && alias vmware-vdiskmanager="/Library/Application Support/VMware Fusion/vmware-vdiskmanager" || alias vmware-vdiskmanager="/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager"; vmware-diskmanager -k <path-to-disk-image-of-your-guest-os>

or simply:

/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k <path-to-disk-image-of-your-guest-os>

f.e.:

/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k /Volumes/EsDeh/Documents/Virtual\ Machines/OS\ X\ 10.11.vmwarevm/Virtual\ Disk.vmdk

Footnotes: