{"id":842,"date":"2014-12-13T00:24:12","date_gmt":"2014-12-12T22:24:12","guid":{"rendered":"http:\/\/www.netexpertise.eu\/en\/?p=842"},"modified":"2021-10-13T21:51:36","modified_gmt":"2021-10-13T19:51:36","slug":"hyper-v-vhd-virtual-disk-does-not-reduce","status":"publish","type":"post","link":"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html","title":{"rendered":"Why Compacting Hyper-v vhd Does Not Reduce Disk Size"},"content":{"rendered":"\n<p>You have freed up a lot of space on your <a href=\"\/en\/tag\/hyper-v-2\">hyper-v<\/a> virtual machine and tried to compact the vhd file but no luck, it doesn&#8217;t shrink as much as it should.<br>&nbsp;<br>Here are a few things I tried to optimize disk space:<br>&#8211; Defragmentation<br>&#8211; Shrink volume from the VM disk manager<br>&#8211; Defrag adding the vhd on another VM as a secondary drive so system files can be defragmented<br>&#8211; Generate a new vhd from the original copy<br>Nothing seems to be working!<br><br>The problem is that NTFS deletes files from the directory structure, but does not cleanse space freed up by removed files. And that space isn&#8217;t released while compacting. This is why there are a lot of tools able to recover deleted files, as long as other files have not taken released space.<br>&nbsp;<br>In order to get all the free space back, you can use sdelete from the excellent Microsoft sysinternals tools. sdelete lets you securely erase any file data that exists in the unallocated portions of a disk, meaning filling space with zeros. That includes files you have already deleted or encrypted.<br>Download <a href=\"http:\/\/technet.microsoft.com\/en-ie\/sysinternals\/bb897443.aspx\">sdelete<\/a> and run this short command on the virtual machine if you want to clean the C: drive:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">sdelete -z C:<\/code><\/pre>\n\n\n\n<p><br>sdelete does not say much, you don&#8217;t even know how much space you just saved. it all depends on how much cleanup you have done beforehand.<br><br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/images\/sdelete_reduce_vhd.png\" alt=\"reduce vhd with sdelete\"\/><\/figure>\n\n\n\n<p><br>You can now successfully compact the vhd file which size will match space really used.<\/p>\n\n\n\n<p><br>&nbsp;<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You have freed up a lot of space on your hyper-v virtual machine and tried to compact the vhd file but no luck, it doesn&#8217;t shrink as much as it should.&nbsp;Here are a few things I tried to optimize disk space:&#8211; Defragmentation&#8211; Shrink volume from the VM disk manager&#8211; Defrag adding the vhd on another [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[346],"tags":[348,290,391],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Netexpertise - Why Compacting Hyper-v vhd Does Not Reduce Disk Size<\/title>\n<meta name=\"description\" content=\"Compacting Hyper-v vhd does not reduce drastically disk size or how to optimize drastically the free space after file deletion\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Netexpertise - Why Compacting Hyper-v vhd Does Not Reduce Disk Size\" \/>\n<meta property=\"og:description\" content=\"Compacting Hyper-v vhd does not reduce drastically disk size or how to optimize drastically the free space after file deletion\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html\" \/>\n<meta property=\"og:site_name\" content=\"Netexpertise\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-12T22:24:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-10-13T19:51:36+00:00\" \/>\n<meta name=\"author\" content=\"dave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@netexpertise\" \/>\n<meta name=\"twitter:site\" content=\"@netexpertise\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html\",\"name\":\"Netexpertise - Why Compacting Hyper-v vhd Does Not Reduce Disk Size\",\"isPartOf\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\"},\"datePublished\":\"2014-12-12T22:24:12+00:00\",\"dateModified\":\"2021-10-13T19:51:36+00:00\",\"author\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\"},\"description\":\"Compacting Hyper-v vhd does not reduce drastically disk size or how to optimize drastically the free space after file deletion\",\"breadcrumb\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.netexpertise.eu\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Why Compacting Hyper-v vhd Does Not Reduce Disk Size\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/\",\"name\":\"Netexpertise\",\"description\":\"Systems \/ Networks \/ DevOps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\",\"name\":\"dave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"caption\":\"dave\"},\"sameAs\":[\"http:\/\/www.netexpertise.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Netexpertise - Why Compacting Hyper-v vhd Does Not Reduce Disk Size","description":"Compacting Hyper-v vhd does not reduce drastically disk size or how to optimize drastically the free space after file deletion","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html","og_locale":"en_US","og_type":"article","og_title":"Netexpertise - Why Compacting Hyper-v vhd Does Not Reduce Disk Size","og_description":"Compacting Hyper-v vhd does not reduce drastically disk size or how to optimize drastically the free space after file deletion","og_url":"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html","og_site_name":"Netexpertise","article_published_time":"2014-12-12T22:24:12+00:00","article_modified_time":"2021-10-13T19:51:36+00:00","author":"dave","twitter_card":"summary_large_image","twitter_creator":"@netexpertise","twitter_site":"@netexpertise","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html","url":"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html","name":"Netexpertise - Why Compacting Hyper-v vhd Does Not Reduce Disk Size","isPartOf":{"@id":"http:\/\/www.netexpertise.eu\/en\/#website"},"datePublished":"2014-12-12T22:24:12+00:00","dateModified":"2021-10-13T19:51:36+00:00","author":{"@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa"},"description":"Compacting Hyper-v vhd does not reduce drastically disk size or how to optimize drastically the free space after file deletion","breadcrumb":{"@id":"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.netexpertise.eu\/en\/systems\/virtualization\/hyper-v-vhd-virtual-disk-does-not-reduce.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.netexpertise.eu\/en"},{"@type":"ListItem","position":2,"name":"Why Compacting Hyper-v vhd Does Not Reduce Disk Size"}]},{"@type":"WebSite","@id":"http:\/\/www.netexpertise.eu\/en\/#website","url":"http:\/\/www.netexpertise.eu\/en\/","name":"Netexpertise","description":"Systems \/ Networks \/ DevOps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa","name":"dave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","caption":"dave"},"sameAs":["http:\/\/www.netexpertise.eu"]}]}},"_links":{"self":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/842"}],"collection":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/comments?post=842"}],"version-history":[{"count":0,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/842\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/media?parent=842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/categories?post=842"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/tags?post=842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}