There are some cases where a remote ports tree is a good thing to have around. For example, it can save bandwidth by downloading dist files only once and using them across all clients, when you need to know that all hosts using the tree have the same version of packages (good in development environment or large network), or even when the client doesn't have enough space for ports tree, distfiles, or the compile itself (NanoBSD!)
I personally use this method for my NanoBSD boxes. These installs are usually on small flash cards that (1) don't have room for the ports tree/build and (2) would kill my solid state drives with all the rewrites. Using ports allows me to fine-tune applications instead of being a slave to preconfigured binaries...which is a very good thing on an embedded board.
Since you are a FreeBSD geek (don't lie!) and already have an existing FreeBSD system, we will just use that port tree and emulate it being on another media device. There is no magic here, but NFS can be picky!
NFS
Pretty much anyone that has been around any unix variant has heard of NFS. The FreeBSD handbook outlines it very well.
In short, it lets you mount a remote directory as if it was on your system. This is exactly what we need to emulate the ports tree.
In our topology, we need a NFS server (with the ports system on it in our case) and our client will be out NanoBSD box.
Server
Ports Tree
First of all, make sure you have the ports tree installed. If you are not sure, ls the /usr/ports directory.
- # ls /usr/ports
If it has contents, you have it. If you do not have it, download it and extract it.
- # portsnap fetch extract
- ... ... snip ... ... snip ... ...
Kernel Config
NFS services come in the default kernel, but if you have a custom kernel you might want to make sure you have the following options in your kernel config:
| options | NFSCLIENT | # Network Filesystem Client |
| options | NFSSERVER | # Network Filesystem Server |
| options | NFS_ROOT | # NFS usable as /, requires NFSCLIENT |
rc.conf
All the services we need are bootable via rc.conf at startup. We need to enable the NFS services:
- # vi /etc/rc.conf
- ... ... snip ... ... snip ... ...
- rpcbind_enable="YES"
- nfs_server_enable="YES"
- mountd_flags="-r"
- ... ... snip ... ... snip ... ...
/etc/exports
exports defines who may access your shares, what permission those shares are, and where the shares point to on the local system. The following is needed for our little project, but more options can be found by using the man exports command.
The IP used below is an example and is the address of the CLIENT. Change this as necessary.
- # vi /etc/exports
- /usr/ports -maproot=root 172.16.5.100
Start Daemons
You can take the easy way out by restarting (restart -r now) or load them manually.
- # /etc/rc.d/rpcbind start
- # /etc/rc.d/nfsd start
- # /etc/rc.d/mountd start
Client
This process is even simpler than the server's config.
rc.conf
- # vi /etc/rc.conf
- nfs_client_enable="YES"
Kernel Config
- ... ... snip ... ... snip ... ...
- nfs_client_enable="YES"
- ... ... snip ... ... snip ... ...
Start Daemons
You can take the easy way out by restarting (restart -r now) or load them manually.
- # /etc/rc.d/nfsclient start
Test It Out
The IP below is the NFS server, so your topology could differ.
- # mkdir /usr/ports
- # mount_nfs 172.16.5.1:/usr/ports /usr/ports
- # cd /usr/ports/net/isc-dhcp3-server
- # make install clean distclean
This port should do all the fun stuff and install. If not, check back over this howto or consult the ultimate resource on this: FreeBSD Handbook - NFS
Conclusion
See, that was pretty easy, huh? Now you have have what ever package you please installed with out taking up all the space that whole ports tree would have otherwise taken up.
- Tags
- AI (1)
- ALIX (1)
- digitalfoo.net (2)
- embedded (6)
- FreeBSD (30)
- Java (1)
- Linux (26)
- misc (7)
- my projects (1)
- MySQL (2)
- NanoBSD (3)
- opensource (7)
- perl (1)
- PHP (3)
- programming (11)
- Python (1)
- security (4)
- Archives
- 2011
- February (1)
- March (1)
- June (1)
- July (1)
- August (1)
- 2010
- June (5)
- July (2)
- December (4)
- April (6)
- March (2)
- May (1)
- August (2)
- October (1)
- November (1)
- 2009
- August (7)
- July (8)
- April (4)
- May (4)
- December (2)
- June (1)
- September (1)
- November (4)
- October (1)
- Web Tools
- Index
- dig-shovel Live
- SQL Injection Encoder
- Links
-

