Gentoo Wiki




This article is based on the following scenario: You have 2 boxes, a fast box A (e.g., Athlon XP 2200+) and a slow box B (e.g., Pentium 120). You want to emerge huge packages to run on box B, but save time by compiling them on box A. Both boxes are running gentoo, as described in the handbook.

Compiling on the fast box by using NFS

First set up NFS.

Setting up box B (NFS server)

We have to grant box A access to box B's root. That is done by adding the following line to /etc/exports:

Code: /etc/exports
/ <IP of box A>(rw,no_root_squash,sync,no_subtree_check)

emerge for box B on box A

The chroot command lets us use the processing power of box A in the environment and file system of box B. To make that environment available, we first mount box B's root on box A. All commands are to be entered on box A, working as root.

In order to work with NFS shares without your machine hanging when you issue mount, make sure that NFS utils is running:

# /etc/init.d/nfsmount start
# mkdir /mnt/slowmachine
# mount <IP of box B>:/ /mnt/slowmachine -o rsize=1024,wsize=1024,rw

(The -o rsize=1024,wsize=1024 prevents IP fragmentation, rw permits read-write operation on the NFS mount.)

Certain information from box A will be needed inside the chroot environment. The following mount commands set this up:

# mount -t proc none /mnt/slowmachine/proc -o nodev,nosuid,noexec
# mount -o bind /dev /mnt/slowmachine/dev
# mount -t devpts none /mnt/slowmachine/dev/pts -o nosuid,noexec,gid=5,mode=620

I have also found it useful to bind some local directory on machine A to the directory /var/tmp/portage on machine B:

# mount -o bind /tmp/on/machineA/ /mnt/slowmachine/var/tmp/portage

This saved 6 minutes in emerging mplayer (1.0_pre8) on a 100mbit network of just 2-computers. (Used 10 minutes instead of 16, where the faster machine A is a pentium4 3.4GHz dual core) - maybe there were some caching issues, but I tried it twice :).

To minimize network perfomance impact it is also advisable to mount PORTAGE_TMPFS on box A to corresponding dir on box B:

# mount -t tmpfs none /mnt/slowmachine/dev/shm -o nodev,nosuid,noexec

Moreover it is a good idea to mount a portage tree itself. (You should keep portage tree on box B uptodate too for stadalone update if required. Just copy portage tree from box A to box B after emerge.)

# mount -o bind /usr/portage /mnt/slowmachine/usr/portage

The chroot command does not change the kernel running on box A, so compiling kernel modules for box B is not likely to work in this setup. (You could add them to /etc/portage/package.mask temporarily, and after NFS compilation run module-rebuild.)

Change system architecture on box A to box B architecture, otherwise programs which compilation depends on 'uname -m' will fail to compile (qt4, openoffice etc.). Finally, use chroot to enter the environment of box B. On box A, say

# setarch machineB_arch chroot /mnt/slowmachine /bin/bash

Now you can emerge packages to your heart's content. Give the commands and watch the processes run on box A; all the files getting installed and changed are on box B.


Remember that box A is doing the downloading of sources, so be sure to setup internet access.

If you get a strange error like this when running emerge:

close failed: [Errno 9] Bad file descriptor

be sure that you mounted NFS with the 'rw' option, if you did not, you can achieve this by running:

 # mount -o remount,rw /mnt/slowmachine

Can anybody add, what to do if Machine A is not Gentoo,
but some other distro, and this error still happens?

If your machine A is not Gentoo system or you don't have rpc.statd there, mount the NFS share with nolock option:

# mount <IP of box B>:/ /mnt/slowmachine -o rsize=1024,wsize=1024,nolock
Can anybody add what do if Machine A is not same arch, like:
MachineA: i686, MachineB: armv5tel?


Be sure that the gcc opts on the faster box are set to build proper binaries for the slower box.

Related Articles

Retrieved from ""

Last modified: Mon, 22 Sep 2008 03:19:00 +0000 Hits: 12,576