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 am hosting several virtual machines on a host running Hyper-V Server 2008 R2. The disks were originally provisioned on a different server (2008, not R2) about 16 months ago, and were migrated onto this server one year ago. Most guests are running Windows 7.

Recently I was comparing the VHD size to used space reported by the guest, and noticed that several machines had VHD files that were 50-100% larger than actually needed. So I decided to try compacting the VHD files to free up space on the host. I followed instructions I found on the internet, roughly as follows:

  1. Run CHKDSK in the guest machine
  2. Run a defrag in the guest machine (Windows built-in defrag)
  3. Shut down the guest
  4. Open "Edit Disk..." tool in Hyper-V Manager
  5. Select the VHD of interest and choose to compact it

The first time I tried this, it worked flawlessly and reduced the size of my VHD by about 50%. But for the disks of every other guest, I get this error message:

The server encountered an error trying to edit the virtual disk.

'The system failed to compact 'C:\example.vhd'. Error Code: The requested
operation could not be completed due to a file system limitation

No guests have NTFS compression enabled. There are no snapshots of these disks. What else could be causing this error?

Edit: Bonus points for anybody who describes a solution to keep dynamic VHD sizes in check automatically.

share|improve this question
1  
do you have guest level shadow copies? –  tony roth Feb 10 '12 at 2:05
    
Ah, yes. That was the problem. But not why post that as an answer? –  Nic Feb 10 '12 at 3:08
    
wasn't quite sure of the answer. –  tony roth Feb 10 '12 at 21:07
    
Also the only way to keep dynamic disks from screwing things up is to not allow dynamic disks. –  tony roth Feb 11 '12 at 1:05
add comment

1 Answer

up vote 5 down vote accepted

remove the shadow copies. that will do it!

vssadmin delete shadows /all
share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.