{"id":6400,"date":"2016-10-25T23:38:52","date_gmt":"2016-10-25T15:38:52","guid":{"rendered":"http:\/\/rmohan.com\/?p=6400"},"modified":"2016-11-16T15:08:53","modified_gmt":"2016-11-16T07:08:53","slug":"nfsv4-mounts-show-nobody-as-owner-and-group-on-a-rhel-6-client","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6400","title":{"rendered":"NFSv4 mounts show &#8220;nobody&#8221; as owner and group on a RHEL 6 client"},"content":{"rendered":"<p>Issue<\/p>\n<div id=\"page-wrap\" class=\"page-wrap\">\n<div class=\"top-page-wrap\">\n<div id=\"cp-content\" class=\"main-content\">\n<article id=\"main-content\" class=\"kcs_solution cirrus-content\">\n<div class=\"band band-first\">\n<div class=\"container\">\n<div class=\"row\">\n<div class=\"col-sm-11 solution-content content-wrapper\">\n<section class=\"field_kcs_issue_txt\">\n<ul>\n<li>On Red Hat Enterprise Linux a NFS mounted share shows &#8220;nobody&#8221; as the owner and groupowner of all the files and directory.<\/li>\n<\/ul>\n<\/section>\n<section class=\"field_kcs_resolution_txt\">\n<h2>Resolution<\/h2>\n<ol>\n<li>Create the same user on the Server and Client<\/li>\n<li>Use a centralized namespace like LDAP domain, NIS, Active Directory etc<\/li>\n<\/ol>\n<\/section>\n<section class=\"field_kcs_rootcause_txt\">\n<h2>Root Cause<\/h2>\n<p>The observed behavior is an expected and intended behavior and is not related to RHEL5 or RHEL6 but instead it is related to NFSv3 and NFSv4.<\/p>\n<p>In NFSv3 the username and groupname is mapped from the UID\/GID value, the UID\/GID of the user creating the resource is saved on the server, When the clients access it , the <code>\/etc\/passwd<\/code> and <code>\/etc\/gpasswd<\/code> file will be checked to see if the <code>id<\/code> exists and for which user it will be mapped to , If there is a user with the same uid and gid, then it will be mapped to that user , else the numeric value will be shown.<\/p>\n<p>In NFSv4 the concept is <code>user@domainname<\/code>, if there is no centralized usermapping, then the user will be mapped to the default user nobody or whatever user has been configured in <code>\/etc\/idmapd.conf<\/code>.<\/p>\n<p>Check for mis-configuration of the \/etc\/imapd.conf file. If you make changes to the idmapd.conf file, on RHEL 6.5 and newer the command to clear out the old mappings is:<\/p>\n<div class=\"code-raw\">\n<div class=\"code-raw-toolbar\"><code># nfsidmap -c<\/code><\/div>\n<\/div>\n<\/section>\n<div class=\"code-raw-toolbar\">\n<div class=\"top-page-wrap\">\n<div id=\"cp-content\" class=\"main-content\">\n<article id=\"main-content\" class=\"kcs_solution cirrus-content\">\n<div class=\"band band-first\">\n<div class=\"container\">\n<div class=\"row\">\n<div class=\"col-sm-11 solution-content content-wrapper\">\n<header class=\"header\">\n<h1 class=\"title\"><\/h1>\n<h1 class=\"title\">NFSv4 mount incorrectly shows all files with ownership as nobody:nobody<\/h1>\n<div class=\"header-meta\">\u00a0From the client, the mounted NFSv4 share has ownership for all files and directories listed as nobody:nobody instead of the actual user that owns them on the NFSv4 server, or who created the new file and directory.<br \/>\nSeeing nobody:nobody permissions on nfsv4 shares on the nfs client. Also seeing the following error in \/var\/log\/messages:nss_getpwnam: name &#8216;root@example.com&#8217; does not map into domain &#8216;localdomain&#8217;<br \/>\nResolution<br \/>\nModify the \/etc\/idmapd.conf with the proper domain (FQDN), on both the client and server. In this example, the proper domain is &#8220;example.com&#8221; so the &#8220;Domain =&#8221; directive within \/etc\/idmapd.conf should be modified to read:<\/p>\n<p>Domain = example.com<br \/>\nNote:<br \/>\nIf using a NetApp Filer, the NFS.V4.ID.DOMAIN parameter must be set to match the &#8220;Domain =&#8221; parameter on the client.<br \/>\nIf using a Solaris machine as the NFS server, the NFSMAPID_DOMAIN value in \/etc\/default\/nfs must match the RHEL clients Domain.<br \/>\nTo put the changes into effect restart the rpcidmapd service and remount the NFSv4 filesystem:<\/p>\n<p># service rpcidmapd restart<br \/>\n# mount -o remount \/nfs\/mnt\/point<br \/>\nNote: It is only necessary to restart rpc.idmapd service on systems where rpc.idmapd is actually performing the id mapping. On RHEL 6.3 and newer NFS CLIENTS, the maps are stored in the kernel keyring and the id mapping itself is performed by the \/sbin\/nfsidmap program. On older NFS CLIENTS (RHEL 6.2 and older) as well as on all NFS SERVERS running RHEL, the id mapping is performed by rpc.idmapd.<br \/>\nEnsure the client and server have matching UID&#8217;s and GID&#8217;s. It is a common misconception that the UID&#8217;s and GID&#8217;s can differ when using NFSv4. The sole purpose of id mapping is to map an id to a name and vice-versa. ID mapping is not intended as some sort of replacement for managing id&#8217;s.<br \/>\nOn Red Hat Enterprise Linux 6, if the above settings have been applied and UID\/GID&#8217;s are matched on server and client and users are still being mapped to nobody:nobody than a clearing of the idmapd cache may be required:<\/p>\n<p># nfsidmap -c<br \/>\nNote: The above command is only necessary on systems that use the keyring-based id mapper, i.e. NFS CLIENTS running RHEL 6.3 and higher. On RHEL 6.2 and older NFS CLIENTS as well as all NFS SERVERS running RHEL, the cache should be cleared out when rpc.idmapd is restarted.<br \/>\nAnother check, see if the passwd:, shadow: and group: settings are set correctly in the \/etc\/nsswitch.conf file on both Server and Client.<br \/>\nDisabling idmapping<br \/>\nBy default, RHEL6.3 and newer NFS clients and servers disable idmapping when utilizing the AUTH_SYS\/UNIX authentication flavor by enabling the following booleans:<\/p>\n<p>NFS client<br \/>\n# echo &#8216;Y&#8217; &gt; \/sys\/module\/nfs\/parameters\/nfs4_disable_idmapping<\/p>\n<p>NFS server<br \/>\n# echo &#8216;Y&#8217; &gt; \/sys\/module\/nfsd\/parameters\/nfs4_disable_idmapping<br \/>\nIf using a NetApp filer, the options nfs.v4.id.allow_numerics on command can be used to disable idmapping. More information can be found here.<br \/>\nWith this boolean enabled, NFS clients will instead send numeric UID\/GID numbers in outgoing attribute calls and NFS servers will send numeric UID\/GID numbers in outgoing attribute replies.<br \/>\nIf NFS clients sending numeric UID\/GID values in a SETATTR call receive an NFS4ERR_BADOWNER reply from the NFS server clients will re-enable idmapping and send user@domain strings for that specific mount from that point forward.<br \/>\nNote: This option can only be used with AUTH_SYS\/UNIX authentication flavors, if you wish to use something like Kerberos, idmapping must be used.<br \/>\nRoot Cause<br \/>\nNFSv4 utilizes ID mapping to ensure permissions are set properly on exported shares, if the domains of the client and server do not match then the permissions are mapped to nobody:nobody.<br \/>\nDiagnostic Steps<br \/>\nDebugging\/verbosity can be enabled by editing \/etc\/sysconfig\/nfs:<\/p>\n<p>RPCIDMAPDARGS=&#8221;-vvv&#8221;<br \/>\nThe following output is shown in \/var\/log\/messages when the mount has been completed and the system shows nobody:nobody as user and group permissions on directories and files:<\/p>\n<p>Jun 3 20:22:08 node1 rpc.idmapd[1874]: nss_getpwnam: name &#8216;root@example.com&#8217; does not map into domain &#8216;localdomain&#8217;<br \/>\nJun 3 20:25:44 node1 rpc.idmapd[1874]: nss_getpwnam: name &#8216;root@example.com&#8217; does not map into domain &#8216;localdomain&#8217;<br \/>\nCollect a tcpdump of the mount attempt:<\/p>\n<p># tcpdump -s0 -i {INTERFACE} host {NFS.SERVER.IP} -w \/tmp\/{casenumber}-$(hostname)-$(date +&#8221;%Y-%m-%d-%H-%M-%S&#8221;).pcap &amp;<br \/>\nIf a TCP packet capture has been obtained, check for a nfs.nfsstat4 packet that has returned a non-zero response equivalent to 10039 (NFSV4ERR_BADOWNER).<br \/>\nFrom the NFSv4 RFC:<\/p>\n<p>NFS4ERR_BADOWNER = 10039,\/* owner translation bad *\/<\/p>\n<p>NFS4ERR_BADOWNER An owner, owner_group, or ACL attribute value<br \/>\ncan not be translated to local representation.<\/p>\n<\/div>\n<\/header>\n<\/div>\n<table>\n<tbody>\n<tr>\n<td class=\"answercell\">\n<div class=\"post-text\">\n<h2>These commands are what I did on CentOS Linux release 7.2.1511 (Core)<\/h2>\n<h3>Install nfs-utils<\/h3>\n<pre><code>yum install -y nfs-utils\r\n<\/code><\/pre>\n<h3>Append text to <code>\/etc\/fstab<\/code><\/h3>\n<pre><code>192.168.1.100:\/mnt\/nfs-server \/mnt\/nfs-client nfs defaults,nofail,x-systemd.automount 0 0\r\n<\/code><\/pre>\n<p>Some articles said <code>noauto,x-systemd.automount<\/code> is better, but it worked without <code>noauto<\/code> for me.<\/p>\n<h3>Check whether mount works<\/h3>\n<pre><code>systemctl start rpcbind\r\nsystemctl enable rpcbind\r\nmount -a\r\n<\/code><\/pre>\n<h3>Fix the problem CentOS 7 won&#8217;t auto-mount NFS on boot<\/h3>\n<p>Append text to the end of \/usr\/lib\/systemd\/system\/nfs-idmap.service<\/p>\n<pre><code>[Install]\r\nWantedBy=multi-user.target\r\n<\/code><\/pre>\n<p>Append text to the end of \/usr\/lib\/systemd\/system\/nfs-lock.service<\/p>\n<pre><code>[Install]\r\nWantedBy=nfs.target\r\n<\/code><\/pre>\n<h3>Enable related services<\/h3>\n<pre><code>systemctl enable nfs-idmapd.service \r\nsystemctl enable rpc-statd.service \r\n\r\nsystemctl enable rpcbind.socket\r\n\r\nsystemctl status nfs-idmapd.service -l\r\nsystemctl status rpc-statd.service \u2013l\r\n<\/code><\/pre>\n<h3>Then restarted the OS, I got it.<\/h3>\n<pre><code>shutdown -r now<\/code><\/pre>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Issue<\/p>\n<p> On Red Hat Enterprise Linux a NFS mounted share shows &#8220;nobody&#8221; as the owner and groupowner of all the files and directory. Resolution Create the same user on the Server and Client Use a centralized namespace like LDAP domain, NIS, Active Directory etc Root Cause <\/p>\n<p>The observed behavior is an expected and intended behavior [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6400"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6400"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6400\/revisions"}],"predecessor-version":[{"id":6408,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6400\/revisions\/6408"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}