# NFS: mapping UID's

**URL:** <https://community.learnlinux.tv/t/nfs-mapping-uids/1393>\
**Category:** Linux on Servers\
**Created:** [February 10, 2022, 2:57pm UTC](https://community.learnlinux.tv/t/nfs-mapping-uids/1393 "2022-02-10T14:57:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwsmit](https://community.learnlinux.tv/user_avatar/community.learnlinux.tv/kwsmit/32/517_2.png) [@kwsmit](https://community.learnlinux.tv/u/kwsmit)\
**Post date:** [February 10, 2022, 2:57pm UTC](https://community.learnlinux.tv/t/nfs-mapping-uids/1393/1 "2022-02-10T14:57:01Z")

</div>

Another NFS question. I’m reading Jay’s book Mastering Ubuntu Server en trying to bring knowledge into practice.  
On my server (ksm-server1, Ubuntu server 20.04) I created two NFS shares. This is my /etc/exports file on the server:

```auto
/exports *(rw,fsid=0,no_subtree_checks)
/exports/documents *(ro,no_subtree_checks)
/exports/public *(rw,no_subtree_checks)

```

I can mount the shares successfully on my client (PC2-Kees, Ubuntu 2004). Because the public folder is rw I can read and write files. So that seems to be ok. But…

As Jay mentioned in his book the UID’s and GUID’s for users and groups are different on both machines. So when I list the folder on my server (/exports/public) I see this:

```auto
kees@ksm-server1:~$ ll /exports/public/
total 16
drwxrwxrwx 2 root root 4096 Feb 6 18:18 ./
drwxr-xr-x 5 root root 4096 Feb 5 17:37 ../
-rw-rw-r-- 1 kees-beheer kees-beheer 14 Feb 6 18:18 file01.txt
-rw-rw-r-- 1 kees-beheer kees-beheer 0 Feb 6 15:24 file02.txt
-rw-rw-r-- 1 kees-beheer kees-beheer 0 Feb 6 15:24 file03.txt
-rw-rw-r-- 1 kees-beheer kees-beheer 0 Feb 6 15:24 file04.txt
-rw-rw-r-- 1 kees-beheer kees-beheer 0 Feb 6 15:24 file05.txt
-rw-rw-r-- 1 kees-beheer kees-beheer 0 Feb 6 15:24 file06.txt
-rw-rw-r-- 1 kees-beheer kees-beheer 0 Feb 6 15:24 file07.txt
-rw-rw-r-- 1 kees-beheer kees-beheer 0 Feb 6 15:24 file08.txt
-rw-rw-r-- 1 kees-beheer kees-beheer 0 Feb 6 15:24 file09.txt
-rw-rw-r-- 1 kees-beheer kees-beheer 0 Feb 6 15:24 file10.txt
-rwxrwxrwx 1 root root 13 Feb 5 18:20 test2_server.txt*
-rwxrwxrwx 1 root root 0 Feb 5 18:13 test_server.txt*

```

But when I list the share on my client (/mnt/public):

```auto
14:58 kees@PC2-Kees:~ $ ll /mnt/public/
totaal 16
drwxrwxrwx 2 root root 4096 feb 6 19:18 ./
drwxr-xr-x 6 root root 4096 feb 5 19:40 ../
-rw-rw-r-- 1 kees kees 14 feb 6 19:18 file01.txt
-rw-rw-r-- 1 kees kees 0 feb 6 16:24 file02.txt
-rw-rw-r-- 1 kees kees 0 feb 6 16:24 file03.txt
-rw-rw-r-- 1 kees kees 0 feb 6 16:24 file04.txt
-rw-rw-r-- 1 kees kees 0 feb 6 16:24 file05.txt
-rw-rw-r-- 1 kees kees 0 feb 6 16:24 file06.txt
-rw-rw-r-- 1 kees kees 0 feb 6 16:24 file07.txt
-rw-rw-r-- 1 kees kees 0 feb 6 16:24 file08.txt
-rw-rw-r-- 1 kees kees 0 feb 6 16:24 file09.txt
-rw-rw-r-- 1 kees kees 0 feb 6 16:24 file10.txt
-rwxrwxrwx 1 root root 13 feb 5 19:20 test2_server.txt*
-rwxrwxrwx 1 root root 0 feb 5 19:13 test_server.txt*

```

kees and kees-beheer are different users on both machines. UID 1000 on the server is for user kees-beheer, but UID 1000 on the client is for user kees.  
To overcome this problem, Jay explains to edit the /etc/idmapd.conf file on both machines in such a way that they use the same domain:

```auto
# set your own domain here, if it differs from FQDN minus hostname
Domain = home

```

On the server command hostname --fqdn shows:

```auto
ksm-server1.home

```

On the client command hostname --fqdn shows:

```auto
PC2-Kees.home

```

So both use the same domain.  
Maybe it is good to say that DHCP-server and DNS-server are running on my modem/router and is also set to domain = home.

What can I do to map the UID’s to the right user on both systems?

---

<div class="post-metadata">

**Author:** ![Buffy](https://community.learnlinux.tv/user_avatar/community.learnlinux.tv/buffy/32/497_2.png) [@Buffy](https://community.learnlinux.tv/u/Buffy)\
**Post date:** [February 10, 2022, 4:10pm UTC](https://community.learnlinux.tv/t/nfs-mapping-uids/1393/2 "2022-02-10T16:10:29Z")

</div>

We make our users with the same UIDs across our systems, else it would be a total pain.

It’s pretty easy to change user and group IDs using `usermod` and `groupmod`. You can use find, too, to make sure everything changed that needs to change. Be careful not to put 2 users at the same UID, so you may want to ‘park’ a user at a temporary UID if you need to assign another his UID during the process.

When setting up a new machine, we use Ansible to create groups and users beyond just the initial Ansible user.

---

<div class="post-metadata">

**Author:** ![kwsmit](https://community.learnlinux.tv/user_avatar/community.learnlinux.tv/kwsmit/32/517_2.png) [@kwsmit](https://community.learnlinux.tv/u/kwsmit)\
**Post date:** [February 10, 2022, 5:47pm UTC](https://community.learnlinux.tv/t/nfs-mapping-uids/1393/3 "2022-02-10T17:47:45Z")

</div>

Thanks for your reply. It makes sense what you say.  
I’ll have a look at Ansible, but first finish the book 😀

Regards,  
Kees

---

<div class="post-metadata">

**Author:** ![ThatGuyB](https://community.learnlinux.tv/user_avatar/community.learnlinux.tv/thatguyb/32/784_2.png) [@ThatGuyB](https://community.learnlinux.tv/u/ThatGuyB)\
**Post date:** [February 11, 2022, 2:44am UTC](https://community.learnlinux.tv/t/nfs-mapping-uids/1393/4 "2022-02-11T02:44:34Z")

</div>

Just as Buffy said, Ii too prefer to have users use the same UID across devices, so it doesn’t get out of hand when managing NFS mounts. And it’s a good practice in general, not just NFS. Unrelated to the topic, another good practice is to use the same partition scheme on everything if you can, like sda1 for /boot/efi, sda2 for /boot, sda3 for / etc. If you have one device with a nvme and one with a sata ssd, just keep the same numbers for the partition. If you use lvm, use the same name for them and similar partition scheme.
