5.1 Template Filesystem

Prior to setting up virtual servers, you must create a template filesystem, which will be used to decide what files each virtual server will contain. In other words, you must create a small Linux Filesystem. The files within the template filesystem will be hard linked to each virtual server you create. The template directory will be the directory and file structure for your virtual servers - whatever is in the template directory will be what each virtual server you create will contain. This may seem a hassle but there are many reasons this must be done. In order for the files to be linked over, they must all be within the same partition (most servers have multiple partitions). Virtfs uses links to create virtual servers to save hard drive space. For example, if you are running about six virtual servers and copied all the files over for each server, this would amount to about 700Mb in itself. By linking, however, this problem is eliminated. Each server will take up about 5-10Mb. However not all of the filesystem is linked over. For example, /etc/hosts, /etc/HOSTNAME, etc - system specific files are not linked and therefore are not included in the template filesystem.

Another advantage to the template filesystem is that you can configure what files should be copied over to the virtual servers. Would you want the "virtual users" to have access to developmental tools? SSH? You can specify which files should be included with each virtual server by copying them to the template filesystem.

To recap, the process in creating virtual servers is simple. Firstly, a template directory is created and whatever files you specify will be copied over to the template filesystem. Then, when you want to create virtual servers, the files from the template filesystem are hard linked to the virtual server - Virtfs handles this for you upon creation of a virtual server. You will have to make sure that the template directory is within the same partition as the virtual servers, ie within the /virtual directory (if you stick to the suggested configuration). If you don't please make changes to the Leading Virtual Directory variable within /etc/virt.conf.

The basic structure of this is:

                           --------------------
                      	   |  MAIN SERVER: /  |
                           ____________________
				   |         
                                   |
                                   V direct copy
                                   |
                  -----------------------------------------
                  | Template Filesystem /virtual/template |
                  -----------------------------------------
                     |                          |     |        
   hard links        ^                          ^     ---------<-------------- 
                     |                          |                            |
                     |		                |		             |
                 -----------------        ------------------           ------------------
                 |   a.com        |       |     b.com      |           |    c.com       |
                 | /virtual/a.com |       | /virtual/b.com |           | /virtual/c.com |
                 -----------------        ------------------           ------------------