Just a quick write up here on how to make a portable image you can mount in LXC which you can move around.

Download minimal ubuntu

Let’s start by downloading a minimal ubuntu raring for this we need sudo:

sudo -i

This will install ubuntu raring into the directory raring

sudo debootstrap --variant minbase raring raring;

We can now chroot into this directory in order to minimize a little and clean the apt-get packages that got installed during the debootstrap process.

chroot raring

You can now install your own software, packages and such. When you are done and ready to package your stuff up you can do:


To clean and exit your chrooted session.

Create a file volume

Next up is creating the file volume which we will mount. And copy the filesystem too so we can move it around as a single file.

Let’s check the size of our raring directory first.

du -hs raring

Remember that amount and lets create an empty file zero padded. The if means file in, the of means file out. The bs the size of block. The count means the number of blocks. Replace the count in the sample below with your own count of megabytes, and allocate a bit extra since mkfs will steal space some in regards to administraton of blocks.

#Size of the Raring directory + some extra
dd of=ubuntu-raring.img if=/dev/zero bs=1M count=200 

It will take a while to populate. When done time to mkfs the image.

mkfs ubuntu-raring.img

After this we can mount the image.

mkdir /dev/ubuntu-raring
mount ubuntu-raring.img /dev/ubuntu-raring

And now we can finally copy our raring directory to our /dev/ubuntu-raring

cd raring
rsync -a . /dev/ubuntu-raring

You can now mount this image in LXC with or without AUFS.

If you want to move it around you can use gzip or tar to compress your image.