nfs-kernel-server: fix up init scripts and exports

Add post-release patch to fix musl builds:
  250-fh_key_file-fix-missing-string.h-inclusion.patch

v3 init:
- Mirror upstream systemd service; use nfsdctl to manage the server
- Add /etc/nfs.conf to restrict to NFSv3 only:
  % cat /proc/fs/nfsd/versions
  +3 -4 -4.0 -4.1 -4.2

v4 init:
- Remove dead procd_append_param -F from nfsdcld instance
- Add respawn to nfsv4.exportd and rpc.idmapd; exclude nfsdcld as it
  daemonizes and would spawn duplicates under procd respawn
- Remove unused NFSDCLD_PID variable; nfsdcld writes no pidfile
- Add status_service() using pgrep; procd permanently misreports
  nfsdcld as stopped due to its daemonization behavior

exports:
- Supply unified /etc/exports covering both v3 and v4 syntax so the
  file survives switching between package variants

Signed-off-by: John Audia <therealgraysky@proton.me>
This commit is contained in:
John Audia
2026-04-11 15:42:30 -04:00
committed by Hannu Nyman
parent d726f77f59
commit ab66b0e04d
8 changed files with 205 additions and 32 deletions
+14 -8
View File
@@ -47,7 +47,7 @@ endef
define Package/nfs-kernel-server
$(call Package/nfs-kernel-server/Default)
TITLE:=Kernel NFS server (NFSv3)
DEPENDS+= +kmod-fs-nfsd +kmod-fs-nfs +rpcbind
DEPENDS+= +kmod-fs-nfsd +kmod-fs-nfs +rpcbind +libevent2-core +libreadline
VARIANT:=v3
USERID:=nfs:nfs
CONFLICTS:=nfs-kernel-server-v4
@@ -73,7 +73,7 @@ endef
define Package/nfs-utils
$(call Package/nfs-utils/Default)
TITLE:=NFS mount and umount utils (NFSv3)
DEPENDS:=+libtirpc
DEPENDS:=+libtirpc +libuuid
CONFLICTS:=nfs-utils-v4
VARIANT:=v3
endef
@@ -85,7 +85,7 @@ endef
define Package/nfs-utils-v4
$(call Package/nfs-utils/Default)
TITLE:=NFS mount and umount utils (NFSv4.x)
DEPENDS:=+libtirpc +libkeyutils +libdevmapper
DEPENDS:=+libtirpc +libuuid +libkeyutils +libdevmapper
VARIANT:=v4
PROVIDES:=nfs-utils
endef
@@ -133,7 +133,8 @@ ifeq ($(BUILD_VARIANT),v3)
--disable-nfsv4server \
--disable-nfsv4 \
--disable-nfsv41 \
--disable-nfsv42
--disable-nfsv42 \
--enable-nfsdctl
endif
ifeq ($(BUILD_VARIANT),v4)
@@ -191,7 +192,7 @@ HOST_CONFIGURE_VARS += \
RPCSECGSS_LIBS=" " \
ac_cv_lib_event_core_event_base_dispatch=yes \
ac_cv_header_event2_event_h=yes \
c_cv_lib_sqlite3_sqlite3_libversion_number=yes \
ac_cv_lib_sqlite3_sqlite3_libversion_number=yes \
libsqlite3_cv_is_recent=yes \
ac_cv_header_libdevmapper_h=yes \
ac_cv_lib_devmapper_dm_task_create=yes
@@ -207,9 +208,12 @@ endef
define Package/nfs-kernel-server/conffiles
/etc/exports
/etc/nfs.conf
endef
Package/nfs-kernel-server-v4/conffiles = $(Package/nfs-kernel-server/conffiles)
define Package/nfs-kernel-server-v4/conffiles
/etc/exports
endef
define Package/nfs-utils/InstallDev
$(INSTALL_DIR) $(1)/usr/include
@@ -222,18 +226,20 @@ endef
define Package/nfs-kernel-server/install
$(INSTALL_DIR) $(1)/etc/config $(1)/usr/sbin $(1)/etc/init.d
$(INSTALL_DATA) ./files/nfsd.v3.exports $(1)/etc/exports
$(INSTALL_DATA) ./files/nfsd.exports $(1)/etc/exports
$(INSTALL_DATA) ./files/nfsd.v3.nfs.conf $(1)/etc/nfs.conf
$(INSTALL_BIN) ./files/nfsd.v3.init $(1)/etc/init.d/nfsd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/statd/sm-notify $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/statd/statd $(1)/usr/sbin/rpc.statd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/nfsd/nfsd $(1)/usr/sbin/rpc.nfsd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/mountd/mountd $(1)/usr/sbin/rpc.mountd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/exportfs/exportfs $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/nfsdctl/nfsdctl $(1)/usr/sbin/
endef
define Package/nfs-kernel-server-v4/install
$(INSTALL_DIR) $(1)/etc/config $(1)/usr/sbin $(1)/etc/init.d
$(INSTALL_DATA) ./files/nfsd.v4.exports $(1)/etc/exports
$(INSTALL_DATA) ./files/nfsd.exports $(1)/etc/exports
$(INSTALL_BIN) ./files/nfsd.v4.init $(1)/etc/init.d/nfsd
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/statd/sm-notify $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/utils/nfsd/nfsd $(1)/usr/sbin/rpc.nfsd
@@ -3,5 +3,5 @@
# Example for NFSv3:
# /srv/home hostname1(rw,sync) hostname2(ro,sync)
# Example for NFSv4:
# /srv/nfs4 hostname1(rw,sync,fsid=0)
# /srv/nfs4 hostname1(rw,sync,fsid=0)
# /srv/nfs4/home hostname1(rw,sync,nohide)
@@ -1,4 +0,0 @@
# /etc/exports - exports(5) - directories exported to NFS clients
#
# Example for NFSv3:
# /srv/home hostname1(rw,sync) hostname2(ro,sync)
+20 -13
View File
@@ -6,41 +6,48 @@ START=99
STOP=60
USE_PROCD=1
CONFIG_FILE="/etc/config/nfsd"
NFS_D=/var/lib/nfs
RECOVERY_D=$NFS_D/v4recovery
LOCK_D=/var/lib/nfs/sm
VAR_NFS=/var/lib/nfs
start_service() {
logger -t "nfsd" -p notice "Starting the NFSV3 daemon"
logger -t "nfsd" -p notice "Starting the NFSv3 daemon"
grep -q /proc/fs/nfsd /proc/mounts || \
mount -t nfsd nfsd /proc/fs/nfsd
mkdir -p "$NFS_D" "$RECOVERY_D" "$LOCK_D" "$VAR_NFS"
chown nfs:nfs "$VAR_NFS"
mkdir -p "$NFS_D" "$LOCK_D"
chown nfs:nfs "$NFS_D"
touch "$NFS_D/rmtab"
sysctl -w fs.nfs.nlm_tcpport=32777 fs.nfs.nlm_udpport=32777 > /dev/null
procd_open_instance
procd_open_instance "statd"
procd_set_param command /usr/sbin/rpc.statd -p 32778 -o 32779 -F
procd_set_param respawn
procd_close_instance
/usr/sbin/exportfs -r
/usr/sbin/rpc.nfsd --grace-time 10
/usr/sbin/nfsdctl autostart || /usr/sbin/rpc.nfsd --grace-time 10 \
--no-nfs-version 4 --no-nfs-version 4.1 --no-nfs-version 4.2
procd_open_instance
procd_open_instance "mountd"
procd_set_param command /usr/sbin/rpc.mountd -p 32780 -F
procd_set_param respawn
procd_close_instance
}
stop_service() {
rpc.nfsd 0 2>/dev/null
/usr/sbin/nfsdctl threads 0 || /usr/sbin/rpc.nfsd 0 2>/dev/null
/usr/sbin/exportfs -au
/usr/sbin/exportfs -f
grep -q /proc/fs/nfsd /proc/mounts && umount /proc/fs/nfsd
}
service_triggers() {
export_dirs="$(while read -r mp _r; do echo "$mp "; done < /etc/exports)"
procd_add_reload_mount_trigger "$export_dirs"
reload_service() {
/usr/sbin/exportfs -r
}
service_triggers() {
local export_dir
for export_dir in $(awk 'NF && !/^#/ {print $1}' /etc/exports); do
procd_add_reload_mount_trigger "$export_dir"
done
}
@@ -0,0 +1,99 @@
#
# This is a general configuration for the
# NFS daemons and tools
#
[general]
# pipefs-directory=/var/lib/nfs/rpc_pipefs
#
[nfsrahead]
# nfs=15000
# nfs4=16000
#
[exports]
# rootdir=/export
#
[exportfs]
# debug=0
#
[gssd]
# verbosity=0
# rpc-verbosity=0
# use-memcache=0
# use-machine-creds=1
# use-gss-proxy=0
# avoid-dns=1
# allowed-enctypes=aes256-cts-hmac-sha384-192,aes128-cts-hmac-sha256-128,camellia256-cts-cmac,camellia128-cts-cmac,aes256-cts-hmac-sha1-96,aes128-cts-hmac-sha1-96
# context-timeout=0
# rpc-timeout=5
# keytab-file=/etc/krb5.keytab
# cred-cache-directory=
# preferred-realm=
# set-home=1
# upcall-timeout=30
# cancel-timed-out-upcalls=0
#
[lockd]
# port=0
# udp-port=0
#
[exportd]
# debug="all|auth|call|general|parse"
# manage-gids=n
# state-directory-path=/var/lib/nfs
# threads=1
# cache-use-ipaddr=n
# ttl=1800
#
[mountd]
# debug="all|auth|call|general|parse"
# apply-root-cred=n
# manage-gids=n
# descriptors=0
# port=0
# threads=1
# reverse-lookup=n
# state-directory-path=/var/lib/nfs
# ha-callout=
# cache-use-ipaddr=n
# ttl=1800
#
[nfsdcld]
# debug=0
# storagedir=/var/lib/nfs/nfsdcld
#
[nfsd]
# debug=0
# threads=16
# host=
# port=0
# grace-time=90
# lease-time=90
# udp=n
# tcp=y
vers3=y
vers4=n
vers4.0=n
vers4.1=n
vers4.2=n
# fh-key-file=/etc/nfs_fh.key
[statd]
# debug=0
# port=0
# outgoing-port=0
# name=
# state-directory-path=/var/lib/nfs/statd
# ha-callout=
# no-notify=0
#
[sm-notify]
# debug=0
# force=0
# retry-time=900
# outgoing-port=
# outgoing-addr=
# lift-grace=y
#
[svcgssd]
# principal=
+25 -6
View File
@@ -6,10 +6,8 @@ START=99
STOP=60
USE_PROCD=1
CONFIG_FILE="/etc/config/nfsd"
NFS_D=/var/lib/nfs
RPC_PIPEFS_D=/var/lib/nfs/rpc_pipefs
NFSDCLD_PID=/var/run/nfsdcld.pid
start_service() {
logger -t "nfsd" -p notice "Starting the NFSV4 daemon"
@@ -21,15 +19,16 @@ start_service() {
procd_open_instance
procd_set_param command /usr/sbin/nfsv4.exportd -f -L
procd_set_param respawn
procd_close_instance
procd_open_instance
procd_set_param command /usr/sbin/rpc.idmapd -f
procd_set_param respawn
procd_close_instance
procd_open_instance
procd_set_param command /usr/sbin/nfsdcld
procd_append_param -F
procd_close_instance
/usr/sbin/exportfs -r
@@ -51,7 +50,27 @@ stop_service() {
) &
}
service_triggers() {
export_dirs="$(while read -r mp _r; do echo "$mp "; done < /etc/exports)"
procd_add_reload_mount_trigger "$export_dirs"
status_service() {
local n_running=0
local n_total=3
pgrep -x nfsv4.exportd > /dev/null && n_running=$((n_running + 1))
pgrep -x rpc.idmapd > /dev/null && n_running=$((n_running + 1))
pgrep -x nfsdcld > /dev/null && n_running=$((n_running + 1))
if [ "$n_running" -eq "$n_total" ]; then
echo "running"
return 0
elif [ "$n_running" -gt 0 ]; then
echo "running ($n_running/$n_total)"
return 0
else
echo "not running"
return 1
fi
}
service_triggers() {
local export_dir
for export_dir in $(awk 'NF && !/^#/ {print $1}' /etc/exports); do
procd_add_reload_mount_trigger "$export_dir"
done
}
@@ -0,0 +1,23 @@
From 0097ceb136a7db15c535a78fca01e2814e82d2a7 Mon Sep 17 00:00:00 2001
From: Giulio Benetti <giulio.benetti@benettiengineering.com>
Date: Fri, 15 May 2026 08:05:10 -0400
Subject: [PATCH] fh_key_file: fix missing string.h inclusion
Add #include <string.h> to fix build failure.
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfs/fh_key_file.c | 1 +
1 file changed, 1 insertion(+)
--- a/support/nfs/fh_key_file.c
+++ b/support/nfs/fh_key_file.c
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
+#include <string.h>
#include <uuid/uuid.h>
#include "nfslib.h"
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
# shellcheck shell=busybox
# The NFS utilities (sm-notify, rpc.nfsd, rpc.mountd, etc.) do not reliably
# report the package version in a way the generic CI probe can detect, and
# several require kernel/netlink support unavailable in the sandbox.
# Functionality is exercised by the companion test.sh.
case "$PKG_NAME" in
nfs-kernel-server|\
nfs-kernel-server-v4|\
nfs-kernel-server-utils|\
nfs-utils|\
nfs-utils-v4)
exit 0
;;
*)
echo "Untested package: $PKG_NAME" >&2
exit 1
;;
esac