It is possible to free up quite a bit of hard disk space by compacting your virtual disks for VMWare.
Here is a easy (manual) way to shrink a Windows guest image hosted on VMWare Fusion for Mac OS. I have used the recipe below to successfully save about 50% of disk space for a Windows 2003 R2 guest image on Mac OS 10.5.2 running VMWare Fusion 1.1.1. Other Windows guest OS’s like Windows 95, 98, NT 4.0, Win2K, XP should work with this recipe as well, although this is untested at this time.
Warning: This recipe may/may not work for you. Beware of the risk! Remember to backup your disk image before messing with it. Finally, do not shrink a disk with snapshots as this is known NOT to work!! Update: See additional recipe at bottom of this post for how to deal with snapshots.
Shrink recipe:
- First backup your guest os disk image and other files (just in case something goes wrong) + make sure you have plenty of spare disk space on your harddrive.
- Start Windows guest OS in VMWare Fusion and login as administrator
- Clean up & defrag guest OS disk image from within guest OS
* Delete all unused files, empty your trash can, delete your browser cache etc.
* Defragment your guest OS (f.x. using “defrag c:” in the cmd prompt). - Zero out unused disk space in guest OS disk image
* Download Mark Russinovich’s disk erase tool SDelete v1.51+ and place it on the local guest drive (*1).
* From a command prompt navigate to where you saved the above delete tool and write “sdelete -c c:”, which will clear all free disk space - Close guest OS and VMWare
* Shutdown your Windows guest OS.
* Quit VMWare fusion - Shrink disk image using VMWare’s diskTool
* Navigate to the VMWare Fusion tools directory. E.g. type “cd /Applications/VMware Fusion.app/Contents/MacOS”
* Run VMWare Fusion’s diskTool command with the shrink option “-k” to compact your virtual drive (*.vmdk). E.g. type “./diskTool -k 0 full-path-to-your-virtual-desk-image.vmdk”. (*2) - Finished!
*1) Nb. this erase tool is not documented to be compatible with Windows 2003/XP, but it works just fine on on my Win2003 R2 (as far as I can tell).
*2) Do remember the “./” when running diskTool to avoid mis-executing the Mac OS disk tool with the same name instead.
UPDATE – QUICK SNAPSHOTS CONSOLIDATION TIP:
If your disk image has snapshots you need to consolidate those into one large disk before attempting the above recipe. You can create a single disk image by cloning (merging) your disks using VMWare’s diskCreate tool (located in same folder as diskTool). The procedure is:
- Again backup your stuff first in case things go wrong (and again make sure you have plenty of spare disk space).
- Create a new folder with the extesion .vmwarevm to hold the output files.
- Navigate to the VMWare Fusion tools directory. E.g. type “cd /Applications/VMware Fusion.app/Contents/MacOS”
- “./diskCreate -C path-to-latest-snapshort-vmdk-file.vmdk path-to-new-merged-disk-file.vmdk” (use output folder above for destination).
- Copy the .vmx , .vmdk and .vmxf files into the output folder. Use a texteditor to edit the .vmx (and .vmxf) files to reflect the new disk file name.
- Test that the new consolidated image works in VMWare fusion.
- You can now proceed to the recipe for shrinking your disk.
May 2, 2008 at 7:33 |
Thanks for this tip.
On my Mac I’m running VMWare Fusion 1.1.1 with Windows XP SP3. The original size of my virtual disk image before shrinking was 19.49GB. Now after running this recipe the new size is 7.57GB. That’s more than 50% reduction.
Thanks a lot
May 13, 2008 at 4:11 |
msbob says:
1. Use to windows defrag tool
2. delete your snapshot (under Virtual Machines)
3. Open the vmware tools in the task bar
4. Choose the “shrink” tab
done!
save a ton of space
May 13, 2008 at 8:14 |
msbob – The more complicated recipe in the posting provides the best possible shrinking while retaining all your data. There are simpler ways to do this but they are not very good (AFAIK).
The problem with your 1-4 recipe is: a) VMWare needs a zero-filled HD for shrink to be truly effective (you should be able to see a significant difference if you compare the results). b) Your latest changes in your snapshots get deleted. What if you need the changes?
May 13, 2008 at 19:07 |
Woot! I’ve been trying to shrink a Parallels image for weeks but it refused to slim down (8gb used vm space took up 21 gigs HD space!). I found you page, converted the image to a VMware image and followed your instructions and everything worked! I have 13gigs of HD precious laptop HD space back. Also, one additional suggestion for those of you who are willing to take the performance hit, I suggest compressing your files first, then defrage and then free space wipe.
May 23, 2008 at 23:06 |
Had a little issue that I can’t seem to resolve. Deleted my Snapshot from the Virtual Machine menu. It began to “clean up” and I switched back to another app – I thought. I hit the escape key and the “clean up” progress window disappeared. It would appear that my snapshot was deleted but not cleaned up.
Not even sure how to identify if I have remnants of a snapshot left. Are the in the Contents/MacOS folders within my VM in the Virtual Machines directory? I followed the shrink recipe and everything seemed work correctly. Follow every step. Windows XP image went from 45GB to 65GB! Opposite of what I expected to say the least.
No worries in that I have a back up. But before I try this again, I’m wondering if I have some “wonkiness” from my snapshot faus pax.
Suggestions?
May 23, 2008 at 23:14 |
yes, you must have had active snapshots when you tried the recipe. That is the reason your image grew. As I warned in the posting, the recipe does NOT work if you have snapshots (they have to be completely removed or consolidated first). All the snapshot files are inside your vmware image (which is a directory – the content of which you can see in the finder by choosing show package content).
May 27, 2008 at 16:06 |
Thanks MMC. Part of my concern is that I’m not 100% sure which of the files within the MacOS directory represent snapshot pieces and parts. Nor am I sure whether or not – once identified – whether i can just delete them. I certainly don’t need the snapshots at this point so deleting them won’t risk a loss for me.
I realize I probably should be directly requesting support from you in this manner. Apologies in advance. If you have suggested forums or sources where I might better research this, I’d be happy to do my investigating there. You’re info is very helpful but I don’t want to be a pain.
May 27, 2008 at 16:34 |
I suggest backup+experimentation+google to find out…. Sorry, I don’t have time for much else in this blog setting (we do however provide paid consultancy – although this is mostly in the software R&D area. See http://www.41concepts.com).
May 28, 2008 at 19:29 |
Quick update. Followed your advice. Found a post on the VMFusion forum about creating a new snapshot and then discarding it. Doing this cleared my previously screwed up snapshot and has allowed me to successfully shrink my image. Thanks for your help.
June 4, 2008 at 3:03 |
Hi, stumbled across this post because someone referenced it on our forums.
mmc: msbob is correct. The VMware shrink process is two stages – the first zero-fills the vmdk, the second stage shrinks the vmdk. Your manual process is equivalent, but using the UI in the guest does both passes (this is why you get two successive progress bars, one for each pass).
“Discarding” a snapshot is a really unfortunate naming convention that we’re stuck with for historical reasons. When you discard a snapshot from the UI, you’re not discarding the data – you’re discarding the ability to go back to that state. Your data is merged back to the base disk, just like your manual procedure of copying the disk. “Reverting” to a snapshot is what loses your changes.
This is different from what happens if you discard snapshot files from the host, in which case you lose changes.
June 4, 2008 at 3:23 |
Stumbled across this post because someone referenced it on our forums.
mmc: msbob is correct.
It’s true that shrinking wants a zero-filled hard drive, which your manual process accomplishes. However, the Tools shrink process does this for you – this is why you get two successive progress bars. The first, in the guest, is the zeroing pass. The second, on the host, is the space reclamation.
“Discarding” a snapshot is a very unfortunate piece of historical terminology that we’re stuck with. If you go through the Fusion UI, discarding a snapshot does not delete your data. What it removes is the ability to go back to the point in time where the snapshot was taken – your changes get merged back to the base disk (as your manual procedure does, except we can be smarter than a full copy). “Reverting” is what deletes the changes since the snapshot was taken.
This is in contrast with deleting a snapshot from the Finder, which would indeed lose your changes.
June 4, 2008 at 9:43 |
etung: Thanks for the feedback. My historic experience with the integrated tool shrink processes in VMWare is not as good as this manual process – I never got as good a result with the original (not very documented) functionality as with this recipe. But I guess it is worth trying some more using the latest VMWare versions.
June 7, 2008 at 20:08 |
Sorry for the double post, feel free to delete one of them. I was confused because the first time I rejected the site’s cookie and didn’t see any indication my post had been made.
Your step 3 (defrag, delete unnecessary files) is something Tools Shrink doesn’t do and will help. Can you quantify what you mean by “never got as good a result” – how big a difference are we talking here?
June 7, 2008 at 20:29 |
tung: With my manual procedure I got about 50% reduction which is very noticeable
The reduction I got the last time I tried the build-in shrink in VMWare was much less. I don’t remember the exact percentage…. maybe 25% or so. On the other hand the numbers can’t really be compared since it was a while ago and on a PC with a different VMWare version/setup.
The conclusion that I think we can agree on is that my manual procedure delivers good results – even though I can not rule out there are now easier ways to do this.
July 2, 2008 at 4:32 |
Humm. This doesn’t seem to do anything on mine. I enter the command, and I get the prompt immediately.
I believe this solution is only for dynamic disks, which I regret not creating in the first place. When i converted other laptop to a Virtual Machine disk to use in Fusion (and that was SWEET btw!), I selected the Allocate all space now option – which is suppose to increase performance, but not being dynamic.
Now, I am sitting on a 93 GB vmdk – that only has 23 GB in use.
I’ll try searching a bit more about to find out how to convert it to a dynamic disk. Right now, the only option I have found instructs you to use a Windows machine – which I do not have for a bit. Grrr.
September 8, 2008 at 1:03 |
I tried the “manual” procedure in a Windows 2000 Pro VM in VMware 1.1.3 and I got an error running the zeroing utility.
Using the built-in shrinking utility (after defragmenting) I was able to reduce the VM bundle size from 2 704 873 255 bytes to 952 248 277 bytes. I did a “clean” installation of Windows 2000 Pro and then installed WinRAR, eTrend (and updated the signature) and applied SP4 (all from a CD).
September 8, 2008 at 22:23 |
Right now I want to throttle you. This article just killed my VM and my Mac.
When I create a VM I always choose a big HD size i.e. 100Gb but don’t let it reserve that space. That way you don’t end up with a machine that one day is capped for disk space (happened to me too many times). Back in the day we created VMs with a 20GB drive thinking that would never get exceeded. Now I build them 100GB. When you disk zero it tries to write the whole f***king 100GB and if you dont have that on the Host then bye bye disk space.
Annyed at you but more at myself for not forseeing it. I fucking hate VM’s somedays.
September 10, 2008 at 23:11 |
Could you give an example of what a correct path might be, I’m trying this but I’m getting a file not found:
./diskTool -k 0Users/myusername/Documents/Virtual Machines/Windows XP Professional.vmwarevm/Windows XP Professional-SCSI_0-0.vmdk
October 29, 2008 at 4:55 |
Ummm, easier way…VMware tools installed on the client. There’s this really neat tab that says “Shrink” Highlight the drive you want to compress, then click “prepare to shrink” then it does it all for you.
November 5, 2008 at 21:21 |
[...] Here is a great post about how to shrink your VMWare fusion disk image [...]
January 31, 2009 at 5:05 |
[...] Shrink your Windows disk image on VMWare Fusion (Mac) « 41 technologies (tags: mac howto vmware virtualization) January 30th 2009 Posted to Links [...]
February 1, 2009 at 23:29 |
[...] http://techblog.41concepts.com/2008/03/31/shrink-your-windows-disk-image-on-wmware-fusion-mac/ (42) [...]
February 12, 2009 at 14:34 |
if you are using vmware fusion 2.0, the tool is located on /Library/Application Support/VMware Fusion/vmware-vdiskmanager
March 11, 2009 at 14:48 |
Hello,
I was trying to follow the instruction and in the final step 6 : I couldn’t find the diskTool for VMware in the /Applications/VMware Fusion.app/Contents/MacOS” directory.
And cannot run the command “./diskTool ……..”
Any suggestions ??
Thanks.