{"id":863,"date":"2017-10-18T16:52:06","date_gmt":"2017-10-18T16:52:06","guid":{"rendered":"http:\/\/mclements.net\/blogWP\/?p=863"},"modified":"2020-04-28T14:31:58","modified_gmt":"2020-04-28T14:31:58","slug":"how-to-shrink-virtualbox-vdi-volumes-in-place","status":"publish","type":"post","link":"http:\/\/mclements.net\/blogWP\/index.php\/2017\/10\/18\/how-to-shrink-virtualbox-vdi-volumes-in-place\/","title":{"rendered":"How to Shrink Virtualbox VDI Volumes In-Place"},"content":{"rendered":"<p>In my case, Ubuntu 16 is the host OS, Windows 7 is the guest OS, with Virtualbox 5.0.40.<\/p>\n<p>Before starting, <strong>ensure your Virtualbox is a VDI file<\/strong>. VMDK files can&#8217;t be resized&#8211;though they&#8217;re useful for other reasons, being compatible with other virtualization software like VMWare.<\/p>\n<p>First, run the guest OS. Delete temp files and clean up the drive. Use the windows <strong>Disk Cleanup<\/strong> feature to remove windows update and other garbage files.<\/p>\n<p>Next, defrag the drive. Defragging crams all the files together with contiguous unused space at the end of the drive instead of scattered around.<\/p>\n<p>Then run: <strong><a href=\"https:\/\/docs.microsoft.com\/en-us\/sysinternals\/downloads\/sdelete\">sdelete<\/a> c: -z<\/strong>. You must run this from a command prompt having admin privileges. This step writes zeros across the unused space, which is critical because <strong>VirtualBox can&#8217;t compact the VDI unless the free space is full of zeroes<\/strong>. The sdelete command takes a long time after reporting 100%, appears to be hung. Be patient and let it finish.<\/p>\n<p>Now <strong>shut down the guest OS<\/strong>. From the host OS command line, run: <strong>vboxmanage modifyhd file.vdi compact<\/strong>. Here, file.vdi is your VDI file.<\/p>\n<p>Your&#8217;e done. The VDI file will be smaller. It will grow automatically as you use more of the guest OS disk space.<\/p>\n<p>Note: don&#8217;t use the guest Windows 7 OS file management to shrink the volume. The free space it creates can&#8217;t be compacted by VirtualBox.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my case, Ubuntu 16 is the host OS, Windows 7 is the guest OS, with Virtualbox 5.0.40. Before starting, ensure your Virtualbox is a VDI file. VMDK files can&#8217;t be resized&#8211;though they&#8217;re useful for other reasons, being compatible with other virtualization software like VMWare. First, run the guest OS. Delete temp files and clean &hellip; <a href=\"http:\/\/mclements.net\/blogWP\/index.php\/2017\/10\/18\/how-to-shrink-virtualbox-vdi-volumes-in-place\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to Shrink Virtualbox VDI Volumes In-Place<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-863","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/posts\/863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/comments?post=863"}],"version-history":[{"count":5,"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/posts\/863\/revisions"}],"predecessor-version":[{"id":2081,"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/posts\/863\/revisions\/2081"}],"wp:attachment":[{"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/media?parent=863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/categories?post=863"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mclements.net\/blogWP\/index.php\/wp-json\/wp\/v2\/tags?post=863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}