unprivileged btrfs clones

In 14.04 you can create unprivileged container clones usign overlayfs. Depending on your use case, these can be ideal, since the delta between your cloned and original containers is directly accessible as ~/.local/share/lxc/clonename/delta0/, ready to rsync.

However, that is not my use case. I like to keep a set of original containers updated for quick clone and use by my package build scripts or for manual use for bug reproduction etc. Overlayfs gets in the way here since updating the original container requires making sure no clones exist, else you can cause glitches or corruption in the clone.

Fortunately, if you are using ppa:ubuntu-lxc/daily, or building from git HEAD, then as of last week you can use btrfs clones with your unprivileged containers. This is perfect for me as I can update the originals while a long-running build is on-going in a clone, or if I just want to keep a clone around until i get time to extract the patch or bugfix or log contents sitting there.

So I create base containers using

lxc-create --template download -B btrfs --name c-trusty -- -d ubuntu -r trusty -a amd64

then have create_container and start_container scripts which basically do

lxc-clone --snapshot --orig c-trusty --new c-trusty-5

Perfect.

About these ads
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s