Configure FreeNAS To Be Your Subversion Repository

Recently I had the pleasure of building a Network Attached Storage (“NAS”) server based on FreeNAS. Since then, this device has more than fulfilled my initial requirements for reliable file storage and media server in my network. In a previous post, I described how I configured FreeNAS to store web files and serve as a document root for the Apache http server implemented in my Ubuntu server. Using a similar approach, this post will describe how I configured FreeNAS to host my Subversion (“svn”) repository.

Software versions used in this post were as follows:

  • FreeNAS v0.7.1 Shere (revision 5127)
  • Ubuntu Server v10.04 LTS (x64)
  • Subversion 1.6.6dfsg-2ubuntu1
  • nfs-common v1:1.2.0-4ubuntu4
  • portmap v6.0.0-1ubuntu2

Configuring the FreeNAS Server

I began by creating the directory svn on /mnt/files, an existing mount point on my FreeNAS server. This directory would serve as the location for my svn repository. Then I enabled the Network File System (“NFS”) service so that /mnt/files/svn could be accessed from the Ubuntu server. To do this, navigate to Services->NFS->Settings and make sure that the check box for enabling NFS is checked and specify the number of servers that will run (the default value of four should easily handle dozens of users). Now select “Save and Restart.” Next, navigate to Services->NFS->Shares and select the “+” icon, where you are presented with the configuration screen for creating a new NFS share. Enter the path to be shared; the network that is authorized to access this shared path; and, make sure that the “All dirs” checkbox selected. The remaining options can retain their defaults (See Figure 1). Now select “Add” then “Apply changes.”

Screenshot of NFS shared path configuration in FreeNAS

Figure 1

Configuring the Ubuntu Server

In order to mount the NFS shared path without error, I needed to add a couple of packages. The nfs-common package is needed when a host acts as an NFS client, and includes a number of processes that ensure a particular NFS connection is allowed and may proceed. Also, because NFS relies upon remote procedure calls to function, the package portmap is needed in order to map RPC requests to the NFS service:

After these requisite packages were added, I created a directory to mount the NFS shared path. In this command, you must include the IP address of the FreeNAS server as well as the path to the directory created on it previously:

Then I made sure the permissions for this directory were set correctly:

Next, I added the following lines to /etc/fstab in order for the shared path to mount automatically at boot time:

Then I installed Subversion. The Subversion package for Ubuntu includes the Subversion client, tools to create a Subversion repository (svnadmin), and a custom protocol to make the repository I create on FreeNAS available over my network (svnserve):

And created an svn repository at the root of the shared path:

Next, I removed anonymous access to the repository and established write privileges for authenticated users. To do this, open /media/svn/conf/svnserve.conf and uncomment the following lines (Note: The svnserve.conf file is sensitive to white spaces, so make sure to not leave a space preceding the line when removing the hash (#) symbol):

Then I added myself as an authenticated user to the /media/svn/conf/passwd file:

I plan to use svn’s custom protocol for access to the repository so I need to start the svn server. One way to start it is to use the svnserve command:

However, I wanted the svn server to start up at boot time, as well as have stop and restart capabilities while it was running, so I created the following simple init script:

To use the script, I saved it to my home directory as svnserve and made it executable. Then moved it to /etc/init.d:

Then added the svnserve script to all of Ubuntu server’s multi-user run levels (2-5) and started the svn server:

Now, if for some reason the Ubuntu server is rebooted, the svn server will fire up automatically.

With the svn server now running, I created a root-level directory in subversion for a project called “code”:

After creating the project in subversion I can now use the standard svn commands or applications such Tortoise, RapidSVN and others to checkout the project or otherwise interact with the repository.

Conclusion

This concludes the post on how to configure a FreeNAS server for use as an svn repository. Sure, I could have installed the subversion package directly on FreeBSD, the underlying operating system for FreeNAS, but that approach adds processes that are not native to the FreeNAS implementation. By using the approach outlined in this post, I was able to place the repository on a solid, reliable and centralized storage system, and provide good logical and physical separation between the svn repository and the svn server functionality.

References

http://tldp.org/LDP/abs/html/abs-guide.html

https://help.ubuntu.com/community/Subversion

Comments

  1. Hi,
    you still can create a chroot or jail on you NAS, so you can seperate “additional services” from the “basic services”. Since a NAS often idle most of the time why not?

Leave a Reply

Your email address will not be published. Required fields are marked *

iceflatline