{"id":483,"date":"2010-12-07T03:55:54","date_gmt":"2010-12-07T03:55:54","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/heaths\/2010\/12\/07\/delete-shadow-copies-to-compact-vhds-and-avhds\/"},"modified":"2019-02-17T15:29:41","modified_gmt":"2019-02-17T22:29:41","slug":"delete-shadow-copies-to-compact-vhds-and-avhds","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/setup\/delete-shadow-copies-to-compact-vhds-and-avhds\/","title":{"rendered":"Delete shadow copies to compact VHDs and AVHDs"},"content":{"rendered":"<p>For a few years my primary development machine has actually been a VM with source located on a physical hard drive attached to the VM. This helps reduce latency compared to a differencing disk (AVHD) which may need to expand to accommodate additional data (common when building). It&rsquo;s also easier to maintain than multiple boot entries when <a href=\"http:\/\/blogs.msdn.com\/b\/heaths\/archive\/2009\/10\/13\/booting-windows-to-a-differencing-virtual-hard-disk.aspx\">booting to different AVHDs<\/a>.<\/p>\n<p>But a couple of weeks ago I accidentally created a new source enlistment on my guest system drive &ndash; a series of differencing disks on top of a dynamic root disk (VHD). Not only did this expand to the limit of the virtual drive capacity, but left the partition for the host with little extra free space. I needed to compact the AVHD since I already removed the source enlistment.<\/p>\n<p>At least with Hyper-V on Windows Server 2008 R2 you can compact VHDs and AVHDs alike; however, I kept seeing the following error,<\/p>\n<blockquote>\n<p>The system failed to compact &lsquo;C:UsersPublicPublic DocumentsHyper-VVirtual hard disks<em>disk<\/em>.avhd&rsquo;. Error code: The requested operation could not be completed due to a file system limitation&#8221;<\/p>\n<\/blockquote>\n<p>I thought perhaps there wasn&rsquo;t enough drive space remaining on the host partition, assuming VDS may create a new temporary file. I copied it to a partition with a lot more capacity to no avail. Then I found <a href=\"http:\/\/www.expta.com\/2010\/06\/unable-to-compact-vhd-due-to-file.html\">blog post<\/a> by Jeff Guillet, a Microsoft MVP. Besides a couple of other possible reasons, Jeff had this to say,<\/p>\n<blockquote>\n<p>You cannot compact a VHD where the VHD contains a VSS backup.<\/p>\n<\/blockquote>\n<p>Since you can compact AVHDs as well, I assumed the same may be true for AVHDs. And since my host partition was not heavily fragmented, I gave the suggested solution a try. I booted the guest OS, opened an elevated command prompt, and ran the following,<\/p>\n<blockquote>\n<p>vssadmin delete shadows \/all<\/p>\n<\/blockquote>\n<p>When that completed, I shut down the VM and attempted to compact the AVHD again: success! Everything is back up and working and my host partition has space to spare, so I thought I&rsquo;d share this tip from Jeff in case you run into the same problem.<\/p>\n<p>And to avoid this situation in the future,&nbsp; also recommend you disable System Restore which will also disable and delete shadow copies. If you&rsquo;re using differencing disks periodically already, you may not need them anyway and it will save space on the guest partition(s).<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For a few years my primary development machine has actually been a VM with source located on a physical hard drive attached to the VM. This helps reduce latency compared to a differencing disk (AVHD) which may need to expand to accommodate additional data (common when building). It&rsquo;s also easier to maintain than multiple boot [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":3843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[39,43],"class_list":["post-483","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-tip","tag-virtualization"],"acf":[],"blog_post_summary":"<p>For a few years my primary development machine has actually been a VM with source located on a physical hard drive attached to the VM. This helps reduce latency compared to a differencing disk (AVHD) which may need to expand to accommodate additional data (common when building). It&rsquo;s also easier to maintain than multiple boot [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/comments?post=483"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/483\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media\/3843"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media?parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/categories?post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/tags?post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}