Pbuilder and tmpfs can be friends

Jul. 12, 2011

A way to speed up Debian/Ubuntu package builds using pbuilder.

Hi everybody.

After the last article about the installation of the package building machine, I was still hacking and searching around this building system.

And I thought it would be useful to use a tmpfs (stored in RAM) to speed up builds.

First, we need a big amount of RAM, at least 4GB, because we need to store the temporary data used for the build process, and keep enough RAM space for the system to work.

The server I use is equipped with 16GB of RAM, so I don’t have to worry about that :).

To set this up, it’s pretty simple (we need to perform all actions as the root user, so under Ubuntu, add sudo at the beginning of every command).

Create the /var/cache/pbuilder/build folder if it’s not done yet :

mkdir /var/cache/pbuilder/build

Then, use your favorite text editor, and add the following line to the /etc/fstab file :

tmpfs /var/cache/pbuilder/build tmpfs defaults,auto 0 0

Mount the partition :

mount /var/cache/pbuilder/build

Then add the following line in your /root/.pbuilderrc file :

APTCACHEHARDLINK=no

This will make the building system create symlinks instead of hardlinks between the cache folder and the build folder, as they are on separated partitions.

I just ran a perf test with a complete build of the latest OWFS release for amd64 and i386 (11 supported systems, so 22 builds), and here is the results :

As you can see, better performances with tmpfs.

That’s all folks, :).