7

I am able to mount an NFS directory as a regular user (which doesn't have sudo rights) because a suitable entry (i.e. with the user option) is defined in /etc/fstab file.

But, when I mount it, I am not the owner of it! The owner is the default superuser of the system. So I don't have write permissions in the mounted directory.

How can I make the directory mine?

EmreA
  • 175

1 Answers1

5

When using NFS you need to make sure there is UID/GID matching between users, the following artcile might be useful.

João Pinto
  • 17,159
  • I get the following error when I follow that article:

    exportfs: /etc/exports:6: unknown keyword "map_static=/etc/nfs.map"

    But in http://manpages.ubuntu.com/manpages/lucid/man5/exports.5.html I found anonuid and anongid options. I couldn't make them work though.

    – EmreA Nov 08 '10 at 22:09
  • The article mentions you need userspace nfs, you need to use NFS (from the package unfs3), instead of the traditional kernel nfs . – João Pinto Nov 08 '10 at 22:13
  • When I wanted to install unfs3, it asked me to remove the nfs packages. I am not willing to replace my working nfs server with something I know nothing about. I will look for a solution with my current nfs server. thanks. – EmreA Nov 08 '10 at 22:44
  • 1
    Another option is to use NFSv4 user id mapping, check https://help.ubuntu.com/community/NFSv4Howto, please note that on the legacy NFS you don't have any uid mapping options, you need to manually ensure that users have the same uid on both systems. Also you can simply switch nfs packages safely, your configuration will not be removed. – João Pinto Nov 08 '10 at 23:42
  • I followed the article and used unfs3 but the uid mapping doesn't seem to work. I get no errors but the owner of the mounted directory on the client is still the superuser. Configuring NFSv4 looks very complicated. Thanks for your help. – EmreA Nov 09 '10 at 01:37
  • map_static which is for setting nfs.map is not recognized on centos 7 x86_64 with nfs-server installed by default. exportfs: /etc/exports:1: unknown keyword "map_static=/etc/nfs.map" – Nick Dong May 27 '17 at 08:04
  • My alternative solution is changing UID/GID for my nfs-server to ensure that it is same with clients. linux-changing-uids-and-gids-for-user – Nick Dong May 27 '17 at 08:14