Using lxd snapshots

Lxd with zfs is fast. Very fast.

Yesterday I was testing a package upgrade problem. Purging and re-installing the package was not good enough to reproduce it. So,

1. create a base container

lxc launch ubuntu:xenial lv1

That takes about 2 seconds on my laptop. Next, customize as needed. Due to the point we’re at in the development cycle, I needed to

2. update it to yakkety,

cat > 01proxy << EOF
Acquire::http::Proxy ";;
lxc file push 01proxy lv1/etc/apt/apt.conf.d/
lxc exec lv1 — apt update
lxc exec lv1 — apt -y upgrade
lxc exec lv1 — sed -i 's/xenial/yakkety/g' /etc/apt/sources.list
lxc exec lv1 — apt update
lxc exec lv1 — apt -y upgrade
(And install a few more packages)

lxc stop lv1 –force

3. snapshot that

lxc snapshot lv1

This created snap0 by default, and took less than 0.3 seconds.

lxc info shows the snapshot:

Name: lv1
Architecture: x86_64
Created: 2016/05/06 21:26 UTC
Status: Stopped
Type: persistent
Profiles: default
snap0 (taken at 2016/05/06 23:28 UTC) (stateless)
snap1 (taken at 2016/05/06 23:45 UTC) (stateless)

Next, every time I wanted to do a test, i created a new container based on the snapshot, and used it

lxc copy lv1/snap0 lv2

which takes less than 0.4 seconds.

In the end I just scripted:

lxc delete lv3 –force
lxc copy lv2/snap0 lv3
for f in *.deb; do lxc file push $f lv3/root/; done
lxc start lv3
lxc exec lv3 bash

So now the iterative cycle consisted of:

vi preinst postinst
tar zcf control.tar.gz control md5sums preinst
ar cr new.deb debian-binary control.tar.gz data.tar.xz

In this way, each iteration was fast enough to not get distracted and forget
what i was doing between cycles. Nice.

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s