ezjail: Mount portstree in basejail

Hi,

I want to automate the mounting of the ports tree with ezjail. By default ezjail mounts the basejail into each new jail and links some directories up to this one.
Code:
# ls -al /usr/local/jails/build/usr
total 73
drwx------   5 root  wheel  15 May  2 17:46 .
drwx------  12 root  wheel  22 May  2 17:46 ..
lrwxr-xr-x   1 root  wheel  17 May  2 17:46 bin -> /basejail/usr/bin
drwx------   2 root  wheel   2 Jan  3 08:55 games
lrwxr-xr-x   1 root  wheel  21 May  2 17:46 include -> /basejail/usr/include
lrwxr-xr-x   1 root  wheel  17 May  2 17:46 lib -> /basejail/usr/lib
lrwxr-xr-x   1 root  wheel  19 May  2 17:46 lib32 -> /basejail/usr/lib32
lrwxr-xr-x   1 root  wheel  21 May  2 17:46 libdata -> /basejail/usr/libdata
lrwxr-xr-x   1 root  wheel  21 May  2 17:46 libexec -> /basejail/usr/libexec
drwx------   3 root  wheel   3 May  3 17:33 local
drwx------   2 root  wheel   2 Jan  3 08:55 obj
lrwxr-xr-x   1 root  wheel  19 May  2 17:46 ports -> /basejail/usr/ports
lrwxr-xr-x   1 root  wheel  18 May  2 17:46 sbin -> /basejail/usr/sbin
lrwxr-xr-x   1 root  wheel  19 May  2 17:46 share -> /basejail/usr/share
lrwxr-xr-x   1 root  wheel  17 May  2 17:46 src -> /basejail/usr/src

Now it would be the easiest to do following:
mount_nullfs /usr/ports /usr/local/jails/basejail/usr/ports

Logically this should provide all jails with the ports tree (except the distfiles). Unfortunately this doesn't work. The symlink is still active in the new jail.

How do you solve this issue?
 
You are trying to mount a path tree (/usr/ports) on top of a path (/usr/jails/basejail/usr/ports), while /usr/jails/basejail is later mounted inside another path (/usr/jails/build/basejail).
This shrieks for trouble. Piggyback mounting with nullfs isn't supported.

If you want to consolidate both ports-trees from /usr/ports and /usr/jails/basejail/usr/ports just populate /usr/jails/basejail/usr/ports with # ezjail-admin update -P and mount this tree in /usr/ports.

Otherwise rename (or remove) the ports link to ports-basejail and create /usr/jails/build/usr/ports.
Then you are able to mount /usr/ports to this directory inside build jail.

Put your mount points in your /etc/fstab.hostname for automatic mounting.
In your case in /etc/fstab.build:
Code:
/usr/ports /usr/jails/build/usr/ports nullfs ro 0 0
/usr/ports/distfiles /usr/jails/build/var/ports/distfiles nullfs rw 0 0

You can also specify PORTSDIR in /etc/make.conf, if you want to mount under a custom directory.
 
So the ports tree is mounted the other way. Actually quite simple and logical :)

Thank you for the help!

I now just fail fetching the ports tree into the basejail and making this writable for the build jail.

Code:
ezjail-admin update -P
Looking up portsnap.FreeBSD.org mirrors... 4 mirrors found.
Fetching snapshot tag from portsnap1.FreeBSD.org... done.
Fetching snapshot metadata... done.
Updating from Sat May  5 02:33:32 CEST 2012 to Sat May  5 08:40:25 CEST 2012.
Fetching 4 metadata patches... done.
Applying metadata patches... done.
Fetching 0 metadata files... done.
Fetching 11 patches.....10 done.
Applying patches... done.
Fetching 1 new ports or files... done.
/usr/jails/basejail/usr/ports was not created by portsnap.
You must run 'portsnap extract' before running 'portsnap update'.
Error: Updating ports failed.
 
# ezjail-admin update -p should invoke # portsnap -p "${ezjail_jailbase/usr/ports}" extract thus extracting new ports-tree into /usr/jails/basejail/usr/ports.
 
Back
Top