VMware Communities
MB2009
Contributor
Contributor
Jump to solution

How to make a virtual machine smaller

I have two virtual machines that were created using VMWare Workstation that I am running on another machine using VMWare Server. I need to send the virtual machines to a colleague so he can debug some issues I reported but the virtual machines are just too big. Each folder compressed (zipped) is 12GB. I checked and the virtual disks are not pre-allocated -- it says on the VMWare server | Edit Disk option: "Disk space is not preallocated for this virtual disk.Virtual disk contents are stored in a single file."

I need to upload the virtual machines and that process is taking forever -- I zipped the individual files and am trying to upload the 3GB zips one at a time, but it is still too slow.

I checked the VMWare Tools | Shrink tab and that is disabled with the message "Shrink is disabled for this virtual machine. Shrink is disabled for linked clones, parents of linked clones, pre-allocated disks, snapshots, and other factors."

Is there any way to make the whole virtual machine folder smaller? I just want to share the VM so the problem can be reproduced and debugged... Any better way of doing that?

Any help will be appreciated!

0 Kudos
1 Solution

Accepted Solutions
WoodyZ
Immortal
Immortal
Jump to solution

I did all that and was able to add the VM to my inventory, start it, and run "Shrink" from VMware Tools.

It  ran on the disks withou any error, however, the vmdk file size is the  same as before running Shrink: 16GB. Is that correct? Does that mean I  cannot get any smaller than that?

Assuming Shrink in VMware Tools under VMware Server worked as it's supposed to...

According to the vmware.log file the virtual hard disk is a 16 GB monolithicSparse (single growable file) type disk and assuming you used the option -t 0 and not -t 2 when using vmware-vdiskmanager then if after a shrink operation it is 16 GB in size at first thought I'd say the disk was full however consider the following.

How much free space is reported when looking at the properties for the C: Drive in Windows Explorer (from within the Guest)?

Generally speaking the amount of used spaced is the size it should end up after a shrink operation.

There are a few thing that can be done prior to shrinking to help decrease the final size...

IIRC In Windows Vista, System Restore defaults to 15% of the size of the hard disk so purging Restore Points could save as much as 2.4 GB on a 16 GB disk.

Purging Browser Caches (i.e. Temporary Internet Files in Internet Explorer).

Deleting the contents of the %TEMP% folder and C:\Windows\Temp.

Turn off Hibernation and delete the C:\hiberfil.sys file (hidden by default) as this file is the size of the amount of RAM the Virtual machine is assigned.

There is more that can be done however what has already been mentioned covers the primary areas that can decrease the shrunk size of a virtual hard disk.

View solution in original post

0 Kudos
27 Replies
WoodyZ
Immortal
Immortal
Jump to solution

Delete the snapshots and then you can shrink the disk and the zip it up.  If you need to keep the VM with snapshots on your system then make a copy that you can delete the snapshots from and then you can shrink the disk and then zip it up.

0 Kudos
MB2009
Contributor
Contributor
Jump to solution

Thank you for your post. Deleting all *snapshot.vmsn and *snapshot.vmem files from disk was the first thing I did. The folders currently have no snapshots, but VMWare Tools still shows the "Shrink" tab as disabled.

Should I have removed the snapshots some other way? I have them on a separate disk, so I can still put them back into the folders and remove them some other way (instead of directly deleting them from my HD).

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Should I have removed the snapshots some other way?

Yes and you should never manually delete files unless you know totally what you're doing! Smiley Wink

I have them on a separate disk, so I can still put them back into the folders and remove them some other way (instead of directly deleting them from my HD).

You can try putting them back and see if the VM still runs and then delete the snapshot properly through the Programs GUI.  See the Programs Documentation and or Help File to see how to properly delete Snapshots.

If you put the file back an can't get it to run let me know and I'll give you directions to manually create a new .vmdk from the existing ones, providing they're all there.

0 Kudos
MB2009
Contributor
Contributor
Jump to solution

The virtual machines run fine without the *snapshot files.

I copied the snapshot files back, but when I open VMWare Server and look at the summary for the virtual machines, it only shows Snapshots | Take Snapshot option -- and that is a sign it does not "see" any snapshots for the VM, isn't it?

After copying the snapshot files back I tried to run one of the virtual machines and it still runs fine; the "Shrink" option is still disabled though.

Both the virtual machines and the snapshots were created with VMWare Workstation, but I am running them using VNWare Server on this machine. Could that be the problem?

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

The files you moved are not Snapshot or Delta Virtual Disks, they are are the snapshot state and memory backing files and not the same as a snapshot or delta virtual hard disk.

Need to see the vmware.log file from the VM, so archive (compress it) and attach the .zip archive to a reply post.

Then I can advise you base on the actual state of the VM.

0 Kudos
MB2009
Contributor
Contributor
Jump to solution

I zipped the .LOG files that are in the Windows Vista (one of the two VMs I need to upload) virtual machine folder (see attached).

I hope you can see something there that will help...

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Okay you do have several Snapshots in play.

You have 5 Snapshot or Delta Virtual Hard Disks.

"Windows Vista-000009.vmdk"
"Windows Vista-000005.vmdk"
"Windows Vista-000006.vmdk"
"Windows Vista-000002.vmdk"
"Windows Vista-000001.vmdk"

This is the order in which they are opened as shown in the vmware.log file.

Give me a few to check out the controls in VMware Server and I'll get back shortly with a recomendation.

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Okay, I think the best course of action is to create a new Base Disk using vmware-vdiskmanager and then it can be shrunk if necessary.

The current Snapshot Disk is "Windows Vista-000009.vmdk" so that is what you'd use as the source with vmware-vdiskmanager and the syntax follows.

vmware-vdiskmanager -r sourceDisk.vmdk -t 0 destinationDisk.vmdk

If you need additional instructions let us know.

MB2009
Contributor
Contributor
Jump to solution

I executed the following command:

"C:\Program Files\VMware\VMware Server\vmware-vdiskmanager" -r "Windows Vista-000009.vmdk" -t 0 ShrinkableVista.vmdk

And the result was:

Creating disk 'ShrinkableVista.vmdk'
Failed to convert disk: The called function cannot be performed on partial chains. Please open the parent virtual disk (0x500003e83).

So I guess I will need to run this on the "Windows Vista-000001.vmdk"? It sounds like that one is the parent-most snapshot. I tried that, but nope, I got the same error above. Does it mean I should open "Windows Vista.vmdk"? I tried that and processing started. Not sure what I am going to get at the end...

OK. If this works, it should create a growable disk based on the *.vmdk that I use as source, but then what do I do with it? Do copy the disk created with vmdiskmanager to a new folder and add it as a new virtual machine to my Server so I can use the "Shrink" option of VMWare Tools? Do I copy all the other files to the new folder as well so all can be part of the shrinking process?

Thank you for all your help so far! I am checking the documentation of vdiskmanager to see if I find some answers there too.

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Let me repeat what I already said...

The current Snapshot Disk is "Windows Vista-000009.vmdk" so that is what  you'd use as the source with vmware-vdiskmanager...

This means if you use any other snapshot disk as the source you loose what is not in the chain.  Also selecting the "Windows Vista.vmdk" file, the Base Disk, means you loose everything in all the Snapshot Disks!

Base on the Error Message there is obvious something wrong with the Virtual Machine in the way the disks are chained and this is going to need to be resolved.

Because the VM is using a monolithicSparse (single growable virtual disk) virtual hard disk this process is not going to be easy however it has to be done if you want this fixed.

I'm going to need two thing, one a file listing of the folder containing the Virtual Machine as made using the directions below and two is to see the embedded "Disk DescriptorFile" for each disk and will provide a link for a program to use and a command script to make extraction easier.

For the file listing open a Command Prompt and the type cd followed by a space and then drag and drop the folder the Virtual Machine is in onto the Command Prompt, this populates the command line with the fully qualified pathname, and press Enter.  The prompt should not reflect the folder the files that comprise the Virtual Machine.  Next use the following command, as it, to create the file listing.  Hint: You can copy and paste it into the Command Prompt.

dir /o:e /t:w > filelist.txt

For the embedded "Disk DescriptorFile" have a look at: How to safely edit embedded vmdk-descriptions  Note:  This site belong to continuum who also is a member of these forums.

Next using the dsfo.exe from the link provided and the attached command script (GetDiskDescriptorFile.cmd) do the following.  Place the dsfo.exe and the extracted command script (GetDiskDescriptorFile.cmd) in the folder the files that comprise the Virtual Machine are in and then execute (double-click) the GetDiskDescriptorFile.cmd command script.  This will create 6 files named WindowsVista-*-DiskDescriptorFile.txt.

Archive (compress) the filelist.txt and the extracted "Disk DescriptorFile" files into a single .zip archive and attach to a reply.

0 Kudos
MB2009
Contributor
Contributor
Jump to solution

Well, since I got the error running vmware-vdiskmanager against the snapshot, I tried against the main file and that ran without errors. I ran the VM using that result file and it is all there -- I have not lost anything; the file Windows Vista.vmdk is just a bit smaller than the original one.

Anyway, I followed the steps you listed and am attaching here the ZIP containing all the outputs you asked for.

I hope we can fix everything so I will be able to reduce the size of the VMs, but should compressing the VMs be always this complicated? I was hoping to simply run a command or utility and compact the whole thing to a sharable size...

Again, thank you very much for doing all this!

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

I tried against the main file and that ran without errors. I ran the VM using that result file and it is all there -- I have not lost anything

There is no way whatsoever with the sizes of and number of snapshots that running that command against the base disk "Windows Vista.vmdk" vs. the newest snapshot disk "Windows Vista-000009.vmdk" that you are not missing anything.

Each Snpshot Disk is a Delta of its Parent Disk meaning its contents does not exist in it parent and as such the snapshots have to be processed in order to end up with a new base disk containing everything.

Anyway having looked at the filelist.txt file I have to apologize I apparently didn't review the vmware.log file thoroughly enough and missed some in the command script so here is a new command script attached and if you delete the existing WindowsVista-*-DiskDescriptorFile.txt files and run this new script and also include the "Windows Vista.vmsd" file in the .zip archive it will be more helpful for me to get the full picture.

but should compressing the VMs be always this complicated?

No however there is something wrong so lets take care of that first and part of the issue is it looks like VMware Server only works with one snapshot at a time so bringing a VM with multiple snapshots from VMware Workstation is not the best way to migrate.

Message was edited by: WoodyZ Forgot to attach the new script.

0 Kudos
a_p_
Leadership
Leadership
Jump to solution

IMO all the files look good ok. I'm not 100% sure, however the error message you get from

vmware-vdiskmanager -r "Windows Vista-000009.vmdk" -t 0 ShrinkableVista.vmdk

could be the result of a buggy vmware-vdiskmanager.exe version!?

I'd suggest you copy the vmdk files over to the machine with VMware Workstation and run the command on this machine.

If this works, copy the new vmdk back to the VMware Server machine and make sure you replace the virtual disk in the VM's settings with the new one.

André

MB2009
Contributor
Contributor
Jump to solution

> There is no way whatsoever with the sizes of and number of snapshots that running that command against the base disk "Windows Vista.vmdk" vs. the newest snapshot disk "Windows Vista-000009.vmdk" that you are not missing anything.

The running VM seems fine to me and contains what I was testing before, including the latest programs I installed. Maybe when I added the VM to the Server (and said it was a copy), the Server consolidated the snapshots or something. Would that be possible?

Well, I ran the second script and here is the result plus the filelist.txt and Windows Vista.vmsd.

0 Kudos
MB2009
Contributor
Contributor
Jump to solution

Thanks, Andre, but I do not have access to the VMware Workstation right now -- I am traveling and have only VMware Server on this machine.

0 Kudos
MB2009
Contributor
Contributor
Jump to solution

Hi WoodyZ,

Have you had a chance to take a look at the latest file I uploaded? Does it you give you any clue to what could be wrong with my VM?

Thank you,

Marcia

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Yes, I looked and the CID and parentCID values in the Disk DescriptorFile .vmdk files and are okay and the necessary files match the information in the vmware.log file so I'm thinking that that what André said may be part of the issues however have not had time to test it yet.  However I will test a VM with multiple Snapshots copied to VMware Server and then try vmware-vdiskmanager under VMware Server to see if it errors out or not and report back in a little while.

0 Kudos
MB2009
Contributor
Contributor
Jump to solution

OK. Thank you for looking into it. I hope you can figure out what is wrong so I can create a smaller VM. This is the first time I am doing this and it has not been a smooth process. 😞

Let me know if you need more information from the VMs here.

0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

Okay, André was right and to workaround the issue I used the vmware-vdiskmanager from the Virtual Disk Development Kit.

I download the Virtual Disk Development Kit and installed it on the system running VMware Server 2.0.2 and then use the vmware-vdiskmanager from it pointing to the appropriate Snapshot Disk and it worked without the error message the one installed in VMware Server 2.0.2 gave and remember in your case it's going to be pointing to "Windows Vista-000009.vmdk".  Look back at my reply Re: How to make a virtual machine smaller for the command syntax and make sure the destinationDisk.vmdk is not going into the same folder as the sourceDisk.vmdk so as not to accidentally overwrite the original file if you name the destinationDisk.vmdk, "Windows Vista.vmdk".

If you're not sure what to do then ask before hand. Smiley Wink

0 Kudos