9

OK, I'm seriously confused over this stuff, so really descriptive answers would be appreciated, especially if they make this whole mounting stuff less magical and more predictable.

I am trying to mount my Drobo-FS NAS with nfs to get better performance than with cifs.

The drobo is running some trimmed down linux distribution.

Inside /etc/fstab on the client machine (Ubuntu with IP: 192.168.1.150)

# Mount Drobo
192.168.1.100:/mnt/DroboFS/Shares/public /media/drobonfs nfs rw,soft,proto=tcp,users 0 0

I have unfsd installed on the drobo and access via ssh. This is the exports file on the server machine (Drobo-FS with IP 192.168.1.100):

# Allow access for client machine
/mnt/DroboFS/Shares 192.168.1.150(rw,no_root_squash)

Mounting works fine, except that the mounted files are all owned by root with most of the file permissions set to 744. The file permissions shown in the mount on the client match the actual permissions on the server. For example:

client$ sudo chmod 123 /media/drobonfs/somefile
client$ ls -l /media/drobonfs/somefile
---x-w--wx 1 root root 0 2012-01-04 14:15 /media/drobonfs/somefile

drobo$ ls -l /mnt/DroboFS/Shares/public/somefile
---x-w--wx    1 root     root            0 Jan  4 14:15 /mnt/DroboFS/Shares/public/somefile

Writing sudo in front of every command is a drag and I want to understand what is going on, so what can I do to mount it on the client machine with the owner/group set to my account instead of root?

Matthew
  • 6,351
  • 8
  • 40
  • 53

3 Answers3

8

When a share is mounted the userID (UID) of the host system is mapped on the userID (UID) of the client.

On the client the mapped user (based on the userID) will become the owner of the mounted share.

Your problem is caused because the host uses other UID then the client.

You can solve this by defining a /etc/nfs.map file:

/etc/nfs.map

This will look like:

# remote local gid 500 1000 # drobo client uid 500 2003 # drobo client

So when using NFS you need to make sure there is UID/GID matching between the users on host and client. Please read the following article also: http://www.kernelcrash.com/blog/nfs-uidgid-mapping/2007/09/10/

Another great way to solve this problem is looking into the UID's on both host and client system by looking on this /etc/passwd file on both systems.

or by typing:

id tom

change the UID with:

usermod -u 10000 tom

Good luck!

Pieter1973
  • 81
  • 1
  • 3
  • 1
    map_static which is for setting nfs.map is not recognized on centos 7 x86_64 with nfs-server installed by default. `unknown keyword "map_static=/etc/nfs.map"` – Nick Dong May 27 '17 at 08:02
  • Changing UID/GID to let server and client have same UID/GID number works for me. [linux-changing-uids-and-gids-for-user](https://muffinresearch.co.uk/linux-changing-uids-and-gids-for-user/) – Nick Dong May 27 '17 at 08:16
2

Seems like this should work in exports on the Drobo:

/mnt/DroboFS/Shares 192.168.1.150(rw,all_squash,anonuid=NNN)

where NNN is your numeric user id on the client.

Marcs
  • 3,768
  • 5
  • 33
  • 42
Kyle Jones
  • 5,492
  • 1
  • 21
  • 30
-1

Change /etc/exports to:

/mnt/DroboFS/Shares 192.168.1.150(rw,insecure)

and then, on the NFS server, run:

$ sudo exportfs -a

Now when you mount the directory as a non-root user on the NFS client it will mount with the appropriate owner and group.

MrAlias
  • 1,316
  • 15
  • 26
Adrian
  • 76
  • 3