Why does my nfs mount always changes to be owned by root after mounting?

14,949

You need to add uid (user identifier) and guid (group user identifier) like these:

$ sudo mount -t nfs 10.9.XXX.XXX:/root/src /home/patryk/nfs_share -o rw,user,vers=3,uid=1001,gid=1001

Maybe you need to use id command to find your id/guid:

$ id username

Although you may use actual user/groupnames (beware of spaces) instead numeric uid, gid values.

Share:
14,949

Related videos on Youtube

Patryk
Author by

Patryk

Software Engineer C++/Go/shell/python coder Linux enthusiast Github profiles: https://github.com/pmalek https://github.com/pmalekn

Updated on September 18, 2022

Comments

  • Patryk
    Patryk over 1 year

    I have a mount point for my nfs share:

    drwxrwxrwx   2 patryk patryk 4.0K Feb  4 16:23 nfs_share
    

    after I mount it I get

    $ sudo mount -t nfs 10.9.XXX.XXX:/root/src /home/patryk/nfs_share -o rw,user,vers=3 
    drwxr-xr-x   2 root   root   4.0K Feb  4 17:06 nfs_share
    

    I tried with /etc/fstab but I get the same results:

    10.9.XXX.XXX:/root/src /home/patryk/nfs_share nfs rw,user,vers=3 0 0
    

    The funny thing is that I cannot chown this after mounting:

    $ sudo chown patryk:patryk nfs_share
    chown: changing ownership of `nfs_share': Operation not permitted
    

    My server is configured as follows:

    // 10.9.XXX.XXX
    $ cat /etc/exports
    /root/src/napet_src/ *(rw,nohide,insecure,no_subtree_check,async)
    

    How do I define those permissions so that I can write to this folder?

  • Louis Kröger
    Louis Kröger over 4 years
    You can also just specify uid=user,gid=user and mount will figure out the current user's credentials, if that's what you need.
  • bagustris
    bagustris about 3 years
    For Ubuntu 20.04, the comment above didn't work (the answer did). Error message: "'uid' option needs a decimal value"