Sharing Portage over NFS

Introduction
This article will detail how to share a single portage repository (usually stored under ) across multiple machines using NFS.

This can be easier to set up than a local rsync server and only requires that one machine sync the package repository. Unlike an automatically updated rsync server, all machines will also be accessing exactly the same repository. It will also allow you to optionally share distfiles, resulting in fewer downloads.

Assumed Knowledge
This article assumes that you already have a working NFS server and know how to mount its shares under Linux.

Server
Add the entry for the portage directory to :

Obviously you'll want to replace 192.168.0.0/16 with the allowed client addresses for your network. See the exports(5) man page for details.

Don't forget to reload the exports table with:

Clients with portage >=2.1.5_rc6
If your client has a stable portage and you didn't enable in make.conf, you may simply mount your shared portage:

Add an entry into for the share:

Try to mount it automatically

and add it to your default level

If you want to save some space, remove your local portage copy

Clients
To prevent accidentally overwriting any data you may want to keep, and as a reminder of the fact that the repository is an NFS mount, this article will use to mount the repository.

192.168.0.1 will be used as the NFS server address. Whereever this appears, replace it with the real server address.

Create the directory where the repository will be mounted with:

Next, ensure you can successfully mount the share:

Add an entry into for the share:

Remount the repository to make sure the fstab line works with:

Note Your Profile
Take note of what profile you're currently using and write it down. There are 2 ways to do this:

Using Eselect
The easiest method is using. Check that you have it installed, if not, install it with:

Now check which profile you currently have selected:

Note the name (not the number, as these may change) of the profile that has an asterisk (*) to the right.

Manually
Check where the symlink points to with:

Configuring Portage
We now need to tell Portage where to find the NFS shared repository. Add the following to the end of :

Resetting Your Profile
You'll now need to set your profile to use the new location.

Using Eselect
To see a list of available profiles, run:

Set the profile to the same one you had set earlier using. For example, if you were using the default/linux/amd64/2008.0 profile and this is listed as [2]:

Manually
Remove your existing profile link with:

Recreate the symlink using the value you obtained earlier, but replacing  with, so for example:

Syncing Cache
Portage keeps a cache of package information relevent to the system which speeds up queries. This is normally updated during emerge --sync. Since your server is the only machine that runs emerge --sync, you will need to update the cache on the clients using:

It is safe to ignore (or forget) this step, but Portage may be noticably slower.

Mounting on Boot
To have your NFS shared repository mount on boot, run:

Configuring eix
If you use eix for package searches, you'll need to change the method which eix uses to find out about packages. Edit and add the following line to the end of the file:

What Next?
In addition to the setup detailed in this article, you may want to investigate setting up a cron job on the server to automatically sync the shared repository.

Not Using the NFS Share
If you want to sync on a client while not connected to the network, you can safely sync as normal:

The repository will be downloaded to. Next time you connect to the network and mount the NFS share, it will be mounted on top of the local copy of the repository.

Note that the first time you sync after following this guide, it may take some time because you the repository will be empty. This can be solved by copying your original local repository over the top with the following: