{"id":237,"date":"2015-10-22T21:36:00","date_gmt":"2015-10-22T21:36:00","guid":{"rendered":"https:\/\/technese.com\/?p=237"},"modified":"2019-12-26T21:53:18","modified_gmt":"2019-12-26T21:53:18","slug":"shrink-qemu-qcow2-files","status":"publish","type":"post","link":"https:\/\/technese.com\/index.php\/2015\/10\/22\/shrink-qemu-qcow2-files\/","title":{"rendered":"Shrink qemu qcow2 files"},"content":{"rendered":"\n<p>Excerpt from source:<\/p>\n\n\n\n<p><strong>Windows Guest<br>\n<\/strong><br>\n1.Delete all unnecessary files, empty recycle bin<br>\n2.Defragment drive (you might need to do this several times, until you see it \u201ccompacted\u201d well)<br>\n3.Use sdelete to zero free disk space. Please note that this operation \nwill cause that all drive free space will be filled by zero, so the \nvirtual machine image will grow to the maximum size.<\/p>\n\n\n\n<p>Using command prompt<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sdelete -c c:\n<\/code><\/pre>\n\n\n\n<p><strong>Linux\/FreeBSD Guest<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># dd if=\/dev\/zero of=.\/zero bs=1M\n# sync\n# rm -f .\/zero\n<\/code><\/pre>\n\n\n\n<p>Note, the bs parameter is important, since it greatly reduce time necessary to complete this task.<\/p>\n\n\n\n<p><strong>Host<\/strong><br>\nConvert image to the same format that is currently is (e.g. qcow2 =&gt; \nqcow2)\u2026 during this procedure it will release unused space.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># qemu-img convert -O qcow2 w2k3.qcow2 w2k3-shrinked.qcow2\n<\/code><\/pre>\n\n\n\n<p>Source:<br>\n<a href=\"http:\/\/mindref.blogspot.com\/2011\/07\/shrink-qcow2.html\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/mindref.blogspot.com\/2011\/07\/shrink-qcow2.html<br>\n<\/a><\/p>\n\n\n\n<p>Download sdelete from here:<\/p>\n\n\n\n<p><a href=\"https:\/\/technet.microsoft.com\/en-us\/sysinternals\/bb897443.aspx\">https:\/\/technet.microsoft.com\/en-us\/sysinternals\/bb897443.aspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Excerpt from source: Windows Guest 1.Delete all unnecessary files, empty recycle bin 2.Defragment drive (you might need to do this several times, until you see it \u201ccompacted\u201d well) 3.Use sdelete to zero free disk space. Please note that this operation will cause that all drive free space will be filled by zero, so the virtual [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/comments?post=237"}],"version-history":[{"count":2,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/posts\/237\/revisions"}],"predecessor-version":[{"id":248,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/posts\/237\/revisions\/248"}],"wp:attachment":[{"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/media?parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/categories?post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/technese.com\/index.php\/wp-json\/wp\/v2\/tags?post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}