<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Qcow2 on nagg.eu</title><link>https://nagg.eu/tags/qcow2/</link><description>Recent content in Qcow2 on nagg.eu</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 09 Nov 2016 18:19:35 +0000</lastBuildDate><atom:link href="https://nagg.eu/tags/qcow2/index.xml" rel="self" type="application/rss+xml"/><item><title>Copy Linux sparse files over network</title><link>https://nagg.eu/copy-linux-sparse-files-over-network/</link><pubDate>Wed, 09 Nov 2016 18:19:35 +0000</pubDate><guid>https://nagg.eu/copy-linux-sparse-files-over-network/</guid><description>&lt;p&gt;Sparse files are nice to use to store virtual machine&amp;rsquo;s virtual disks but can be a real pain in the ass to backup efficiently, especially over the network.&lt;br&gt;
Luckily &lt;code&gt;rsync&lt;/code&gt; provides a way to intelligently copy sparse files both locally and over the network.&lt;br&gt;
The trick is use &lt;code&gt;--sparse&lt;/code&gt; and &lt;code&gt;--inplace&lt;/code&gt; options.&lt;br&gt;
Let&amp;rsquo;s say we have a sparse 60 GB qemu virtual disk with only around 7 GB used:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ ls -lh fedora24.qcow2 
-rw------- 1 root root 61G Nov 8 19:11 fedora24.qcow2
$ du -h fedora24.qcow2 
7.2G	fedora24.qcow2
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The first thing to note is that ls does not recognize sparse files while du does.&lt;br&gt;
The first time a file is copied use the &lt;code&gt;--sparse&lt;/code&gt; option:&lt;/p&gt;</description></item><item><title>QEMU+KVM, reclaim disk space</title><link>https://nagg.eu/qemukvm-reclaim-disk-space/</link><pubDate>Tue, 17 Nov 2015 11:06:29 +0000</pubDate><guid>https://nagg.eu/qemukvm-reclaim-disk-space/</guid><description>&lt;p&gt;After some time qcow2 images tend -especially after taking snapshots- to grow bigger and bigger, even bigger than the maximum size specified at creation time.&lt;br&gt;
QEMU provides a tool called virt-sparsify (install &lt;code&gt;libguestfs-tools&lt;/code&gt; package in CentOS 7) that can effectively make a virtual machine disk thin provisioned (space is not preallocated, only the actual space needed is used).&lt;br&gt;
virt-sparsify has a nice number of options, the most interesting one is &lt;code&gt;--in-place&lt;/code&gt;, it tells QEMU to shrink the volume in place without requiring any addition space.&lt;/p&gt;</description></item></channel></rss>