# FreedomBox for Communities/Building Disk Images

This guide explains how to make ready-to-deploy images of FreedomBox for community deployments. Applications are installed on top of the base FreedomBox image and a disk image of a fully installed FreedomBox is created.
Since single board computers don't usually satisfy the system requirements for community deployments of FreedomBox, usually desktop machines of i386 or amd64 architecture are chosen. This guide will assume that the amd64 architecture is chosen, though the same instructions apply to i386 as well.

## Getting the base image

The FreedomBox operating system is usually distributed in the form of disk images which can be downloaded from the official website.
Download and verify the GPG signature of an image suitable for desktop installations.
In case the website is down, you can build the disk image yourself using a tool called freedom-maker. Please follow the instructions in the ReadMe file of freedom-maker to build an amd64 image.

## Preparing the disk image
### Using a spare computer

Burn the image to a USB disk using the command-line tool dd or a GUI tool called balenaetcher. Insert the USB disk into a spare computer of amd64 architecture and select it form the BIOS settings while booting up.
Create a new administrator user in FreedomBox and install the required applications.

### Using VirtualBox CLI

Install virtualbox on your computer. On Debian, the following command works:
   $ sudo apt install virtualbox
We will use a command-line utility provided by VirtualBox called VBoxManage for further operations from here.
Convert the amd64 image into a format that VirtualBox understands
   $ VBoxManage convertdd <freedombox-image-name>.img <freedombox-image-name>.vdi --format VDI
Import this disk image into VirtualBox using the GUI application.
Forward port 443 from the guest to your host machine to be able to access the FreedomBox web interface from a browser.
Forward port 22 for ssh access from your host machine.
The base image is only 3.7 GiB in size. You may have to expand the disk image to a larger size, say 8 GiB to be able to install applications.
   $ VBoxManage modifyhd <freedombox-image-name>.vdi --resize 8192
Note: Be careful about the argument to --resize. Further expansion is possible but shrinking disk images is not yet possible with VBoxManage.
FreedomBox doesn't yet know that there's extra disk space available. In the web interface, go to System -> Storage and click the "Expand Root Partition" button to expand the root partition to fill the entire disk.
Allocate at least 2 CPU cores and 2 GiB memory for the virtual machine.
Create a new administrator user in FreedomBox and install the required applications.
Once the setup is done, convert the VirtualBox image back to a raw disk image.
   $ VBoxManage clonehd <freedombox-image-name>.vdi <freedombox-image-name>.img --format RAW

## Using the disk image

Use the dd command to replicate the disk image prepared above into each hard disk of the computers that will be used to serve FreedomBox in communities. After starting the new FreedomBox server, it is essential to re-generate two keys for security reasons:
* Regenerated SSH keys. systemctl stop sshd rm -f /etc/ssh/ssh_host_* dpkg-configure openssh-server systemctl start sshd
* Regenerate Apache's snakeoil certificate used for TLS connections when proper Let's Encrypt certificate is not available. make-ssl-cert generate-default-snakeoil --force-overwrite systemctl restart apache2