Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Virtual machine and i am using VMWare Workstation to run it. The vmdk file, which is the virtual hard drive, is in excess of 40GB. When i start the virtual Machine i can see that i have only 2 Partions. One is a 6GB with Windows XP and the required software installed and the second partition is 3.91GB. This makes just less than 1GB of space in use while the other 30GB is not being used.

I am trying to find a way to shrink this VM HDD file down. I have tried to use the VM tools and another third party tool called Virtual Disk Factory. It might be the case that I am not doing it right.

I would be very much grateful if I can have some help on this matter,

share|improve this question

6 Answers 6

One more alternative is to use the vCenter converter. There is a standalone version that is a free (registration required) download. You can "convert" a VM to the same or other formats, and in the same process you can make modifications such as the size of the virtual disk as long as you leave enough room for the current contents.

I found this when trying to shrink a VD that the virtual disk manager would not allow me to shrink and it worked like a champ.

share|improve this answer

Just create a new vmdk file of the required size and copy the files to it from the old vmdk. You can use any of the disk imaging utilities like Snapshot (www.drivesnapshot.de) to make the copy easier, as they will copy the boot sectors, ACLs etc, but you could actually just copy the files. There's a VMWare utility that will mount a vmdk so the host can see it as a drive letter, or you can boot the VM of a BartPE CD.

JR

share|improve this answer
    
Yes this is probably the safest method. –  PowerApp101 May 28 '09 at 12:45

A VMWare virtual disk is defined with a certain size (e.g. 40 GB), and can be allocated in two ways:

  1. Pre-allocated In this case the disk can not be shrunk. Your best option is the one suggested by renniej: Copy the files to a new disk
  2. Sparse Files Meaning, that the file which represents the virtual disk is grown with its space needs until it reaches the predefined size. In this case you can shrink the disk, if you are willing to delete things or (like in your case) there is still free space in the disk image. The procedure is described in this VMWare support document.
share|improve this answer

Have you installed the VMware Tools into the guest? I seem to recall there being a shrink option in there. Hang on, I'll just check...

...hmmm apparently the Tools shrink option doesn't work for pre-allocated disk (or one with snapshots). Did you pre-allocate the disk? Or did you just let it grow to the current size?

share|improve this answer

If you set the Disk(s) to grow rather than being pre-allocated, and don't have snapshots (this is the hard part). you can use the Shrink option in the VM Tools.

I perform periodic maintenance on my VMs by running all important updates (OS and other software), clearing all the snapshots, and then shrinking the drives. Then I snapshot the baseline again. Of course some of my VMs are loaded with development snapshots for different customers, that I want to keep, so these VMs stay un-updated.

share|improve this answer

Found this article, for using vmware-vdiskmanager. I use this all the time for splitting and expanding and it has a shrink option too.

See here which has details for Windows and Linux hosts.

http: // www.howtoforge.com/how-to-shrink-vmware-virtual-disk-files-vmdk

hope this helps

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.