<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, May 16, 2016 at 3:38 PM, Brian Candler <span dir="ltr"><<a href="mailto:b.candler@pobox.com" target="_blank">b.candler@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<p>root@vtp:~# lxc launch ubuntu:16.04 base1<br></p><tt>Creating base1</tt><tt><br>
</tt><tt>Retrieving image: 100%</tt><tt><br>
</tt><tt>Starting base1</tt><tt><br>
</tt><tt>root@vtp:~# zpool list</tt><tt><br>
</tt><tt>NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP
HEALTH ALTROOT</tt><tt><br>
</tt><tt>lxd 77G 644M 76.4G - 0% 0% 1.00x
ONLINE -</tt><tt><br>
</tt><tt>root@vtp:~# lxc launch ubuntu:16.04 base2</tt><tt><br>
</tt><tt>Creating base2</tt><tt><br>
</tt><tt>Starting base2</tt><tt><br>
</tt><tt>root@vtp:~# lxc launch ubuntu:16.04 base3</tt><tt><br>
</tt><tt>Creating base3</tt><tt><br>
</tt><tt>Starting base3</tt><tt><br>
</tt><tt>root@vtp:~# lxc exec base1 /bin/sh -- -c 'echo hello
>/usr/test.txt'</tt><tt><br>
</tt><tt>root@vtp:~# lxc stop base1</tt><tt><br>
</tt><tt>root@vtp:~# zpool list</tt><tt><br>
</tt><tt>NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP
HEALTH ALTROOT</tt><tt><br>
</tt><tt>lxd 77G 655M 76.4G - 0% 0% 1.00x
ONLINE -</tt><tt><br>
</tt><br>
So disk space usage is about 645MB for the image, and small change
for the instances launched from it. Now I want to clone further
containers from base1, so I publish it:<br>
<br></div></blockquote><div><br></div><div><br></div><div>Did you know you can set compression on zfs side? </div><div><br></div><div>zfs set compression=lz4 lxd</div><div><br></div><div>... would save lots of space with a negligable cost to CPU.</div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><br>
Now, what I was hoping for was that the named image (clonemaster)
would be a snapshot derived directly from the parent, so that it
would also share disk space. What I'm actually trying to achieve is
a workflow like this:<br>
<br>
- launch (say) 10 initial master containers<br>
- customise those 10 containers in different ways (e.g. install
different software packages in each one)<br>
- launch multiple instances from each of those master containers<br>
<br>
This is for a training lab. The whole lot will then be packaged up
and distributed as a single VM. It would be hugely helpful if the
initial zfs usage came to around 650MB not 6.5GB.<br></div></blockquote><div><br></div><div><br></div><div>Are you using the published images on the same lxd instance? If so, you can use "lxc copy" on a powered-off container. It should correctly use zfs clone. You can also copy-a-copy.</div><div><br></div><div>Add to that "compression=lz4", and you'll probablly end up with around 400MB usage. If you want even more savings, use "compression=gzip". Note that compression only affects new data, so the easiest way would be to restart from scratch, apply zfs compression, and configure lxd.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">The other option I can think of is zfs dedupe. The finished target
system won't have the resources to do dedupe continuously. However I
could turn on dedupe during the cloning, do the cloning, and then
turn it back off again (*)<br>
<br></div></blockquote><div><br></div><div>DO NOT USE DEDUPE. EVER.</div><div>* there are few exceptions, but if you still need to ask, then dedupe is not for you.<br></div><div><br></div><div>-- </div><div>Fajar</div></div></div></div>