7

(Disclaimer: I've read "NFS sharing is read only" and I think it's not the same problem)

I have just setup NFS on my raspberry (Raspbian) and I'm trying to access it from OSX. So far so good, I can mount the partition but unfortunately it's read only. Some more info:

Client (OSX)

➜  ~ mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
192.168.1.102:/export/data on /media (nfs)

➜  ~  ls -ld /media    
drwxr-xr-x  3 root  wheel  4096 Mar  8 15:57 /media

Server (Raspbian)

pi@raspberrypi ~ $ cat /etc/exports 

/export       192.168.0.0/16(rw,fsid=0,insecure,no_subtree_check,async)
/export/data  192.168.0.0/16(rw,nohide,insecure,no_subtree_check,async)

pi@raspberrypi ~ $ cat /etc/idmapd.conf 
[General]

Verbosity = 0
Pipefs-Directory = /var/lib/nfs/rpc_pipefs
# set your own domain here, if id differs from FQDN minus hostname
# Domain = localdomain

[Mapping]

Nobody-User = nobody
Nobody-Group = nogroup

As I said the problem comes when trying to create a file in the mounted directory:

➜  /media  touch foo
touch: foo: Permission denied
➜  /media  sudo touch foo
Password:
touch: foo: Permission denied

Note that I can create a file from the server, the problem must be in the nfs mount.

(BTW I followed this guide to set the whole thing up)

Additional info (edit):

Here's how I'm mounting the partition on osx:

sudo mount -t nfs -o rw 192.168.1.102:/export/data /media

  • How are you mounting? Could you show us the relevant /etc/fstab (or OSX equivalent) line? – terdon Mar 8 '14 at 19:49
  • It's usually a good idea to mount the NFS share locally on the system itself in another directory prior, to confirm it's working. – slm Mar 8 '14 at 20:26
  • @terdon Edited to show how I'm mounting, there's no /etc/fstab yet (osx doesn't use one by default, and I want to make sure the mounting is right before adding one) – Pablo Fernandez Mar 8 '14 at 20:57
  • @slm how would that be? mounting it as an nfs partition too?. Just tried to mount it locally using the same mount command as for osx (see edit) and it still readonly, even locally. – Pablo Fernandez Mar 8 '14 at 20:58
  • mount -o nfs sever:/export /mnt. – slm Mar 8 '14 at 22:08
3

This looks more like a permissions problem to me than a read-only filesystem.

From the pi, can you make the /export/data directory temporarily world-writable? If so, can you now write from the client? When you create a file this way, who is the owner?

Without no_root_squash, your root user is mapped to nobody. Otherwise, you'll need to map the user from the client to a user on the pi.

  • I ran into this problem and was able to get around it by using the all_squash option, opening up all permissions on the share directory, and setting the owner of the share to nobody. – T.D. Smith Apr 17 '16 at 1:35
0

I have seen this issue with CentOS 6.5. I don't know if Raspbian uses NetworkManager but if it does, that may be your problem. It appears that the newest version of Network Manager gets in the way of rpcbind and won't let nfs authenticate in some situations. You can find this out quickly by doing an dpkg --get-selections | grep -i NetworkManager on your Raspbian. On CentOS you can remove it without it affecting your network setup. Hopefully this might help.

  • I can't even create a read-write nfs mount on the same raspbian, how is network manager involved here? – Pablo Fernandez Mar 14 '14 at 15:47
  • nfs uses an RPC service to authenticate a user. If rpcbind can't bind the service to the port then nfs cannot authenticate the user. If the user is not authenticated, nfs defaults to read only. – user62700 Mar 14 '14 at 20:32
0

This is something to do with NFSv4. If you use -o vers=3, it becomes happy. I'm sure there's an NFSv4 option to allow root to wreak havoc on your NFS shares, but I stopped looking after I got it to work at all.

# mount -o soft,rw server:/exports/share /mnt/test
# touch /mnt/test/foo
touch: cannot touch '/mnt/test/foo': Permission denied
# umount /mnt/test
# mount -o soft,rw,vers=3 server:/exports/share /mnt/test
# touch /mnt/test/foo
# ls /mnt/test/foo
/mnt/test/foo
# rm /mnt/test/foo
# umount /mnt/test
0

I see that your pseudoroot is /export:

/export 192.168.0.0/16(rw,fsid=0,insecure,no_subtree_check,async)

and your sub-share is /media under /export:

/export/data 192.168.0.0/16(rw,nohide,insecure,no_subtree_check,async)

Instead of mounting giving the absolute path:

sudo mount -t nfs -o rw 192.168.1.102:/export/data /media

have you tried mounting giving the path relative to the pseudoroot:

sudo mount -t nfs -o rw 192.168.1.102:/data /media

?

That's how it works with my installation (CentOS 7 NFSv4 server, Fedora clients).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.