VMware Communities
cdigs
Contributor
Contributor
Jump to solution

Shrink disk is disabled for this virtual machine

Host environment: Windows XP Professional x64 SP2

Guest environment: Windows Server 2003 R2 SP2

Host environment free disk space: 31.1GB

Guest environment disk size: 13 GB (20 total, 7 free)

Guest environment disk size on host disk: 20 GB

VMWare version: Workstation 6.5.0 build 118166.

The issue:

I am currently unable to perform the shrink operation.

I've done a google search and come across a few scenarios :

However, I have not been able to resolve the issue.

The full message is as follows:

Shrink disk is disabled for this virtual machine. Shrinking is disabled for linked clones, parents of linked clones, pre-allocated disks, snapshots, and other factors.

This VM has definitely been shrunk before. I've attempted to reinstall VMWare Tools and this does not fix it. I've verified that there are no snapshots in snapshot manager. I've also tried as one of the threads suggested: adding a snapshot and then deleting it. I am unable to shrink the disk. For sure, it is not a linked clone or a parent of a linked clone (don't know how to use these). How can I tell if it's a pre-allocated disk (I don't think it is, but who knows)?

On the file system, the directory looks like so:

  • \<guid>.vmem.lck

  • \Windows Server 2003 Standard Edition.vmdk.lck

  • \Windows Server 2003 Standard Edition.vmx.lck

  • <guid>.vmem

  • vmware-0.log

  • vmware-1.log

  • vmware-2.log

  • vmware.log

  • Windows Server 2003 Standard Edition.nvram

  • Windows Server 2003 Standard Edition.vmdk

  • Windows Server 2003 Standard Edition.vmsd

  • Windows Server 2003 Standard Edition.vmx

  • Windows Server 2003 Standard Edition.vmxf

  • Windows Server 2003 Standard Edition-flat.vmdk

Any assistance would be much appreciated.

Reply
0 Kudos
1 Solution

Accepted Solutions
RDPetruska
Leadership
Leadership
Jump to solution

From the file listing you show, your virtual disk is pre-allocated (*-flat.vmdk). As the message indicates, you cannot shrink a preallocated disk.

View solution in original post

Reply
0 Kudos
20 Replies
jayolsen
Expert
Expert
Jump to solution

To check if it is pre-allocated, go to settings of the VM and click the hard disk. Under disk information it should tell you if it is pre-allocated or not. Not sure if that can be changed or not, maybe a vmx file hack?

RDPetruska
Leadership
Leadership
Jump to solution

From the file listing you show, your virtual disk is pre-allocated (*-flat.vmdk). As the message indicates, you cannot shrink a preallocated disk.

Reply
0 Kudos
cdigs
Contributor
Contributor
Jump to solution

Jay, you're right.

It looks like it's pre-allocated.

What a bummer....maybe it can be hacked?

Reply
0 Kudos
jayolsen
Expert
Expert
Jump to solution

you should have a file with extension vmx stored with your VM. This is a text file that can be modified, I didn't know if there was a change for that to change the disk state or not, I'd do a search on vmx file parameters to see if there is.

Reply
0 Kudos
RDPetruska
Leadership
Leadership
Jump to solution

Jay, you're right.

It looks like it's pre-allocated.

What a bummer....maybe it can be hacked?

Hack what? As I pointed out - you have a preallocated disk. There is no POINT in shrinking anything, as you have ALREADY allocated the full space required for this virtual disk.

Now, if you want, you can convert this preallocated disk to a growable type. Use the vmware-vdiskmanager utility to do this. If you are on a Windows host, you can use my GUI wrapper for the disk manager utility. See my profile for website.

Robert

Reply
0 Kudos
cdigs
Contributor
Contributor
Jump to solution

"Hack what? As I pointed out - you have a preallocated disk. There is no POINT in shrinking anything, as you have ALREADY allocated the full space required for this virtual disk."

Well, for me there is a point. I've typically created dynamic disks in the past, but this VM was given to me. Since the guest disk size is 13GB (but taking up the full 20 GB on the host), it'd be great if I could shrink it down to ~13GB on the host system in preparation for compression and upload (my typical procedure when transfering VMs).

"Now, if you want, you can convert this preallocated disk to a growable type. Use the vmware-vdiskmanager utility to do this. If you are on a Windows host, you can use my GUI wrapper for the disk manager utility. See my profile for website. "

Well, now, that's interesting: doesn't that mean that it can be shrunk, then? Isn't that exactly the "hack" that I would need?

Reply
0 Kudos
RDPetruska
Leadership
Leadership
Jump to solution

Well, using something built-in to the product (the diskmanager utility) for its intended purpose isn't considered a "hack". At least not in my book.

Once you convert your disk to a growable type, then you will be able to shrink it, yes.

Reply
0 Kudos
cdigs
Contributor
Contributor
Jump to solution

Take it easy on me man, I'm just a lowly dev., not some IT/systems manager.

I'm not hardcore enough to know these things when it comes to VMWare...just the basics like "hit the 'Play' button to start it" 😄

Thanks for the info!

Reply
0 Kudos
cdigs
Contributor
Contributor
Jump to solution

BTW, the GUI utilities don't seem to work on XP64, citing missing TABCTL32.OCX.

I'll see if I can get it done via command-line.

Reply
0 Kudos
RDPetruska
Leadership
Leadership
Jump to solution

They work just fine if you install the Core Files first, like the page text mentions. Smiley Happy

Reply
0 Kudos
cdigs
Contributor
Contributor
Jump to solution

Interestingly, from the command line, I'm getting an error that says that the file is not a valid disk (but it clearly is).

Too aggrevating; I give up.

Reply
0 Kudos
RDPetruska
Leadership
Leadership
Jump to solution

Are you certain you are using the correct syntax? That's why I recommended my GUI, by the way.

Reply
0 Kudos
cdigs
Contributor
Contributor
Jump to solution

Reply
0 Kudos
RDPetruska
Leadership
Leadership
Jump to solution

From:

*vmware-vdiskmanager -r  win2008-1_2.vmdk -t 0 new.vmdk* 
> 
> 

Sure, you can read the same thing from the documentation (or the help displayed by running diskmanager with no parameters). However, you should also pay attention that you need to use the full path and filenames of the virtual disks and/or the vmware-vdiskmanager utility itself... including using quotes if there are any spaces in the path and/or filename. Hence the reason I wrote the GUI wrapper in the first place. Smiley Happy

Reply
0 Kudos
cdigs
Contributor
Contributor
Jump to solution

As an update, I installed the core files and tried the disk conversion again and it failed with an error dialog stating that it could not read the disk.

Reply
0 Kudos
icando9
Contributor
Contributor
Jump to solution

Anyone has an idea on what 'other factors' means. I have the same problem and I have checked it is not a preallocated disk. By the way, I have some other physical disks. Does it prevent the vm from shrinking? The disk I want to shrink is not a physical one, though.

Reply
0 Kudos
continuum
Immortal
Immortal
Jump to solution

you must shrink manually if one of the vmdks of the VM is a physical disk

to do that create a wiperfile manually inside the VM - see http://www.feyrer.de/g4u/#shrinkimg

then power down the VM and use the shrink option of vmware-vdiskmanager against the vmdk you want to shrink






___________________________________

VMX-parameters- VMware-liveCD - VM-Sickbay


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
gechurch
Contributor
Contributor
Jump to solution

I have been having the same error, and for the sake of posterity thought I would post my experience.

Just to summarise what others have already said, vmdk (virtual hard drives) can be growable or preallocated. Preallocated reserves the space on the host (create a 20GB partition in guest OS, and a 20GB .vmdk file will be generated). Growable will only take up as much space on the host OS as is needed (create the same 20GB partition in the guest, and put 4GB of files on it, and you will have a 4GB .vmdk file on the host system). Once you understand this, it becomes obvious that shrinking a preallocated disk makes no sense.

When you delete a file in the guest OS, all that happens is the space that file was taking up is marked as free space. The file contents still exist on the drive. The guest OS knows this is unused space, but the host system does not, so the space cannot be reclaimed. If you take our 20GB partition above with 4GB space used, and write another 10GB your .vmdk file will grow to 14GB. Delete that 10GB and the .vmdk file will still be 14GB. Write another 10GB to the partition and the .vmdk file will grow to 24GB, even though only 14GB of data is used. This is the danger with growable disks - they can grow larger than the partition sizes in your guest. This is what happened in my situation, and I ran out of space on the host.

To shrink a growable .vmdk file, you boot into the guest OS, and click the shrink tab in Vmtools. This prepares the partition for shrinking by running through the partition and zero-filling the contents of any files that have been deleted. Once you have done this, you power down the guest and run vmware-vdiskmanager -k source.vmdk. It then runs through your .vmdk file, and when it finds a string of 0's it knows that it is space taken by a now-deleted file, and it can be removed. This should bring your .vmdk file size back into line with the amount of space taken up on the partition in the guest OS.

I had the same error as the original poster when I ran VMtools from within the guest. I still don't know why, but the workaround I chose was to download a tool called sdelete. This does the same thing as the preparation step in VMtools. Usage: "sdelete -c -s" from a command prompt. Sdelete works by creating large new files, then writing their contents with 0's, then deleting them. I was almost out of space on the host, so when the large new files were created I completely ran out of space on the host, and the guest OS crashed and was no longer bootable (no room for the .vmem file). I had to go to a backup to get the guest booting again, and in the end I increased capacity on the host and was able to run sdelete (in my case I ran it on a 30GB partition with 13GB taken, which was a 60GB .vmdk file. After sdelete ran the .vmdk file ballooned to 90GB, then dropped to 16GB after the shrink completed). Sdelete took about an hour for me, and the shrink took about 25 mins.

My preference is to move to preallocated virtual disks, which will guarantee this problem doesn't happen again. You can do this by powering down the guest OS, and running the .vmk through the free converter provided by Vmware. Choose virtual to virtual, and point it to the .vmk file (I think you can also point it to a running guest, but I haven't tried this). It will read the .vmk file, and give you options which include being able to change the virtual disks to preallocated, and you can also choose to change their size. I have tried this previously, but it failed, probably due to other inconsistencies in my VM that are a separate issue.

Reply
0 Kudos
mniles74
Contributor
Contributor
Jump to solution

I know this is a pretty dead discussion by now, but I found it helpful. I was not able to resolve my issue with this same error until removing all of my prior snapshots for this VM. Since the error message did not even mention this as a possibility of what might interefere, I thought I'd note it back to this conversation for posterity.

Cheers!

Reply
0 Kudos