i try to use systemd to mount two NFS shares in my notebook, because the method of fstab is not working fine. The main problem is that the wifi connection is established later after logging in.
I read about the method of systemd. I understand to create the mount-file in “/etc/systemd/system/” and using the path of mount for the name of the mount-file. I can set the mount-options in the file, too. But i dont understand, if i have to use the entries in the fstab, too. And which options i have to set in the mount-file and the fstab-file.
Note: I want to mount the share after the wifi-connection is established.
systemd is doing the work either way. It converts all the entries in /etc/fstab into mount units dynamically. The advantage of using /etc/fstab is that you can see them all in one place.
In your case, there are a lot of options but for network shares I always recommend a systemd automount. It gets dynamically mounted on access so you don’t have to worry about dependencies.
I use something like this in /etc/fstab for my nfs mounts.
@dalto
pacman -Qi util-linux returns (note: i use the german version):
Name : util-linux
Version : 2.35.1-1
Beschreibung : Miscellaneous system utilities for Linux
Architektur : x86_64
URL : https://github.com/karelzak/util-linux
Lizenzen : GPL2
Gruppen : Nichts
Stellt bereit : rfkill
Hängt ab von : pam shadow coreutils systemd-libs libcap-ng
libutil-linux
Optionale Abhängigkeiten : python: python bindings to libmount [Installiert]
words: default dictionary for look
Benötigt von : f2fs-tools fakeroot gupnp jfsutils mkinitcpio
nilfs-utils ntfs-3g rasqal reiserfsprogs systemd
tlp zeromq
Optional für : syslinux
In Konflikt mit : rfkill
Ersetzt : rfkill
Installationsgröße : 13,00 MiB
Packer : Christian Hesse <arch@eworm.de>
Erstellt am : Sa 01 Feb 2020 19:36:16 CET
Installiert am : Sa 08 Feb 2020 14:43:25 CET
Installationsgrund : Ausdrücklich installiert
Installations-Skript : Nein
Verifiziert durch : Signatur
Let me tell you: I tested this entry in the FSTAB on my desktop-PC, in the same home network (without wifi but wired!) i use EndeavourOS, too, just with XFCE instead of plasma. The FSTAB contains exactly the same entry for the same NFS-share. On this desktop PC the fstab works fine.
Thanks for this tip about dynamically mounting nfs shares using systemd in fstab on the client.
Speaking of dependencies however, I still have an issue on the nfs server side (‘VEBODROID’) which also leads to a problem on the client: when the server is freshly booted, Thunar file manager is hanging when browsing an nfs share and must be killed. First I must restart the nfs-server on the server to make things work again. Looking for a solution for this, I came across a how-to where it explicitely says that the rpcbind service must always be started before the nfs-server service:
[ROOT@VEBODROID ~]# showmount -a localhost
clnt_create: RPC: Program not registered
[ROOT@VEBODROID ~]# systemctl restart nfs-server
[ROOT@VEBODROID ~]# showmount -a localhost
All mount points on localhost:
192.168.0.150:/
192.168.0.150:/srv/nfs
192.168.0.99:/srv/nfs
192.168.0.99:/srv/nfs/LaCie
[ROOT@VEBODROID ~]#
So, now I’m looking for a way to automate this on the server. I can’t find out how to manipulate the order in which services are started.
There is no nfs-server.service file in '/etc/systemd/system/.` to copy.
In stead I used ‘systemctl edit nfs-server’ and added ‘After’ directive:
[Unit]
Description=nfs-server Service
After=rpcbind.target
This resulted in a new directory in ’ /etc/systemd/system’ called ‘nfs-server.service.d’.
In this directory there is a file ‘override.conf’ with the ‘After’ directive.
However the issue persists; I still have to restart nfs-server to get things working.
What can I do?
Edit: now I understand there are two ways to accomplish this; either copy /usr/lib/systemd/system/nfs-server.service to /etc/systemd/system/. and edit this file OR using ‘systemctl edit nfs-server’.
I prefer the ‘systemctl edit’ way and added Requires=rpcbind.target and After=rpcbind.target
Still no luck…
Hey guys,
Ok, @dalto jumps in my thread - its ok, but i did not have a solution for my problem yet.
The wifi-connection on my laptop is established very late - after loggin in. The option in the fstab “systemd-networkd-wait-online” is correct, but i think there must be another problem.
I want to use error logs or start logs for finding the problem. I just need a little starting help.
journald with the correct filter could be the right way. Can someone give me a tip?
Damn, i think a made an error: Days before i tested the way of creating the file “mnt-nfsshare.mount” manually, before i try to use the fstab only. The manual created file was already there.
I deleted the file now an restart the system. As i understand, the mount-file will be created automatically by systemd from the entries of fstab?
But after the restart of system, there is no file mnt-nfsshare.mount. The problem is not solved, yet.
HI @dalto,
thanks for you patience.
I still get an error in Dolphin. The NFS-Share is listed in the left tab, but if i click on it, Dolphin shows the message
An error occurred while accessing 192.168.XXX... The message is "mount.nfs: failed to prepare mount: Operation not permitted"