{"id":599,"date":"2014-05-19T12:13:22","date_gmt":"2014-05-19T11:13:22","guid":{"rendered":"http:\/\/it.tuxie.eu\/?p=599"},"modified":"2014-05-19T12:24:26","modified_gmt":"2014-05-19T11:24:26","slug":"shrinking-linux-vdi-convincing-host-fs-to-claim-real-size-not-more-in-virtualbox","status":"publish","type":"post","link":"http:\/\/it.tuxie.eu\/?p=599","title":{"rendered":"Shrinking linux .vdi (convincing host fs to claim real size, not more :-) ) in Virtualbox"},"content":{"rendered":"<p>Maybe you know it &#8211; virtual linux machine is used for anything (installing Oracle for example) &#8211; and its size says something about <strong>12<\/strong>GB \/df -h\/ &#8211; what a surprise that your host OS is allocating around <strong>25<\/strong>GB and still wants more, more, MORE!!! \ud83d\ude42<\/p>\n<p><!--more--><\/p>\n<p>There are two common ways how to zero-ing unused space: use <span style=\"font-family: courier new,courier; font-size: 10pt;\">dd<\/span> utility or specialized one &#8211; as <span style=\"font-family: courier new,courier; font-size: 10pt;\">zerofree<\/span>. Inmortal <span style=\"font-family: courier new,courier; font-size: 10pt;\">dd <\/span>is slow &#8211; <span style=\"font-size: 10pt; font-family: courier new,courier;\">zerofree <\/span>is intelligent = I have just ONE choice \ud83d\ude42 Main point = target file system should be mount as <strong>read only<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1st phase &#8211; guest<\/strong><\/p>\n<p>As I\u00b4m lazy and create default layout still the same (one 2TB partition + swap), it looks like a problem to\u00a0 mount it as read only. <a href=\"http:\/\/www.sysresccd.org\/SystemRescueCd_Homepage\">SystemRescueCd<\/a> is a free live distribution where zerofree is located. After booting this distribution from virtual machine (CD mount through menu), you will just need to set your device id:<\/p>\n<p><a href=\"http:\/\/it.tuxie.eu\/wp-content\/uploads\/2014\/05\/015.png\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-601\" src=\"http:\/\/it.tuxie.eu\/wp-content\/uploads\/2014\/05\/015-300x114.png\" alt=\"015\" width=\"300\" height=\"114\" srcset=\"http:\/\/it.tuxie.eu\/wp-content\/uploads\/2014\/05\/015-300x114.png 300w, http:\/\/it.tuxie.eu\/wp-content\/uploads\/2014\/05\/015.png 738w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>And that\u00b4s all \ud83d\ude42 Just wait for finishing. It can take demanding time according your disk usage and size of disk. In my environment with around 12GB used, 2TB disk it took around 2 hours to complete it.<\/p>\n<p><a href=\"http:\/\/it.tuxie.eu\/wp-content\/uploads\/2014\/05\/016.png\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-602\" src=\"http:\/\/it.tuxie.eu\/wp-content\/uploads\/2014\/05\/016-300x43.png\" alt=\"016\" width=\"300\" height=\"43\" srcset=\"http:\/\/it.tuxie.eu\/wp-content\/uploads\/2014\/05\/016-300x43.png 300w, http:\/\/it.tuxie.eu\/wp-content\/uploads\/2014\/05\/016.png 447w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>2nd phase &#8211; host<\/strong><\/p>\n<p>If you are using vmdk, not vdi, you have to convert this file \/compact is functional only for .vdi\/. In my case:<\/p>\n<p><span style=\"color: #ff0000;\"><strong><span style=\"font-size: 10pt; font-family: courier new,courier;\"><span lang=\"EN-AU\">VBoxManage clonehd &#8211;format VDI U:\\vmware\\Ora65_Ora1124\\Ora65-clean-disk1.vmdk U:\\vmware\\Ora65_Ora1124\\Oracle11204.vdi<\/span><\/span><\/strong><\/span><\/p>\n<p>Then you really perform compacting virtual machine on host side:<\/p>\n<p><span style=\"color: #ff0000;\"><strong><span style=\"font-family: courier new,courier; font-size: 10pt;\">VBoxManage.exe modifyhd U:\\vmware\\Ora65_Ora1124\\Oracle11204.vdi compact<\/span><\/strong><\/span><\/p>\n<p>Done.<\/p>\n<p>-a-<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Maybe you know it &#8211; virtual linux machine is used for anything (installing Oracle for example) &#8211; and its size says something about 12GB \/df -h\/ &#8211; what a surprise that your host OS is allocating around 25GB and still &hellip; <a href=\"http:\/\/it.tuxie.eu\/?p=599\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,6],"tags":[],"_links":{"self":[{"href":"http:\/\/it.tuxie.eu\/index.php?rest_route=\/wp\/v2\/posts\/599"}],"collection":[{"href":"http:\/\/it.tuxie.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/it.tuxie.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/it.tuxie.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/it.tuxie.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=599"}],"version-history":[{"count":0,"href":"http:\/\/it.tuxie.eu\/index.php?rest_route=\/wp\/v2\/posts\/599\/revisions"}],"wp:attachment":[{"href":"http:\/\/it.tuxie.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/it.tuxie.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=599"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/it.tuxie.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}