Search code examples
linuxgitubuntunfs

Git not working on nfs share


First, the setup. I'm running a haneWin nfs server on a Windows Server 2012, mounting it at startup in a ubuntu server with this fstab entry ~ip~:/sharenfs /srv/share nfs rw 0 0
The umask is set on the windows server to 000, which indeed results in every user on ubuntu having rw access to the entire share.

Now here's the problem: I want to use the nfs share to store all our git repos so that the windows server can back them up together with all its data. In an earlier setup the ubuntu host provided a nfs share which worked perfect, but for storage reasons the windows server should host the share.

The git repos are supposed to be created automatically by redmine, which worked fine prior to the nfs change, but now it just fails silently. The logs dont provide any useful information.

But here's something that does provide information, if I create a new directory on the nfs share, run git init, the following comes out:

error: could not lock config file /srv/share/git/metatest/test1/.git/config: File exists
... (this line shows a total of 6 times)
error: could not lock config file /srv/share/git/metatest/test1/.git/config: File exists
Reinitialized existing shared Git repository in /srv/share/git/metatest/test1/.git/

The dir was completely empty! In fact running rm -rf .git; git init has the same output.

A ls -lAhR shows this

./.git:
total 22K
drwxrwxrwx 2 git git 4.0K Jun  5 17:07 branches/
-rw-rw-rw- 1 git git   53 Jun  5 17:07 config
-rw-rw-rw- 1 git git   21 Jun  5 17:07 config.lock
-rw-rw-rw- 1 git git   73 Jun  5 17:07 description
-rw-rw-rw- 1 git git   23 Jun  5 17:07 HEAD
drwxrwxrwx 2 git git 4.0K Jun  5 17:07 hooks/
drwxrwxrwx 2 git git 4.0K Jun  5 17:07 info/
drwxrwxrwx 4 git git 4.0K Jun  5 17:07 objects/
drwxrwxrwx 4 git git 4.0K Jun  5 17:07 refs/

./.git/branches:
total 0

./.git/hooks:
total 17K
-rwxrwxrwx 1 git git  452 Jun  5 17:07 applypatch-msg.sample*
-rwxrwxrwx 1 git git  896 Jun  5 17:07 commit-msg.sample*
-rwxrwxrwx 1 git git  189 Jun  5 17:07 post-update.sample*
-rwxrwxrwx 1 git git  398 Jun  5 17:07 pre-applypatch.sample*
-rwxrwxrwx 1 git git 1.7K Jun  5 17:07 pre-commit.sample*
-rwxrwxrwx 1 git git 1.3K Jun  5 17:07 prepare-commit-msg.sample*
-rwxrwxrwx 1 git git 1.4K Jun  5 17:07 pre-push.sample*
-rwxrwxrwx 1 git git 4.8K Jun  5 17:07 pre-rebase.sample*
-rwxrwxrwx 1 git git 3.6K Jun  5 17:07 update.sample*

./.git/info:
total 512
-rw-rw-rw- 1 git git 240 Jun  5 17:07 exclude

./.git/objects:
total 8.0K
drwxrwxrwx 2 git git 4.0K Jun  5 17:07 info/
drwxrwxrwx 2 git git 4.0K Jun  5 17:07 pack/

./.git/objects/info:
total 0

./.git/objects/pack:
total 0

./.git/refs:
total 8.0K
drwxrwxrwx 2 git git 4.0K Jun  5 17:07 heads/
drwxrwxrwx 2 git git 4.0K Jun  5 17:07 tags/

./.git/refs/heads:
total 0

./.git/refs/tags:
total 0

Interestingly though when redmine tries to create a repository the directory isnt even created. Again, it fails silently, no useful output.

When I try to run git add or from a remote pc push any changes from existing repos that where created when redmine did work, I get

fatal: error when closing sha1 file: Permission denied

This all makes absolutely no sense to me. Any ideas?


Solution

  • The question might not be entirely right about the cause of the problem. It turned out, that the gitolite installation had been broken by porting it over to a SMB mount, and then after moving it to an NFS mount the problem persisted.
    I can't tell for sure if that's what happened, but right now it's working on an NFS share and this is my most probable explanation.

    Another explanation would be that hanewin nfs was the problem, since right now running the Windows Server 2012 NFS Server it's working.