I have to admit that I am building up a thorough frustration with automated mounts in general on Linux. My really really simple use case (notebook with wifi connection) is proving almost insurmountable to solve in a practical manner (no delay in (re)boot, available without manually having to mount it, rw access, some basic level of security (no chmod +777)).
Can someone give me some proper pointers?
In this case Arch wiki for autofs is quite ambiguous and not nearly detailed enough, at least for me.
systemd automount will mount it as root user, so no write access
static fstab will not mount it properly even with noauto,_netdev
I feel like I am losing my sanity here, so I printed all the relevant things in a single file.
In short, the REboot still hangs and still only root has write (it is exported as rw, and no_root_squash).
sudo systemctl status mnt-mounts4bind-nfs_share.mount
● mnt-mounts4bind-nfs_share.mount - nfs share
Loaded: loaded (/etc/systemd/system/mnt-mounts4bind-nfs_share.mount; disabled, vendor preset: disabled)
Active: active (mounted) since Sun 2021-10-17 19:07:37 CEST; 2s ago
TriggeredBy: ● mnt-mounts4bind-nfs_share.automount
Where: /mnt/mounts4bind/nfs_share
What: broken-lenovo.lan:/mnt/nfs_share
Tasks: 0 (limit: 18926)
Memory: 16.0K
CPU: 11ms
CGroup: /system.slice/mnt-mounts4bind-nfs_share.mount
okt 17 19:07:37 myuser-dell systemd[1]: Mounting nfs share...
okt 17 19:07:37 myuser-dell systemd[1]: Mounted nfs share.
sudo systemctl status mnt-mounts4bind-nfs_share.automount
● mnt-mounts4bind-nfs_share.automount - Automount NFS Share
Loaded: loaded (/etc/systemd/system/mnt-mounts4bind-nfs_share.automount; enabled; vendor preset: disabled)
Active: active (running) since Sun 2021-10-17 19:02:34 CEST; 5min ago
Triggers: ● mnt-mounts4bind-nfs_share.mount
Where: /mnt/mounts4bind/nfs_share
okt 17 19:02:54 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 1741 (AUTHENTICATE) okt 17 19:03:12 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 2058 (dolphin)
okt 17 19:06:32 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 3647 (kioslave5) okt 17 19:06:43 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 3647 (kioslave5) okt 17 19:06:54 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 3647 (kioslave5)
okt 17 19:07:05 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 3647 (kioslave5)
okt 17 19:07:15 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 3647 (kioslave5)
okt 17 19:07:26 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 3647 (kioslave5)
okt 17 19:07:37 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 3647 (kioslave5)
okt 17 19:07:48 myuser-dell systemd[1]: mnt-mounts4bind-nfs_share.automount: Got automount request for /mnt/mounts4bind/nfs_share, triggered by 3647 (kioslave5)
cat /etc/systemd/system/mnt-mounts4bind-nfs_share.mount
[Unit]
Description=nfs share
[Mount]
What=broken-lenovo.lan:/mnt/nfs_share
Where=/mnt/mounts4bind/nfs_share
Type=nfs Options=_netdev,auto
[Install]
WantedBy=multi-user.target
cat /etc/systemd/system/mnt-mounts4bind-nfs_share.automount
[Unit]
Description = Automount NFS Share
ConditionPathExists=/mnt/mounts4bind/nfs_share
[Automount]
Where=/mnt/mounts4bind/nfs_share
TimeoutIdleSec=10
[Install]
WantedBy=multi-user.target
cat /etc/fstab | grep nfs
# nfs share
#broken-lenovo.lan:/mnt/nfs_share /mnt/mounts4bind/nfs_share nfs rw,sync,noauto,_netdev,x-systemd.automount,x-systemd.mount-timeout=10,timeo=14,x-systemd.idle-timeout=1min 0 0
This is something you need configure on the NFS Server. The rw in the export just means client could read and write if the filesystem permissions match. The UID of your user on the client still needs write access on the folder of the server you put in the export. If you don’t want to use the UID or GID you can use ACL, but this is a little bit more complicated.
This is a little bit different to something like samba. There is no account for the login, but the file permissions are used to determine which user can access which files. The username is not important, but the UID and GID are very important.
You mean a weird thing that I’m exporting the server’s /mnt/nfs_share? It is actually correct. Also the files on the server are owned by my user, and things work on the server side as expected.
My user is both UID,GID 1000 on both computers. On the client side the files in the share show as owned by root.
My long term goal is to make a Kerberos-LDAP solution on the server, but I cannot hope to defeat that task if I cannot make this easier one work…
According to the server’s rpcinfo -p | grep nfs I have nfs versions 3 and 4, whereas nfs_acl is on version 3 (if that means something).
$ nfsstat -m
/mnt/mounts4bind/nfs_share from broken-lenovo.lan:/mnt/nfs_share
Flags: rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp6,timeo=600,retrans=2,sec=sys,clientaddr=fd5b:c76b:759c::eba,local_lock=none,addr=fd5b:c76b:759c::49f
It seems like the issue was related to the mount on the other PC. For some reason ls -l showed the files belonging to myuser, but upon reboot they changed to root. Adding the uid and gid explicitly on the server solved the issue. Now there is only one thing to take care of, and that is NFS stalling reboot. Is there a good practice to avoid this?
Edit: for the reboot I added this systemd unit and enabled it: