Configure ports to install and run on external media

I've purchased a Asus EeePC 701 4G, which has 4 gigabytes of built in storage. I've installed the base FreeBSD system as well as some small command line ports (sudo, nano, tmux).

What I'm looking to do is configure ports to install on an external storage media, like a flash drive or an SD card. Also include the external media as a path to execute binaries from command line. Like installing xorg and a desktop environment onto just the external media and being able to start a desktop environment with it attached.

I'm also looking for a degree of flexibility as far as being able to start up the machine without the external media. Like if I wanted to add a port to the built in storage.

Essentially, having two ports directories, one local and one external, external may not always be available.

Where would be a good place to get started?
 
You could do it as follows:

Create a mount point for the media you want to store your installed ports, and mount it:
Code:
# mkdir /software
# mount /dev/daXsY /software
Then create directories for the port files and the package and ports database:
Code:
# mkdir -p /software/db/pkg
# mkdir /software/db/ports
# mkdir -p /software/usr/local
Now you can build and install your ports:
Code:
# cd /usr/ports/<category>/<portname>
# sh -c 'PORT_DBDIR=/software/db/ports PKG_DBDIR=/software/db/pkg LOCALBASE=/software/usr/local make install'
Finally, add the paths /software/usr/local/sbin and /software/usr/local/bin to the environment variable PATH, or add them to the path-variable of your login class in /etc/login.conf, followed by executing
Code:
# cap_mkdb /etc/login.conf
 
Thanks, configured very nicely.

Would it be possible to configure the installation of binary packages onto external media using "pkg install?" The example there works well for small ports, but for something like xorg I'm exhausting my machine's local storage capacity attempting to compile.
 
See pkg(8):
Code:
     -r	<root directory>, --rootdir <root directory>
	     pkg will install all packages within the specified	<root
	     directory>.
 
See pkg(8):
Code:
     -r	<root directory>, --rootdir <root directory>
	     pkg will install all packages within the specified	<root
	     directory>.

Ah, I see.

Have to say, BSD is pretty fantastic compared to other unix like operating systems, particularly coming from a popular commercial operating system. BSD offers a degree of structure I'm comfortable with, and without too much hand holding so I can take the time to learn.

Thanks.
 
Back
Top