Vssadmin is dead, long live Diskshadow

Today while trying to compact a dynamically expanding virtual hard disk in Hyper-V, I ran into a cryptic error message that made bugger all sense:

Error Code: The requested operation could not be completed due to a file system limitation

I tried the same compact operation using diskpart instead, but got the same message, this time with the additional information that I could “See the System Event Log for more information.”

Imagine my surprise when I checked the System event log to find there was nothing about this.

Anyway, the actual answer came from a helpful blog post entitled “Unable to Compact a VHD Due to a File System Limitation Explained“, which blamed the problem on a left-over VSS backup. So, off I went to clear the shadow copies, when I hit this:

Error: Snapshots were found, but they were outside of your allowed context. Try removing them with the backup application which created them.

All very well, but the only backup program I was using was Windows Server Backup, and I soon found that clearing the backups using wbadmin wasn’t helping. When I examined the offending shadow copies using vssadmin /list, I got something looking like this:

Contents of shadow copy set ID: {5ed567cb-5ec4-4f3e-85d5-eeb477a1307e}
Contained 1 shadow copies at creation time: 11/28/2007 6:00:20 AM
Shadow Copy ID: {707257c9-ef03-48c9-8e5f-4b5aacae0adc}
Original Volume: (D:)\\?\Volume{40dd3a88-7914-40d2-8a6c-40cddcc7b256}\
Shadow Copy Volume: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy5
Originating Machine:
Service Machine:
Provider: 'Microsoft Software Shadow Copy provider 1.0'
Type: ApplicationRollback
Attributes: Persistent, No auto release, Differential

It turns out that vssadmin cannot remove these at all, which is frankly just irritating given that it’s supposedly an admin tool. I found a few suggestions online about using the vshadow tool from the Windows SDK, but that suggestion is about as much use as a chocolate teapot because vshadow is deprecated on Windows Server 2008.

After a short bout of rage, I found a very convenient answer. In Windows Server 2008 onwards, vshadow has been replaced by Diskshadow, which is helpfully included in-box, so you don’t have to go fishing through Microsoft’s downloads section. Diskshadow essentially provides similar functionality to vssadmin, without any of the daft restrictions such as what kinds of shadow copies is can remove. It took less than 10 seconds to remove the problem shadow copies, and my VHD would then happily compact.

Tags: , , ,

About The Angry Technician

The Angry Technician is an experienced IT professional in the UK education sector. Normally found in various states of annoyance on his blog. All views are those of his imaginary pet dog, Howard.

12 responses to “Vssadmin is dead, long live Diskshadow”

  1. dan says :

    That is the answer I have been looking for for days! I ran into the same wall and was about to give up. Thanks for posting this!

  2. Graham says :

    Thanks for this solution, was having the same error trying to compact my SBS 2011 with backups on another atatched vhd
    Worked a treat!
    Thank-you

  3. Joel Culbreth says :

    Awesome! Thank You. I too was hitting the brick wall until I found your post.

  4. Craig Putnam says :

    That is exactly what I needed. And I completely agree: with a name like “vssadmin”, one would expect to be able to, um, administer VSS stuff. :(

  5. NYCIT says :

    This worked for us, Though we were looking for a full backup command line tool that can automate. We ended up using gscopypro http://www.gurusquad.com/GSCOPYPRO it worked for us. It is similar to diskshadow but easier to use.

  6. Bryan Williams says :

    Thanks to your rant I saved myself many hours of frustration. Great post!

  7. christian says :

    Thankyou so much

  8. Frank B. says :

    Thanks for posting this. Why the F.. MS is always replacing tools instead of just upgrade the old ones is beyond me.