# Pearce Wiki

### Site Tools

notes:union_mounts_for_building

This is an old revision of the document!

# Union Mounts For Building

To separate source files and build products, it's possible to use all sorts of systems of top-level build directories and/or symbolic links. A simple way to implement this on top of an otherwise standard source tree is to use a union mount, however.

The concept is simply to layer an empty read-write directory on top of a read-only source tree and perform the build in this merged layer. In this document two approaches are described, one using aufs and one using the user-space unionfs-fuse.

## Dependencies

To use aufs, make sure it's installed. On Ubuntu this can be achieved with:

sudo apt-get install aufs-tools

To use unionfs-fuse, that'll need to be installed instead:

sudo apt-get install unionfs-fuse

## Setup

For the sake of this example we'll assume that the source files are in ~/projects/ipsum/src.

First, a directory to create the build artifacts must be created as well as a directory for a mount point:

mkdir ~/projects/ipsum/build-artifacts
mkdir ~/projects/ipsum/build-mnt

## Using aufs

To use aufs root privileges are required:

sudo mount -t aufs -o dirs=<build-dir>=rw:<source-dir>=ro none <mnt-dir>

… where, in this example:

• <build-dir> is /home/user/projects/ipsum/build-artifacts
• <source-dir> is /home/user/projects/ipsum/src
• <mnt-dir> is /home/user/projects/ipsum/build-mnt

To unmount the partition later, simply use standard umount:

sudo umount <mnt-dir>

## Using unionfs-fuse

To use unionfs-fuse root privileges are not required. Being a user-space filesystem, the binary for it is simply invoked and will automatically fork into the background:

<code> unionfs-fuse -o cow <build-