Squashed Portage Tree

This article describes how to reduce the Portage tree, using a squashfs image, to 30-40MB. A good alternative to having the portage tree on a separate partition. For a list of publicly available copies please see the bottom of this article.

Required Packages
You will need which provides ,

And of course the aufs module:

Kernel Configuration
Kernels based on include SquashFS by default.

It is of course possible to have these built-in, but we avoid a reboot when building these as modules.

Preparation
For a single squashed tree, you will need to move anything not part of the portage tree out of PORTDIR. This usally includes DISTDIR and laymans storage. Modify ,

Remove ,

Layman's configuration file is. Here we move layman's storage directory to, same directory as DISTDIR,

Move the layman storage directory to our new location,

init.d/squash_portage
Paste this into ,

Make it executable,

conf.d/squash_portage
Paste this in the corresponding configuration file ,

Usage
To make sure you always have a mounted portage tree:

Now it is time to initialize the tree. Simply start the service.

Preparation
For multiple squashed trees, you probably want to move DISTDIR (usually ) out of PORTDIR (usually ), or else it'll take a very long time to create a portage sqfs image, without any significant size reduction.

What we'll describe here is an example configuration, for three trees, each of located in /var/portage/{portage,layman,local}, with it's original locations being, and. One could achieve the same with only two trees by merging local with layman. But this would side effect you dependent of layman for your local tree, and our script configuration, to work without modifications.

First we make sure that and sub-dirs does exist.

Remember that we want every tree in /var/portage, and, we also need layman to write it's overlays to, instead of. So, modify ,

and ,

Move ,

Or remove ,

Move ,

Modify overlays to ,

Before we create the images we need to split layman from local, doing:

Now we have to create the sqfs images, since our script expect the images to be at /var/portage/, named as sqfs.${TREE}-current.sqfs, we proceed as following:

Since some system files need files at, we have to symlink after we remove them.

It's safer to move:

After we symlink:

Init script
You can now create and configure, first of all create it:

Make it executable,

Now to configure, create and edit the corresponding configuration file ,

Check your initial setup running the script once.

Now complete your setup restarting it, so it will create necessary symlinks while stopping.

To make sure you always have a mounted portage tree:

If everything went alright, you can now delete the all old trees content but and  links from  if you want.

Usage
You can sync the trees with:

You can also start, stop, and restart it:

Public Downloads
Snapshots of portage tree are created by and uploaded to these Gentoo binhosts:

http://binhost.ossdl.de/ - updated every four days, format: SquashFS 4.0, XZ compression. Courtesy of Hurrikane Systems, Germany.

Kompresowanie drzewa Portage SquashFS ile Portage