Results 1 to 8 of 8

Thread: how can I mount NFS Share as root?

  1. #1
    Join Date
    Jun 2008
    Beans
    118

    how can I mount NFS Share as root?

    I want to set up an NFS share i ubuntu 12.04 and mount it from a client as root. To be clear, I need apps not running as root on client machine to be able to write files so that the owner will show as root on server and client can read all files as root. I want to force the seever as always seeting thise reads writes from that client as root , regardless of user on client.


    I need to do this all through /etc/exports on server and /etc/fstab on client

    I have been struggling with this for days and could really uses some guidance.

    Thanks in advance

  2. #2
    Join Date
    Dec 2011
    Beans
    15

    Re: how can I mount NFS Share as root?

    The only way to do this would be to allow rw and only use the mount as root.

    Instead an easier approach would be to use SAMBA and directory/file creation masks.

  3. #3
    Join Date
    Feb 2009
    Location
    Dallas
    Beans
    1,306
    Distro
    Ubuntu Gnome 14.04 Trusty Tahr

    Re: how can I mount NFS Share as root?

    A better option might be to set ownership to nobody and nogroup for the shared files and then squash all in the NFS configuration (defaults to nobody and nogroup). If you really must use root then you can squash all and specify the user as root (not recommended).

  4. #4
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,724
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: how can I mount NFS Share as root?

    The key requirement is adding "no_root_squash" to the list of options for the share in /etc/exports.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  5. #5
    Join Date
    Jun 2008
    Beans
    118

    Re: how can I mount NFS Share as root?

    Thanks to all of you. My current scenario is like this. I have an app running as "root" on server. I can not change this. I have a similar app running under user space on client. They share all data files via NFS

    From the client if I log in as root then cd to the NFS mount I can then read/write as root on the shared NFS mount (server confirms files as owner root). If however I log in as user on the client, I no longer can read/write as root. Instead it seems to map to the user of the corresponding user ID (number) .

    I want to be able to log in to the client as user and maintain the ability to read/write the NFS share as root

    current export is like this
    Code:
    /home/serverusername/  *(rw,async,no_root_squash,no_subtree_check)
    I mount it on the client like this
    Code:
    192.168.1.2:/home/serverusername               /home/clientusername               nfs     _netdev,defaults,user,auto,noatime,intr   0 0


    so if I change the export as follows
    Code:
    /home/serverusername/  *(rw,async,root_squash,no_subtree_check)
    Then how do I define to squash all access to "root"?

    I can not change how the server writyes these files. They will always be root:root


    although the smb suggestion is good, I thought about it already and unfortunately I do not really see it as a viable option for performance reasons.
    Last edited by markosjal; March 13th, 2014 at 05:07 PM.

  6. #6
    Join Date
    May 2008
    Location
    SoCal
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: how can I mount NFS Share as root?

    Quote Originally Posted by markosjal View Post
    Thanks to all of you. My current scenario is like this. I have an app running as "root" on server. I can not change this. I have a similar app running under user space on client. They share all data files via NFS

    From the client if I log in as root then cd to the NFS mount I can then read/write as root on the shared NFS mount (server confirms files as owner root). If however I log in as user on the client, I no longer can read/write as root. Instead it seems to map to the user of the corresponding user ID (number) .

    I want to be able to log in to the client as user and maintain the ability to read/write the NFS share as root

    current export is like this
    Code:
    /home/serverusername/  *(rw,async,no_root_squash,no_subtree_check)
    I mount it on the client like this
    Code:
    192.168.1.2:/home/serverusername               /home/clientusername               nfs     _netdev,defaults,user,auto,noatime,intr   0 0


    so if I change the export as follows
    Code:
    /home/serverusername/  *(rw,async,root_squash,no_subtree_check)
    Then how do I define to squash all access to "root"?

    I can not change how the server writyes these files. They will always be root:root


    although the smb suggestion is good, I thought about it already and unfortunately I do not really see it as a viable option for performance reasons.
    Set the group ownership to a common user. I use the user group named users . This is gid 100. You need to set inheritance on the basedir of the export by using chmod 775. At this point it doesn't matter if the root user or a mortal user creates or modifies the file the ownership is always root:users with the directory perms of 775 and file perms of 664.
    Last edited by bab1; March 13th, 2014 at 06:28 PM.
    -BAB1

  7. #7
    Join Date
    Jun 2008
    Beans
    118

    Re: how can I mount NFS Share as root?

    Thanks I finally figured out another work-around that I think is working.

    I ran the program as root on the client system and so far so good.

    I question the implications of root:users but might try it if what I have does not work

  8. #8
    Join Date
    May 2008
    Location
    SoCal
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: how can I mount NFS Share as root?

    Quote Originally Posted by markosjal View Post
    I question the implications of root:users but might try it if what I have does not work
    What implications are those? This is the standard method of accommodating multiple users in UNIX (Solaris and BSD's) and versions of Linux.

    Debian uses User Private Groups (UPG), but it is not viable scheme if you have multiple users accessing the same data. Maybe this will help in understanding the situation. Running a process as root is far more dangerous from a system admin's point of view.

    EDIT: While this is a modification to the default method of UPG, it is not a workaround at all. It is more like reverting to the UNIX/BSD way on a specific branch of the file system.
    Last edited by bab1; March 13th, 2014 at 08:47 PM.
    -BAB1

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •