ThingyMaJig

Thingy Ma Jig is the blog of Nicholas Thompson and contains any useful tips, sites and general blog-stuff which are considered interesting or handy!

Connect

LinkedIn GitHub

Topics

announcement 25 apache 3 Apple 1 bash 8 code 7 cool 30 Days Out 8 Dark Basic Pro 4 design 12 doctor who 1 Drupal 74 E4600 1 EOS 400D 3 firefox 2 Flickr 3 free 21 games 5 geek 38 git 2 GreaseMonkey 1 hardware 7 Homebrew 1 How to 37 humour 5 iphone 1 javascript 1 jquery 1 K800i 6 k850i 4 lighttpd 3 linux 33 mac 9 miscellaneous 4 mobile phone 9 music 4 mysql 8 n73 1 n95 1 New Relic 1 Ogre3D 1 OS X 2 performance 3 photos 10 programming 40 Quicksilver 1 review 19 security 3 SEO 6 software 12 svn 2 technology 4 tip 7 tips 10 tv 3 video 3 vim 7 webdev 2 websites 33 wii 1 windows 1 YADS 10

SVN + NFS = svn nfs cant get exclusive lock

Posted on 25 November 2008 in
svn programming linux How to geek

Last night I was trying to configure SVN on a server. The setup was that the SVN Repo was on "srv2" and the frontend and code I wanted to import was on "srv1".

I created an NFS share on srv2 and mounted it on srv1 in /mnt/svnroot. The mount worked perfectly and I could touch and remove files from srv1.

So I tried to create a "sites" folder where I wanted to import a site I wanted to version control. This is where I started to have problems… The sollution was to add "nolock,bg" to the mount options on the client. Read on for more details!

NFS Configuration

[adsense:160x600:6965419571]

Before I continue, a little detail about the setup… The servers mentioned here are "psuedo" (ie not real). For the sake of the example "srv1" is 192.168.1.2 and "srv2" is 192.168.1.1. The SVN Server (srv2) has the following...

[user@srv2 ~]$ cat /etc/exports
/svnroot 192.168.1.2(rw)
[user@srv2 ~]$ cat /etc/hosts.deny
portmap: ALL
#ADDED BY NICK
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL
[user@srv2 ~]$ cat /etc/hosts.allow
portmap: srv1
#ADDED BY NICK
lockd:   srv1
rquotad: srv1
mountd:  srv1
statd:   srv1

The above shows that the folder /svnroot is being exported as an NFS share and that access to the services portmap, lockd, mountd, rquotad & statd are denied to all, however the allow file grants access to these services for srv1 only.

One srv1, we have the following settings…

[user@srv1 ~]$ cat /etc/fstab
# srv2 - svn stuff
srv2:/svnroot  /mnt/svnroot  nfs  rw,hard,intr,nolock,bg  0 0

What does this do? Well it mounts the export /svnroot on srv2 to the local folder /mnt/svnroot using nfs with the options rw,hard,intr,nolock,bg. In all honesty - I dont know what the last 2 numbers are for!

Using this line in the fstab file I can now type (as root I believe)…

[user@srv1 ~]$ mount /mnt/svnroot

If this works then you can browse /mnt/svnroot as if it was on your local system. Now to use SVN!

[adsense:336x280:9994499560]

Configuring SVN

I checked out websvn from Tigris using the following command…

[user@srv1 ~]$ svn checkout http://websvn.tigris.org/svn/websvn/trunk websvn --username guest

Once in here, I went into the includes folder and copied distconfig.php to config.php. In config.php I made a few changes to suit my system - the main ones were adding a repository:

$config->addRepository('REPO', 'file:///mnt/svnroot/');

and teaching websvn that files ending in .module are actually PHP files:

$extEnscript['.module'] = 'php';

After that it was a simple matter of adding a VHost to bind a domain to my websvn install.

Using SVN

The problems really kicked in after all the above steps when I actually tried to USE SVN. When I tried to SVN to import a project by running this (on srv1)…

svn mkdir file:///mnt/svnroot/sites -m "Creating sites folder"

… I was presented with an interesting error claiming…

svn nfs cant get exclusive lock

After doing a little research I found an interesting post on woss.name by Byung-chul Lee about how he (or she?) fixed the same issue. The suggestion of adding "bg,nolock" to the mount options on the client fixed the locking issues! I don't know what the side effects will be though.