5

I'm currently setting up NFS based file sharing between my Mac client (Macos 10.14.1) and Raspberry Pi3 server (U16.04.1 LTS). As I dual-boot my Mac (MacOS/Ubuntu18) I want to use my Pi with NFS (I already have Samba running well, but it doesn't handle Unix permissions) as a common home to reduce duplication of files and simplify version control. After I get MacOS working properly, I will tackle the Ubuntu setup.

I have two shares setup at the moment, one using NFS3 (anonymous), the other using NFSv4 (home/user1). Reading/writing files to either of the shares is very fast and working well (other than UID/GID mismatches). Where I have a problem is that whilst listing the files on the NFS3 share is also very fast, listing files on the NFSv4 share is VERY slow and I can't figure out why.

Below are all the settings I'm using. I haven't used mount --bind on the server as I don't think its necessary and doesn't have anything to do with my problem, but I may be wrong.

I've been searching for solutions to this problem for a number of days however nothing I've read addresses my problem, whereby others always complain about directories with large numbers of files, nor have any of the suggestions I've seen fixed my problem. Turns out that it has to do with my color settings in the terminal, see Update below.

Ultimately, I want to synchronise UIDs/GIDs between my Mac and Pi, but that is another question as I don't now much about setting up LDAP (or using NIS?) with (but hopefully without) Kerberos. In addition, I don't have a domain controller setup right now.

Thanks in advance for taking the time to read about my problem and your suggestions.

Server Side
/etc/exports:

/srv/anonymous *(rw,sync,insecure,no_subtree_check,all_squash)
/srv/home/user1 *(rw,sync,fsid=0,insecure,crossmnt,no_subtree_check,no_root_squash)

/etc/default/nfs-common:

NEED_STATD=
NEED_IDMAPD=yes
STATDOPTS="--port 4000 --outgoing-port 4001"
NEED_GSSD=

/etc/default/nfs-kernel-server:

RPCNFSDCOUNT=8
RPCNFSDPRIORITY=0
RPCMOUNTDOPTS="--manage-gids -p 4002"
NEED_SVCGSSD=""
RPCSVCGSSDOPTS=""
RPCNFSDOPTS=""

/etc/idmapd.conf:

[General]
Verbosity = 0
Pipefs-Directory = /run/rpc_pipefs

[Translation]
   Method=static
[Static]
   user1@mac.local = user1

[Mapping]
Nobody-User = nobody
Nobody-Group = nogroup

/etc/modprobe.d/blacklist.conf:

blacklist rpcsec_gss_krb5

/etc/modprobe.d/options.conf:

options lockd nlm_udpport=4001 nlm_tcpport=4001

/etc/modules:

lockd

/sys/module/nfsd/parameters/nfs4_disable_idmapping:

Y  (I've tried manually setting this to "N" but it gets overwritten)
   (So I'm using nfs-common to manage this via the 'NEED_IDMAPD=yes' option

Client Side
Mounting performed using:

mount -v -t nfs -o proto=tcp,port=2049 raspberry.local:/srv/anonymous ~/ranonymous
mount -v -t nfs -o rsize=32768,wsize=32768,proto=tcp,port=2049,sec=sys raspberry.local:/srv/home/user1 ~/ruser1

Results of time ls /share:

user1@mac:[ 6:13]$ time ls ranonymous/
a1        putty.zip test

real    0m0.013s
user    0m0.002s
sys     0m0.004s
user1@mac:[ 6:13]$ time ls ruser1/
a1        a2        a3        a4        a5        me        me copy   myScripts you       you1      you2      you3

real    0m6.044s
user    0m0.002s
sys     0m0.004s

UPDATE I have worked out part of the answer for the slow ls time, which has to do with the use of colours. By commenting out export CLICOLOR=1 in my bash profile, I'm now getting normal speeds. This is a shame as I do want to have colour in my terminal.

1)Why is this problem only occurring with NFSv4?
2)Why does this problem only affect the root folder but not sub-folders, which I get very fast listings of even with colours still on. 3)Is there any way of setting up my bash profile such that I have color when listing local folders but no color when listing shares without using different commands?
4)Is it possible to achieve fast performance without sacrificing colours?

I have another related question: In the terminal, I access the shared drive as per the mountpoint (~/ruser1). However, in Finder, the mountpoint is renamed to (~/user1), the base directory of the server's share. Is there a way of making this consistent?

gone
  • 209
  • 1
  • 10

0 Answers0