# ports and src on LAN



## balanga (Nov 17, 2017)

Is there any way to link /usr/ports and /usr/src to some location on my LAN so that these two directories don't need to be maintained on every system I have?

Am I correct in thinking that that these two directories have the same contents irrespective of machine architecture?


----------



## obsigna (Nov 17, 2017)

On the FreeBSD 11.1-RELEASE (x86-64) file server in my LAN I have in /etc/exports:

```
/usr/ports  -mapall=root -alldirs    -network 192.168.1.0 -mask 255.255.255.0
/usr/src    -mapall=root -alldirs    -network 192.168.1.0 -mask 255.255.255.0
V4: /
```
... and in /etc/rc.conf

```
...
## NFS with listening IP nailed down to the LAN IP of the file server and fixed ports
rpcbind_flags="-h 192.168.1.1"
rpc_lockd_flags="-h 192.168.1.1 -p 997"
rpc_statd_flags="-h 192.168.1.1 -p 998"
mountd_flags="-r -h 192.168.1.1 -p 999"
nfs_server_flags="-t -h 192.168.1.1"
rpcbind_enable="YES"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"
mountd_enable="YES"
nfs_client_enable="YES"
nfs_server_enable="YES"
nfsv4_server_enable="YES"
nfsuserd_enable="YES"
...
```
On my Beaglebone Black FreeBSD 11.1-RELEASE (ARM) I have in /etc/rc.conf:

```
...
### NFS Client
nfs_client_enable="YES"
nfsuserd_enable="YES"
...
```
... and in /etc/fstab:

```
...
192.168.1.1:/usr/ports      /usr/ports  nfs    rw,noatime,readahead=4,intr,soft,nfsv4    0    0
192.168.1.1:/usr/src        /usr/src    nfs    rw,noatime,readahead=4,intr,soft,nfsv4    0    0
...
```
Of course, you need to make sure that the mount points /usr/ports and /usr/src do exist on the client system and that both are empty.

Of course, you need to restart the file server first, and only once it is up, restart the client.

When building ports in the shared ports tree make sure that  make clean is always executed afterwards, either implicitly -- portmaster(8) does it automatically if not told otherwise -- or explicitly in the respective port directory. Otherwise you would have a completed build in the respective /usr/ports/*/*/work directory which may confuse a client with another architecture.

Occasionally, you might want to run `rm -r /usr/ports/*/*/work` on the file server, in order to keep the ports tree clean.

Regarding /usr/src, this is only the same for exactly the same FreeBSD version and patch level.


----------



## balanga (Nov 17, 2017)

Thanks for the advice. I'll need to work out how to do that on my FreeNAS box...


----------



## sko (Nov 17, 2017)

obsigna said:


> Of course, you need to restart the file server first, and only once it is up, restart the client.



It is sufficient to (re)start the necessary services. Issuing `service nfsd start` or `service mountd restart` upon changing the exports will do the trick - we're not on windows, so don't restart for every minor change...

Also the exports can (should?) be handled via ZFS. Just set the property "sharenfs" on "on" and reload mountd. When managing exports via ZFS it is wise to put a comment in /etc/exports, so you or anyone searching for exports will stick to managing them via ZFS.


AFAIK FreeNAS allows NFS configuration via the GUI. Never actually used it, also this forum has a strict policy regarding questions/discussions about FreeBSD derived products/projects like FreeNAS, so you'll be better off asking at the FreeNAS forum for help with configuration.


----------



## gkontos (Nov 17, 2017)

sko said:


> Also the exports can (should?) be handled via ZFS. Just set the property "sharenfs" on "on" and reload mountd. When managing exports via ZFS it is wise to put a comment in /etc/exports, so you or anyone searching for exports will stick to managing them via ZFS.



In my epxerience so far, it is safer to stick with /etc/exports.


----------



## sko (Nov 17, 2017)

That depends - I'm managing exports (and everything else) on some systems via ansible. Here it is safer/easier to just toggle the zfs property instead of modifying a file, as this will always lead to the desired state even on multiple runs.


----------



## balanga (Feb 10, 2018)

If I have /usr/ports/ linked to the LAN, does that mean that any time a build a port it will be built on the LAN. If so, would it be possible to have the build done locally?


----------



## SirDice (Feb 12, 2018)

Set WRKDIRPREFIX to a local directory with lots of space. See ports(7).


----------



## balanga (Feb 15, 2018)

Where should this be set?


----------



## tobik@ (Feb 15, 2018)

In /etc/make.conf


----------

