Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am sure this may seem like a simple question, but I cannot seem to ask Google the correct question for the life of me. In short, I am having trouble understanding how symbolic links function when a given filesystem is mounted at multiple points.

I have been following the FreeBSD Handbook in setting up application jails on my little home server. Everything has been going along smoothly, until I encountered the second to last step in setting up the master template. More specifically, when I am to issue the following commands:

# cd /home/j/mroot
# mkdir s
# ln -s s/etc etc
# ln -s s/home home
# ln -s s/root root
# ln -s ../s/usr-local usr/local
# ln -s ../s/usr-X11R6 usr/X11R6
# ln -s ../../s/distfiles usr/ports/distfiles
# ln -s s/tmp tmp
# ln -s s/var var

Now, these commands will execute just fine. What I am concerned with is the why. I know that the master template will be mounted as read-only so mounting one file set for multiple jails is no problem. My confusion is how the operating system knows which service's data directory (/s directory, mounted read-write for each service) to use given that the master template only maintains one set of links? Say I had two services, www and ftp. Each will use the master template at /home/j/mroot (mounted read-only at /home/j/) and have their own data directories (found at /home/js/; mounted read-write at /home/j/). Based on the links, how is the filesystem able to know that it should write to the www data directory within one jail and to the ftp data directory from another?

Also, why are the "../" pathing operators required from some of the links? It is my understanding that those would back you right out of the current directory and to elsewhere in the filesystem, whish is likely an invalid path?

I apologize if these are simple questions. My searching has not turned up anything, but I certainly suspect that I may be simply asking the wrong questions. For reference, here is the link to the particular FreeBSD handbook page.

http://www.freebsd.org/doc/en/books/handbook/jails-application.html

Thank you in advance for your assistance.

share|improve this question
add comment

1 Answer

This is not exactly what you asked for but it might make your life easier with ezjail. Ezjail auztomates the process of creating jails and and the templating of them.

share|improve this answer
    
Yeah, I had seen ezjail. But this home server is more of an exploratory project for me to understand what really goes on behind the scenes. Using someone else's script would defeat that purpose. And I am able to set up the jails without too much trouble, but I really what to understand why / how they work. Thanks all the same, though. –  phobos51594 Sep 28 '12 at 23:27
add comment

Your Answer

 
discard

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.