I played around some with with vmdebootstrap, my little toy to generate a disk image with a pre-installed Debian system. I added some more features, and to show them off, created a simplistic, proof-of-concept image to demostrate what FreedomBox might do.

The image includes Apache and an SSH server, and a pre-configured user. You can use SFTP to put files on the server, and HTTP to access them. An instant file-sharing appliance.

A real FreedomBox should, of course, do all sorts of other things, and this filesharing should probably be done differently, too. This is not a demonstration of the FreedomBox. It's a demonstration of vmdebootstrap.

The following command builds the image. Passwords are fixed, so you'll want to not run the image on a public network.

sudo vmdebootstrap \
--log fboxlite.log \
--log-level debug \
--image fboxlite.img \
--hostname fboxlite \
--size 1G \
--verbose \
--enable-dhcp \
--package ssh \
--package apache2 \
--mirror http://mirror.lan/debian/ \
--customize=./fboxlite-customize \

You'll need the following customization script as well:


import crypt
import os
import subprocess
import sys

def runcmd(argv, stdin='', ignore_fail=False, **kwargs):
    p = subprocess.Popen(argv, stdin=subprocess.PIPE, 
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE, 
    out, err = p.communicate(stdin)
    if p.returncode != 0:
        msg = 'command failed: %s\n%s\n%s' % (argv, out, err)
        if not ignore_fail:
            raise Exception(msg)
    return out

print 'Customizing fboxlite'

rootdir = sys.argv[1]

# Create a fboxlite account.
runcmd(['chroot', rootdir, 'adduser', '--gecos', 'Freedombox Lite',
        '--disabled-password', 'fboxlite'])
encrypted = crypt.crypt('password1', '..')
runcmd(['chroot', rootdir, 'usermod', '-p', encrypted, 'fboxlite'])

# Create /srv/shared for holding shared files.
shared = os.path.join(rootdir, 'srv', 'shared')
runcmd(['chroot', rootdir, 'chown', 'fboxlite:fboxlite', 'srv/shared'])
os.chmod(shared, 0775)

# Configure Apache to serve /srv/shared as /shared.
conf = os.path.join(rootdir, 'etc', 'apache2', 'sites-available', 'default')
text = open(conf, 'r').read()
lines = text.splitlines()
new_lines = [
    'Alias /shared "/srv/shared"',
    '<Directory "/srv/shared/">',
    'Options Indexes',
lines = lines[:-1] + new_lines + lines[-1:]
text = ''.join('%s\n' % line for line in lines)
open(conf, 'w').write(text)

If you're using libvirt with KVM, you can then use the following command to deploy the disk image:

virt-install --connect qemu:///system -n fboxlite -r 512 \
--os-type linux --os-variant debiansqueeze \
--disk $(pwd)/fboxlite.img --vnc  --import

Log in via the emulated console, and run ip addr to see what the IP address of the virtual machine is (and if you can find a way to query libvirt what the address is, please tell me). Then you can use the following URLs (in, for example, Nautilus):


Replace the correct IP address in the above URLs and off you go.