Mounting Portage Tree and Distfiles via NFS


If you have several Gentoo machines in your network, it might make sense for them to share the portage tree. That way the tree only needs to be synced once, and once downloaded distfiles are available for other machines to use without downloading them again from the mirrors.

The configuration example in this post is written for NFS 4 and does not work for previous versions.

Server settings

For the machine meant to host the NFS share, make sure that the NFS server support is enabled. The path in kernel menuconfig is File systems -> Network File Systems -> NFS server support -> NFS server support for NFS version 4 (see screenshot). Add it as a module or build it in.

To set up the shares specify them in /etc/exports. The format is

path host(options)

where path is the file path to the share under /exports, host is the host that is allowed to access it and options are the NFS options associated with the share. For example, in my LAN I have:


I have set /export/portage as 'rw' to be allow clients save downloaded distfiles on the NFS server for other clients to use. I also have set 'no_root_squash' to be able to do that as root.

To make server's local /usr/portage available in /export/portage command mount --bind /usr/portage /export/portage/.

To start sharing the NFS share, first emerge net-fs/nfs-utils and start NFS daemon: /etc/init.d/nfs start.

Client settings

For the NFS client you need to enable the corresponding option through the path File systems -> Network File Systems -> NFS client support -> NFS client support for NFS version 4 (see screenshot). Add it as a module or build it in.

In addition to kernel options, net-fs/nfs-utils should be installed and the nfsclient daemon started (/etc/init.d/nfsclient start).

Finally to mount the share, command mount -t nfs4 -o nfsvers=4 NFS_SERVER:/portage /usr/portage -v manually or put it in your fstab:

NFS_SERVER:/portage /usr/portage nfs4 nfsvers=4,nofail 0 0

NFS_SERVER should be replaced with either the IP address or the host name of the NFS server.


Basically there is none, so remember to keep your LAN private and firewall in check.


Read more from the NFS article in the Gentoo wiki.