From 5a68de115723b85c3ac97d9d18ead1d99df56689 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 19 Jul 2024 17:42:28 +0200 Subject: [PATCH] nfsd.service: Fix startup gap We've seen that a client sometimes gets EPERM when a server reboots. This is caused by `exportfs -ra` running during boot when the network is not yet available and the hostnames can't be resolved. Start nfsd after the network is online. Also make sure, that mxmounts is done. Also, don't unexport on nfsd exit. exportfs(8): Exporting to IP networks or DNS and NIS domains does not enable clients from these groups to access NFS immediately. Rather, these sorts of exports are hints to rpc.mountd(8) to grant any mount requests from these clients. This is usually not a problem, because any existing mounts are preserved in rmtab across reboots. --- etc/systemd/system/nfsd.service | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etc/systemd/system/nfsd.service b/etc/systemd/system/nfsd.service index e66d959..b481883 100644 --- a/etc/systemd/system/nfsd.service +++ b/etc/systemd/system/nfsd.service @@ -4,6 +4,9 @@ ConditionPathExists=/etc/exports Requires=proc-fs-nfsd.mount var-lib-nfs-rpc_pipefs.mount After=proc-fs-nfsd.mount var-lib-nfs-rpc_pipefs.mount After=sysinit.target +After=mxmount.service +After=network-online.target +Wants=network-online.target Conflicts=shutdown.target [Service] @@ -12,7 +15,7 @@ ExecStart=/usr/sbin/rpc.mountd --foreground --manage-gids ExecStartPost=/usr/sbin/rpc.nfsd --lease-time 90 --grace-time 90 --no-nfs-version 3 8 ExecStartPost=bash -c "(sleep 10;exportfs -r;sleep 20;exportfs -r;sleep 30;exportfs -r)&" ExecReload=/usr/sbin/exportfs -ra -ExecStopPost=/usr/sbin/rpc.nfsd 0 ; /usr/sbin/exportfs -ua +ExecStopPost=/usr/sbin/rpc.nfsd 0 Restart=always [Install]