I am truly impressed.
You are able to completely confuse yourself and run in circles around a truly simple operation.
Ok - I admit - if you are not familiar with *nix concepts it is not simple …
Server
-
Define device mount using UUID (persistent device name)
- device UUID → $(lsbl -no UUID /dev/sdy1)
- mount point → /a/nfs
create mount unit a-nfs.mount with content
[Unit] Description=Demo NFS share mount [Mount] What=/dev/disk/by-uuid/4fdcb623-71ce-4840-ac50-021413cbfd4a Where=/a/nfs Options=defaults,rw,noatime [Install] WantedBy=multi-user.target -
Mount device
systemctl enable --now a-nfs.mount -
Bind mount in fstab
/a/nfs /srv/nfs/share none bind 0 0 -
Ensure service folder is created
mkdir -p /srv/nfs/share -
Ensure mount point has rw permissions
chmod 777 /a/nfs -
Ensure NFS service enabled and up
systemctl enable --now nfs-server -
Create NFS export file with a rw share
/srv/nfs tiger.net.nix.dk(rw,sync,fsid=0,no_subtree_check) /srv/nfs/share tiger.net.nix.dk(rw,sync,no_subtree_check) -
Reload NFS exports
# exportfs -arv exporting tiger.net.nix.dk:/srv/nfs/share exporting tiger.net.nix.dk:/srv/nfs -
Verify export
# showmount -e pw0.net.nix.dk Export list for pw0.net.nix.dk: /srv/nfs/share tiger.net.nix.dk /srv/nfs tiger.net.nix.dk
Client
-
Verify the share can be reached
$ showmount -e pw0.net.nix.dk Export list for pw0.net.nix.dk: /srv/nfs/share tiger.net.nix.dk /srv/nfs tiger.net.nix.dk -
Define NFS mount and mountpoint
- mount point → /a/nfs
- mount unit → a-nfs.mount
create mount unit a-nfs.mount with content
[Unit] Description=Demo NFS share mount [Mount] What=pw0.net.nix.dk:/share Where=/a/nfs Type=nfs Options=_netdev,rw [Install] WantedBy=multi-user.target -
Create automount
- automount unit → a-nfs.automount
create automount unit a-nfs.automount with content
[Unit] Description=Demo NFS client mount [Automount] Where=/a/nfs TimeoutIdleSec=10 [Install] WantedBy=multi-user.target -
Start the mount unit once and stop it
systemctl start a-nfs.mount systemctl stop a-nfs.mount -
Ensure mount point has rw permission
chmod 777 /a/nfs -
Enable and start the automount unit
systemctl enable --now a-nfs.automount
Done
On the client browse the share using your file manager
fh@tiger ~ $ ls -l /a/nfs
total 0
-rw-r--r-- 1 fh fh 0 Jul 24 16:21 file.txt
fh@tiger ~ $ touch /a/nfs/new_client_file.txt
fh@tiger ~ $ ls -l /a/nfs
total 0
-rw-r--r-- 1 fh fh 0 Jul 24 16:21 file.txt
-rw-r--r-- 1 fh fh 0 Jul 24 17:03 new_client_file.txt
Visualising point made by @winnie in below comment
fh@tiger ~ $ ls /a/nfs
file.txt new_client_file.txt non_root_server_user.txt
fh@tiger ~ $ ls -l /a/nfs
total 0
-rw-r--r-- 1 fh fh 0 Jul 24 16:21 file.txt
-rw-r--r-- 1 fh fh 0 Jul 24 17:03 new_client_file.txt
-rw-r--r-- 1 1001 1001 0 Jul 24 17:18 non_root_server_user.txt
fh@tiger ~ $ echo "TEST" > /a/nfs/non_root_server_user.txt
bash: /a/nfs/non_root_server_user.txt: cannot overwrite existing file
fh@tiger ~ $ echo "TEST" >> /a/nfs/non_root_server_user.txt
bash: /a/nfs/non_root_server_user.txt: Permission denied
fh@tiger ~ $ ls -l /a/nfs
total 1
-rw-r--r-- 1 fh fh 0 Jul 24 16:21 file.txt
-rw-r--r-- 1 fh fh 0 Jul 24 17:03 new_client_file.txt
-rw-r--r-- 1 1001 1001 48 Jul 24 17:22 non_root_server_user.txt
fh@tiger ~ $ cat /a/nfs/non_root_server_user.txt
fh@pw0.net.nix.dk owns the content of this file
fh@tiger ~ $ cat /a/nfs/file.txt
TEST
fh@tiger ~ $ cat /a/nfs/file.txt
TEST
nix@pw0.net.nix.dk owns this file.
Because the user have the same UID as fh@tiger both can write the file
Confused?