Jump to content

How to shrink OS X .vmdk


34 posts in this topic

Recommended Posts

How to shrink os x .vmdk in vmware workstation 12 
As most people probably notice is that .vmdk file expands and never shrinks down back again it just gets bigger and bigger.
 
The solution to fix this in vmware workstation 12 is this:
Open terminal on your guest os OS X machine and run this command:
 
Macintosh\ HD is the name of your harddrive so it might not be Macinthosh \HD for you so check that you type the correct name for your HardDrive.

Use "sudo" instead of "su" if its yosemite or newer
 
su diskutil secureErase freespace 0 Macintosh\ HD
 
It will take some time and when it goes 90+% it will give you an error message that it ran out space and failed just ignore that and let it finish. 
When it has finished shutdown the Guest os and run this command in CMD (command prompt) as administrator on the main OS.
 
path-of-vmware-folder\ vmware-vdiskmanager.exe -k path-of-virtual-machine\guest-name.vmdk
 
Exampel of the one i had to use and dont forget the " " or you will get an error message and it wont start.
C:\"Program Files (x86)\VMware\VMware Workstation\vmware-vdiskmanager.exe" -k "E:\Virtual Machines\OS X 10.9 Mavericks\OS X 10.9 Mavericks.vmdk"
 
This will take some time also so but when its done your .vmdk will now be shrinked down to its real and correct size.
 
I have added and changed so many files on my os x that it became 70gb+ in size but after running this it shrinked back down to just 10,4gb. 
 
The information was gathered from this blog but the commands he had didnt make vmware workstation 12 so it will look different from the blog and he didnt add su to the command and without it will stop.
  • Like 2
Link to comment
Share on other sites

I just did it on el capitan and i worked perfect from 17 gb down to 11gb.

Did you write the command in guest os os x correct so it did the job there first and then the cmd in windows?
Looks like you didn't run the command in OS X since it complains that the disk is full. 
I never get this error i just shrinking % and after some time it hits 100% and gives me:

  Shrink: 100% done.
Shrink completed successfully

Use the example i posted instead of going all the way into the program files folder and vmware workstation folder.
 

The only difference i got in os x el capitan was that it didn't want to accept my password when i used "su" so i had to use "sudo" instead and then it worked like excpected.

either you didn't do the commands correct or you have done something to the .vmdk file 

Link to comment
Share on other sites

Microsoft Windows [Version 6.1.7601]

Copyright © 2009 Microsoft Corporation.  All rights reserved.

 

C:\Windows\system32>C:\"Program Files (x86)\VMware\VMware Workstation\vmware-vdi

skmanager.exe" -k "C:\Users\LuX\Documents\Virtual Machines\OS X 10.11.0 El Capit

an\OS X 10.11.0 El Capitan.vmdk"

  Shrink: 100% done.

Shrink completed successfully.

 

looks like this

 

why did you enter the programs folder so many times? 

Link to comment
Share on other sites

It seems like something is wrong with your config file did you add a lot to it? 
You can just make a new VM so you just get a fresh config file and see if that works you of course change it so it matches the original file placement of the VM you want to shrink.
Just look true the .vmx and vmxf and you should see those fields you need to change.

Link to comment
Share on other sites

It seems like something is wrong with your config file did you add a lot to it? 

You can just make a new VM so you just get a fresh config file and see if that works you of course change it so it matches the original file placement of the VM you want to shrink.

Just look true the .vmx and vmxf and you should see those fields you need to change.

I did add a few lines over the original VMX from a long time ago, but I don't think they'd prevent vmware-vdiskmanager from working properly. Here's my current VMX: http://pastebin.com/SC1dC616

Link to comment
Share on other sites

  • 1 month later...

Hey there !
I have tried this on My Mac OSX El Capitan running on Window 10!
everything worked fine and I got success both from Guest and host system but I didn't see any improvements means I don't see any space free after all this !
Can you guys help me out! How can I get this working

Link to comment
Share on other sites

Simple way using VMware tools:

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

You can repeat for any other mounted disks by replacing the "/" with the mount point. Please remember you cannot shrink disks with snapshots.

Link to comment
Share on other sites

Hey Donk!

I have tried the command you mentioned with no success !

I mean the process works just fine and successful but I am not getting the space back. It just shrink the vmdk but the overall space that I have in guest OS doesn't getting increased !

 

This thread is a not about freeing up space in the guest, it shrinks the virtual disk on the host. 

Link to comment
Share on other sites

Hey Donk!

I have tried the command you mentioned with no success !

I mean the process works just fine and successful but I am not getting the space back. It just shrink the vmdk but the overall space that I have in guest OS doesn't getting increased !

To free up space within the guest, you'd have to delete content from within the VM.

Link to comment
Share on other sites

Ohhhh that's great ! so shriking virtual disk on host doesn't frees space in guest? 
Well, thats sounds ridiculous :D 
how'll the vmdk then actually shrink on host?


Thanks besweet !  I have deleted to get space from the guest. Infact I don't think I am using more than 15-20GB but in my HardDrive info it gives only 4GB remaining!
Can you help! how do I get my 15-20GB that's been lost in Bermuda triangle :( lol

Link to comment
Share on other sites

Ohhhh that's great ! so shriking virtual disk on host doesn't frees space in guest? 

Well, thats sounds ridiculous :D 

how'll the vmdk then actually shrink on host?

Thanks besweet !  I have deleted to get space from the guest. Infact I don't think I am using more than 15-20GB but in my HardDrive info it gives only 4GB remaining!

Can you help! how do I get my 15-20GB that's been lost in Bermuda triangle :( lol

 

It writes zeros to all the unused blocks on the virtual drive and then sends a command to the host VMware process to suspend the virtual machine, delete all zeroed block from the vmdk and then defragment the remaining blocks.

 

It is the same as the manual process documented here.

Link to comment
Share on other sites

I' running into this problem when i try to expand my OS X(El Capitan) virtual machine diskspace on VMware 12 - on Windows 10. With Unlocker 2.07

 

I'm using TechReviews: https://www.youtube....h?v=qIINnuBRsmg - download link: https://goo.gl/2Lu9c6

 

I get this core dump:

vcpu:-0:Verify vmcore/vmm/main/physmem_monitor.c:1178

 

And yes i've already added:   smc.version = "0"   to my VMX configuration file...

 

What is wrong ???

Please i can't expand my OS X VM image: 40 GB preset in VMware is simply to small

 

Regards

Tom

Link to comment
Share on other sites

  • 4 months later...

I see that there is an option to compact the hard disk when I select the Hard Disk within Hardware of the Virtual Machine Settings.

 

I also check the documentation of VMware. I quote it here

 

 


Compacting Virtual Hard Disks

Compacting a virtual hard disk reclaims unused space in the disk. If a disk has empty space, this process reduces the amount of space the virtual hard disk occupies on the host drive. You must power off a virtual machine before you compact its virtual hard disk.

Link to comment
Share on other sites

yes but not for OS X VM only the OS that are supported out of the box like Microsoft Windows operating system not sure about linux havent tried to shrink a linux OS with the built in function.

Link to comment
Share on other sites

yes but not for OS X VM only the OS that are supported out of the box like Microsoft Windows operating system not sure about linux havent tried to shrink a linux OS with the built in function.

 

I don't know that. Usually, I use it for all virtual machines.

Link to comment
Share on other sites

My alternative way to shrink VM disk

 

1. Create a new empty VM disk

2. Clone old VM Osx disk with Carbon Copy Cloner to new one.

3. Install bootloader Clover or Chameleon in new VM

4. Use New VM and delete old one

 

Imo. I think that it is a faster way ...

 

See Ya

 

PippoX0

Link to comment
Share on other sites

 Share

×
×
  • Create New...