====== NFS Portage ======
Gentoo etiquette asks that users don't sync their [[wp>Portage (software)|Portage]] no more than daily to avoid over-loading the rsync servers. But what if you have several [[wp>Gentoo Linux|Gentoo]] systems and you want to update each daily? The simple solution is to have one computer synchronise daily and then share [[wp>Portage (software)|Portage]] as a Network File System (NFS) that the other systems then mount and use transparently.
===== Kernel =====
The first thing you need to do is ensure that you have NFS support in the kernel of each of your systems.
**Server Config**
File systems --->
[*] Network File Systems --->
[*] Root file system on NFS
<*> NFS server support
[*] NFS server support for NFS version 3
[ ] NFS server support for the NFSv3 ACL protocol extension
[ ] NFS server support for NFS version 4 (EXPERIMENTAL)
**Client Config**
File systems --->
[*] Network File Systems --->
<*> NFS client support
[*] NFS client support for NFS version 3
[ ] NFS client support for the NFSv3 ACL protocol extension
[ ] NFS client support for NFS version 4 (EXPERIMENTAL)
[*] Root file system on NFS
<*> SMB file system support (OBSOLETE, please use CIFS)
<*> CIFS support (advanced network filesystem, SMBFS successor)
===== Software =====
Now install the software on each system. This is really simple just
# emerge -av nfs-utils
If you want to have a tool for managing NFS shares on your server then you can
# emerge -av system-config-nfs
but note that there is only one version in portage and it is marked as unstable (for ''~x86'') so you will either need to be running testing or you will have to explicitly unmask it in your ''/etc/portage/package.keywords'' file.
===== Server Configuration =====
You now need to tell the server which file systems and directories to export as Network File Systems. This is straight-forward, simply look at your ''/etc/fstab'' file that defines the mount points of your various devices/partitions, and for each partition you wish to export add an entry to ''/etc/exports''
/media/sda5 192.168.1.0/255.255.255.0(rw,async,subtree_check,no_root_squash)
/media/sda6 192.168.1.0/255.255.255.0(rw,async,subtree_check)
/media/sda7 192.168.1.0/255.255.255.0(rw,async,subtree_check)
/media/sdb1 192.168.1.0/255.255.255.0(rw,async,subtree_check)
/media/sdb2 192.168.1.0/255.255.255.0(rw,async,subtree_check)
/media/sdb3 192.168.1.0/255.255.255.0(rw,async,subtree_check)
/media/sdb5 192.168.1.0/255.255.255.0(rw,async,subtree_check)
/media/sdb6 192.168.1.0/255.255.255.0(rw,async,subtree_check)
/media/sdb7 192.168.1.0/255.255.255.0(rw,async,subtree_check)
/media/sdb8 192.168.1.0/255.255.255.0(rw,async,subtree_check)
The first entry should be the device you wish to export which in the above is ''/media/sda*'' or ''/media/sdb*'' (partitions on one of two drives). The second field indicates which subnet to export to, and allows fine control of IP address' or the use of masks to specify a range of IP address' to export the file-systems to (handy if you've more than one client on the same network). In the above I export all partitions to the ''192.168.1.*'' subnet. The final section sets the options for exporting ''rw'' allows reading and writing, ''async''. Note that one partition (which is actually the portage partition) is exported with the ''no_root_squash'' this.
===== Client Configuration =====
In addition to the kernel configuration detailed above for the client you need to install a few tools for using NFS.
emerge -av nfs-utils
The final step is adding the appropriate entries to your ''/etc/fstab'' file
slug:/media/sda5 /usr/portage nfs auto,rw,users 0 0
slug:/media/sda6 /mnt/slug/pics1 nfs auto,rw,users 0 0
slug:/media/sda7 /mnt/slug/music1 nfs auto,rw,users 0 0
slug:/media/sdb1 /mnt/slug/music2 nfs auto,rw,users 0 0
slug:/media/sdb2 /mnt/slug/video nfs auto,rw,users 0 0
slug:/media/sdb3 /mnt/slug/pics2 nfs auto,rw,users 0 0
slug:/media/sdb5 /mnt/slug/doc nfs auto,rw,users 0 0
slug:/media/sdb6 /mnt/slug/misc nfs auto,rw,users 0 0
slug:/media/sdb7 /mnt/slug/work nfs auto,rw,users 0 0
slug:/media/sdb8 /mnt/slug/ref nfs auto,rw,users 0 0
Instead of the traditional ''/dev/hda*'' in the first field, the device and the mount point that is exported is listed followed by the desired mount point on the client. The filesystem is simply ''nfs'' and then the mount options are as normal.
===== Non-Gentoo Server =====
I started off using NFS portage on my main desktop/server to provide an up-to-date portage for my laptop which I don't turn on every day. However, I decided that leaving this computer on all of the time was a bit of a waste of energy (and ultimately money) so I opted to get an [[nslu2 overview|NSLU2]] to plug my USB drives in and increase the amount of network storage I had available.
Initially I installed Gentoo on the NSLU2, so setting up a NFS portage was straightforward (NFS support was already in the kernel for the NSLU2, it would be pretty useless firmware without!). Unfortunately after a few months it was creating more headaches than it was worth solving so I dropped it and switched to [[http://www.nslu2-linux.org/|SlugOS 4.8]]. This meant that I had to fall back on using a simple ''cron'' job to ''rsync'' my portage tree. I use the following ''cron'' job to sync portage daily on my NSLU2.
# Mins Hours Days Months Day of the week
00 00 * * * rsync --recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages rsync://rsync.gentoo.org/gentoo-portage /usr/portage
Note that you will have to ensure that the ''/usr/portage/'' directory exists, in this example I have Portage on a separate partition, so ''/usr/porgage'' is simply a symbolic link to the mount point of that partition. You may also wish to change the ''rsync://rsync.gentoo.org/gentoo-portage'' mirror to a [[http://www.gentoo.org/main/en/mirrors2.xml|local mirror]].
===== Links =====
* [[http://en.gentoo-wiki.com/wiki/Sharing_Portage_over_NFS|Sharing Portage Over NFS]]
{{tag>gentoo portage linux nfs}}