{"id":387,"date":"2010-07-18T13:36:48","date_gmt":"2010-07-18T18:36:48","guid":{"rendered":"http:\/\/www.insomnihack.com\/?p=387"},"modified":"2010-07-18T20:29:27","modified_gmt":"2010-07-19T01:29:27","slug":"shrink-vmware-virtual-disks-formatted-with-ext4","status":"publish","type":"post","link":"http:\/\/www.insomnihack.com\/?p=387","title":{"rendered":"Shrink VMWare Virtual Disks formatted with ext4"},"content":{"rendered":"<p>If you&#8217;re running a Linux distribution under <a href=\"http:\/\/www.vmware.com\/\">VMWare<\/a> that uses disks formatted with <a href=\"https:\/\/secure.wikimedia.org\/wikipedia\/en\/wiki\/Ext4\">ext4<\/a> (as <a href=\"http:\/\/www.ubuntu.com\">Ubuntu<\/a> does by default), you may have had some problems shrinking the resulting virtual disks files your VM uses. This is because ext4 is a journaling file system. It protects your file system in case of a system crash or power failure.<\/p>\n<p>Unfortunately, the current version of VMWare&#8217;s tools (I&#8217;m using Workstation 7.1 currently) hasn&#8217;t been updated to completely handle journaling file systems like ext4. Your disk won&#8217;t appear on the shrink tab of <em>vmware-toolbox<\/em> or be listed when using <em>vmware-toolbox-cmd<\/em>. This can be frustrating when your virtual disk grows to several gigabytes large than the actual data you&#8217;re using under Linux.<\/p>\n<p>However, the good news is that you can reclaim the unused space with a little preliminary work inside your guest OS. First, execute the following commands from within the Linux guest.<\/p>\n<p>[plain]<br \/>\nsudo apt-get clean<br \/>\nsudo dd if=\/dev\/zero of=\/0bits bs=20971520 # bs=20m<br \/>\nsudo rm \/0bits<br \/>\n[\/plain]<\/p>\n<p>This will manually clear unused space. Note that the first call to apt-get is not required, and only applicable if you&#8217;re running a distribution that uses Debian&#8217;s <a href=\"https:\/\/secure.wikimedia.org\/wikipedia\/en\/wiki\/Advanced_Packaging_Tool\">advanced packaging tool<\/a> for package management.<\/p>\n<p>After you&#8217;ve executed these commands, shutdown your VM and use <em>vmware-vdiskmanager<\/em> to shrink the virtual drive file.<\/p>\n<p>[plain]<br \/>\ncd &quot;C:\\Program Files\\VMware\\VMware Workstation&quot;<br \/>\nvmware-vdiskmanager -k path\\to\\your\\VirtualDisk.vmdk<br \/>\n[\/plain]<\/p>\n<p>You should see a noticeable reduction in file size after this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re running a Linux distribution under VMWare that uses disks formatted with ext4 (as Ubuntu does by default), you may have had some problems shrinking the resulting virtual disks files your VM uses. This is because ext4 is a journaling file system. It protects your file system in case of a system crash or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[26,34],"_links":{"self":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts\/387"}],"collection":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=387"}],"version-history":[{"count":0,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts\/387\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=387"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}