Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In FreeBSD, how do I automate the process of mounting of a directory into a jail at boot time?

share|improve this question

migrated from Mar 10 '11 at 17:53

This question came from our site for professional and enthusiast programmers.

Reading through /etc/default/rc.conf there are some nice entries for setting up jails. Most notable is:

#jail_example_exec_afterstart0="/bin/sh command"        # command to execute after the one for
                                                        # starting the jail. More than one can be
                                                        # specified using a trailing number

So you could use that to execute a script within the jail to mount a directory (as long as that directory is available from within the jail, such as NFS mounts etc).

Alternatively you would just ensure that the mounts are all done before the jail starts by using nullfs in /etc/fstab:

/path/to/source /path/to/jail/directory nullfs ro 0 0

Replace the ro with rw if you want to allow writing to that directory.

share|improve this answer

How about using nullfs mounts? It's similar to bind-mounts on Linux. I.e. mount another location onto a folder.

share|improve this answer
I finally got it working by using the cron utility. Thanks for all of your suggestions. Cheers. – user71126 Apr 8 '11 at 4:37

The official way is to create a fstab from the host os's point of view and give it the jails name as an extension


create /etc/fstab.jail1 for jail1 create /etc/fstab.jail2 for jail2

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.