|
Harald Hoyer |
460d2c |
From 5f8063c6f2944fc93af5d6d800197e8c966ba70f Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
460d2c |
From: Kairui Song <kasong@redhat.com>
|
|
Harald Hoyer |
460d2c |
Date: Fri, 10 Apr 2020 20:50:49 +0800
|
|
Harald Hoyer |
460d2c |
Subject: [PATCH] 95nfs: only install rpc services for NFS < 4 when hostonly is
|
|
Harald Hoyer |
460d2c |
strict
|
|
Harald Hoyer |
460d2c |
|
|
Harald Hoyer |
460d2c |
Most rpc services are not needed for NFSv4, so skip these components
|
|
Harald Hoyer |
460d2c |
to save space. rpc.idmapd is still needed in case of
|
|
Harald Hoyer |
460d2c |
nfs4_disable_idmapping is set to 0.
|
|
Harald Hoyer |
460d2c |
---
|
|
Harald Hoyer |
460d2c |
modules.d/95nfs/module-setup.sh | 33 ++++++++++++++++++++++++++-------
|
|
Harald Hoyer |
460d2c |
modules.d/95nfs/nfs-start-rpc.sh | 6 ++----
|
|
Harald Hoyer |
460d2c |
2 files changed, 28 insertions(+), 11 deletions(-)
|
|
Harald Hoyer |
460d2c |
|
|
Harald Hoyer |
460d2c |
diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh
|
|
Harald Hoyer |
460d2c |
index f9bcedd1..d9a91fdf 100755
|
|
Harald Hoyer |
460d2c |
--- a/modules.d/95nfs/module-setup.sh
|
|
Harald Hoyer |
460d2c |
+++ b/modules.d/95nfs/module-setup.sh
|
|
Harald Hoyer |
460d2c |
@@ -1,5 +1,22 @@
|
|
Harald Hoyer |
460d2c |
#!/bin/bash
|
|
Harald Hoyer |
460d2c |
|
|
Harald Hoyer |
460d2c |
+# return value:
|
|
Harald Hoyer |
460d2c |
+# 'nfs4': Only nfs4 founded
|
|
Harald Hoyer |
460d2c |
+# 'nfs': nfs with version < 4 founded
|
|
Harald Hoyer |
460d2c |
+# '': No nfs founded
|
|
Harald Hoyer |
460d2c |
+get_nfs_type() {
|
|
Harald Hoyer |
460d2c |
+ local _nfs _nfs4
|
|
Harald Hoyer |
460d2c |
+
|
|
Harald Hoyer |
460d2c |
+ for fs in "${host_fs_types[@]}"; do
|
|
Harald Hoyer |
460d2c |
+ [[ "$fs" == "nfs" ]] && _nfs=1
|
|
Harald Hoyer |
460d2c |
+ [[ "$fs" == "nfs3" ]] && _nfs=1
|
|
Harald Hoyer |
460d2c |
+ [[ "$fs" == "nfs4" ]] && _nfs4=1
|
|
Harald Hoyer |
460d2c |
+ done
|
|
Harald Hoyer |
460d2c |
+
|
|
Harald Hoyer |
460d2c |
+ [[ "$_nfs" ]] && echo "nfs" && return
|
|
Harald Hoyer |
460d2c |
+ [[ "$_nfs4" ]] && echo "nfs4" && return
|
|
Harald Hoyer |
460d2c |
+}
|
|
Harald Hoyer |
460d2c |
+
|
|
Harald Hoyer |
460d2c |
# called by dracut
|
|
Harald Hoyer |
460d2c |
check() {
|
|
Harald Hoyer |
460d2c |
# If our prerequisites are not met, fail anyways.
|
|
Harald Hoyer |
460d2c |
@@ -7,11 +24,7 @@ check() {
|
|
Harald Hoyer |
460d2c |
require_binaries rpc.statd mount.nfs mount.nfs4 umount || return 1
|
|
Harald Hoyer |
460d2c |
|
|
Harald Hoyer |
460d2c |
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
|
Harald Hoyer |
460d2c |
- for fs in "${host_fs_types[@]}"; do
|
|
Harald Hoyer |
460d2c |
- [[ "$fs" == "nfs" ]] && return 0
|
|
Harald Hoyer |
460d2c |
- [[ "$fs" == "nfs3" ]] && return 0
|
|
Harald Hoyer |
460d2c |
- [[ "$fs" == "nfs4" ]] && return 0
|
|
Harald Hoyer |
460d2c |
- done
|
|
Harald Hoyer |
460d2c |
+ [[ "$(get_nfs_type)" ]] && return 0
|
|
Harald Hoyer |
460d2c |
return 255
|
|
Harald Hoyer |
460d2c |
}
|
|
Harald Hoyer |
460d2c |
return 0
|
|
Harald Hoyer |
460d2c |
@@ -77,8 +90,7 @@ cmdline() {
|
|
Harald Hoyer |
460d2c |
install() {
|
|
Harald Hoyer |
460d2c |
local _i
|
|
Harald Hoyer |
460d2c |
local _nsslibs
|
|
Harald Hoyer |
460d2c |
- inst_multiple -o portmap rpcbind rpc.statd mount.nfs \
|
|
Harald Hoyer |
460d2c |
- mount.nfs4 umount rpc.idmapd sed /etc/netconfig chmod "$tmpfilesdir/rpcbind.conf"
|
|
Harald Hoyer |
460d2c |
+ inst_multiple -o rpc.idmapd mount.nfs mount.nfs4 umount sed /etc/netconfig chmod "$tmpfilesdir/rpcbind.conf"
|
|
Harald Hoyer |
460d2c |
inst_multiple /etc/services /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/idmapd.conf
|
|
Harald Hoyer |
460d2c |
|
|
Harald Hoyer |
460d2c |
if [[ $hostonly_cmdline == "yes" ]]; then
|
|
Harald Hoyer |
460d2c |
@@ -106,6 +118,12 @@ install() {
|
|
Harald Hoyer |
460d2c |
inst_hook pre-udev 99 "$moddir/nfs-start-rpc.sh"
|
|
Harald Hoyer |
460d2c |
inst_hook cleanup 99 "$moddir/nfsroot-cleanup.sh"
|
|
Harald Hoyer |
460d2c |
inst "$moddir/nfsroot.sh" "/sbin/nfsroot"
|
|
Harald Hoyer |
460d2c |
+
|
|
Harald Hoyer |
460d2c |
+ # For strict hostonly, only install rpcbind for NFS < 4
|
|
Harald Hoyer |
460d2c |
+ if [[ $hostonly_mode != "strict" ]] || [[ "$(get_nfs_type)" != "nfs4" ]]; then
|
|
Harald Hoyer |
460d2c |
+ inst_multiple -o portmap rpcbind rpc.statd
|
|
Harald Hoyer |
460d2c |
+ fi
|
|
Harald Hoyer |
460d2c |
+
|
|
Harald Hoyer |
460d2c |
inst "$moddir/nfs-lib.sh" "/lib/nfs-lib.sh"
|
|
Harald Hoyer |
460d2c |
mkdir -m 0755 -p "$initdir/var/lib/nfs/rpc_pipefs"
|
|
Harald Hoyer |
460d2c |
mkdir -m 0770 -p "$initdir/var/lib/rpcbind"
|
|
Harald Hoyer |
460d2c |
@@ -121,5 +139,6 @@ install() {
|
|
Harald Hoyer |
460d2c |
chmod 770 "$initdir/var/lib/rpcbind"
|
|
Harald Hoyer |
460d2c |
grep -q '^rpc:' $dracutsysrootdir/etc/passwd \
|
|
Harald Hoyer |
460d2c |
&& grep -q '^rpc:' $dracutsysrootdir/etc/group
|
|
Harald Hoyer |
460d2c |
+
|
|
Harald Hoyer |
460d2c |
dracut_need_initqueue
|
|
Harald Hoyer |
460d2c |
}
|
|
Harald Hoyer |
460d2c |
diff --git a/modules.d/95nfs/nfs-start-rpc.sh b/modules.d/95nfs/nfs-start-rpc.sh
|
|
Harald Hoyer |
460d2c |
index 694e05e2..dadfd90a 100755
|
|
Harald Hoyer |
460d2c |
--- a/modules.d/95nfs/nfs-start-rpc.sh
|
|
Harald Hoyer |
460d2c |
+++ b/modules.d/95nfs/nfs-start-rpc.sh
|
|
Harald Hoyer |
460d2c |
@@ -1,8 +1,6 @@
|
|
Harald Hoyer |
460d2c |
#!/bin/sh
|
|
Harald Hoyer |
460d2c |
|
|
Harald Hoyer |
460d2c |
-
|
|
Harald Hoyer |
460d2c |
if modprobe sunrpc || strstr "$(cat /proc/filesystems)" rpc_pipefs; then
|
|
Harald Hoyer |
460d2c |
-
|
|
Harald Hoyer |
460d2c |
[ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \
|
|
Harald Hoyer |
460d2c |
mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
|
|
Harald Hoyer |
460d2c |
|
|
Harald Hoyer |
460d2c |
@@ -17,8 +15,8 @@ if modprobe sunrpc || strstr "$(cat /proc/filesystems)" rpc_pipefs; then
|
|
Harald Hoyer |
460d2c |
# Start rpc.statd as mount won't let us use locks on a NFSv4
|
|
Harald Hoyer |
460d2c |
# filesystem without talking to it. NFSv4 does locks internally,
|
|
Harald Hoyer |
460d2c |
# rpc.lockd isn't needed
|
|
Harald Hoyer |
460d2c |
- [ -z "$(pidof rpc.statd)" ] && rpc.statd
|
|
Harald Hoyer |
460d2c |
- [ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
|
|
Harald Hoyer |
460d2c |
+ command -v rpc.statd >/dev/null && [ -z "$(pidof rpc.statd)" ] && rpc.statd
|
|
Harald Hoyer |
460d2c |
+ command -v rpc.idmapd >/dev/null && [ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
|
|
Harald Hoyer |
460d2c |
else
|
|
Harald Hoyer |
460d2c |
warn 'Kernel module "sunrpc" not in the initramfs, or support for filesystem "rpc_pipefs" missing!'
|
|
Harald Hoyer |
460d2c |
fi
|
|
Harald Hoyer |
460d2c |
|