* [RFC PATCH 1/5] dracut-funtions: fix 'instmods =modname'
[not found] ` <cover.1243053563.git.dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
@ 2009-05-23 2:12 ` David Dillow
2009-05-23 2:16 ` [RFC PATCH 2/5] dracut: fix fallback to default configuration file David Dillow
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Dillow @ 2009-05-23 2:12 UTC (permalink / raw)
Move srcmods definition into the function, as $kernel isn't defined yet when
dracut-functions is sourced from dracut.
Signed-off-by: David Dillow <dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
---
dracut-functions | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/dracut-functions b/dracut-functions
index 2beaef2..36f1a96 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -202,9 +202,9 @@ dracut_install() {
}
# install modules, and handle installing all their dependencies as well.
-srcmods="/lib/modules/$kernel/"
instmods() {
local mod mpargs modpath modname cmd
+ local srcmods="/lib/modules/$kernel/"
while (($# > 0)); do
mod=${1%.ko}
case $mod in
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH 2/5] dracut: fix fallback to default configuration file
[not found] ` <cover.1243053563.git.dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
2009-05-23 2:12 ` [RFC PATCH 1/5] dracut-funtions: fix 'instmods =modname' David Dillow
@ 2009-05-23 2:16 ` David Dillow
2009-05-23 2:29 ` [RFC PATCH 3/5] lib: create a library for useful shell functions David Dillow
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Dillow @ 2009-05-23 2:16 UTC (permalink / raw)
Need to do the fallback in a list rather than a subshell, or we never
actually set $conffile.
Signed-off-by: David Dillow <dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
---
dracut | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/dracut b/dracut
index 0170fbb..0cf00c6 100755
--- a/dracut
+++ b/dracut
@@ -57,7 +57,7 @@ while (($# > 0)); do
shift
done
-[[ -f $conffile ]] || ( [[ -f /etc/dracut.conf ]] && conffile="/etc/dracut.conf" )
+[[ -f $conffile ]] || { [[ -f /etc/dracut.conf ]] && conffile="/etc/dracut.conf" }
[[ -f $conffile ]] && . "$conffile"
[[ $dracutmodules_l ]] && dracutmodules=$dracutmodules_l
[[ $omit_dracutmodules_l ]] && omit_dracutmodules=$omit_dracutmodules_l
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH 3/5] lib: create a library for useful shell functions
[not found] ` <cover.1243053563.git.dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
2009-05-23 2:12 ` [RFC PATCH 1/5] dracut-funtions: fix 'instmods =modname' David Dillow
2009-05-23 2:16 ` [RFC PATCH 2/5] dracut: fix fallback to default configuration file David Dillow
@ 2009-05-23 2:29 ` David Dillow
2009-05-23 2:43 ` [RFC PATCH 4/5] network: prepare network configuration engine for udev-based nfsroot David Dillow
2009-05-23 2:53 ` [RFC PATCH 5/5] nfsroot: mount NFS root from udev rules David Dillow
4 siblings, 0 replies; 6+ messages in thread
From: David Dillow @ 2009-05-23 2:29 UTC (permalink / raw)
There are several snippits of shell code that are useful to multiple
scripts. Start by moving getarg() into the library.
Signed-off-by: David Dillow <dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
---
modules.d/99base/dracut-lib | 16 ++++++++++++++++
modules.d/99base/init | 12 ++----------
modules.d/99base/install | 1 +
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/modules.d/99base/dracut-lib b/modules.d/99base/dracut-lib
new file mode 100644
index 0000000..1f31933
--- /dev/null
+++ b/modules.d/99base/dracut-lib
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Licensed under the GPLv2
+#
+# Copyright 2008, Red Hat, Inc.
+# Jeremy Katz <katzj-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
+
+getarg() {
+ local o line
+ [ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
+ for o in $CMDLINE; do
+ [ "$o" = "$1" ] && return 0
+ [ "${o%%=*}" = "${1%=}" ] && { echo ${o#*=}; return 0; }
+ done
+ return 1
+}
diff --git a/modules.d/99base/init b/modules.d/99base/init
index ac6a2d8..05cc4b7 100755
--- a/modules.d/99base/init
+++ b/modules.d/99base/init
@@ -14,15 +14,6 @@ emergency_shell()
sh -i
}
-getarg() {
- local o line
- for o in $CMDLINE; do
- [ "$o" = "$1" ] && return 0
- [ "${o%%=*}" = "${1%=}" ] && { echo ${o#*=}; return 0; }
- done
- return 1
-}
-
source_all() {
local f
[ "$1" ] && [ -d "/$1" ] || return
@@ -35,6 +26,8 @@ NEWROOT="/sysroot"
trap "emergency_shell" 0
+. /lib/dracut-lib
+
mknod /dev/null c 1 3
# mount some important things
@@ -42,7 +35,6 @@ mount -t proc /proc /proc >/dev/null 2>&1
mount -t sysfs /sys /sys >/dev/null 2>&1
mount -t tmpfs -omode=0755 udev /dev >/dev/null 2>&1
-read CMDLINE </proc/cmdline;
getarg ramfsdebug && set -x
# Make some basic devices first, let udev handle the rest
mknod /dev/null c 1 3
diff --git a/modules.d/99base/install b/modules.d/99base/install
index 00436ae..ce1e2f9 100755
--- a/modules.d/99base/install
+++ b/modules.d/99base/install
@@ -9,4 +9,5 @@ if [ ! -x "$moddir/switch_root" ]; then
exit 1
fi
inst "$moddir/switch_root" "/sbin/switch_root"
+inst "$moddir/dracut-lib" "/lib/dracut-lib"
inst_hook pre-pivot 50 "$moddir/selinux-loadpolicy.sh"
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH 4/5] network: prepare network configuration engine for udev-based nfsroot
[not found] ` <cover.1243053563.git.dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
` (2 preceding siblings ...)
2009-05-23 2:29 ` [RFC PATCH 3/5] lib: create a library for useful shell functions David Dillow
@ 2009-05-23 2:43 ` David Dillow
2009-05-23 2:53 ` [RFC PATCH 5/5] nfsroot: mount NFS root from udev rules David Dillow
4 siblings, 0 replies; 6+ messages in thread
From: David Dillow @ 2009-05-23 2:43 UTC (permalink / raw)
This changes the network config to run dhclient from within udev, and
allows multiple dhclients to run at once. It also sets the hostname and
adds a kernel command line option 'netdebug' to help debug network issues.
This an RFC patch, as I've not tested it since porting to the current
dracut (it worked in HEAD as of April, though).
---
modules.d/40network/dhclient-script | 98 ++++++++++++++++----
modules.d/40network/ifup | 124 +++++++++++++++++++++-----
modules.d/40network/install | 3 +-
modules.d/40network/kill-dhclient.sh | 5 +-
modules.d/40network/run-dhclient.sh | 9 --
5 files changed, 182 insertions(+), 57 deletions(-)
diff --git a/modules.d/40network/dhclient-script b/modules.d/40network/dhclient-script
index 895ed1b..7689e04 100755
--- a/modules.d/40network/dhclient-script
+++ b/modules.d/40network/dhclient-script
@@ -1,27 +1,85 @@
-#!/bin/sh
+#!/bin/sh -e
# very simple dhclient-script. All it cares about is bringing the interface
# up, and it does not even try to do anything else.
-case $reason in
- PREINIT) /sbin/ip link set "$interface" up ;;
- BOUND) ipopts="$new_ip_address"
- [ "$new_interface_mtu" ] && ip link set $interface mtu $new_interface_mtu
- [ "$new_subnet_mask" ] && ipopts="$ipopts/$new_subnet_mask"
- [ "$new_broadcast_address" ] && ipopts="$ipopts broadcast $new_broadcast_address"
- /sbin/ip addr add $ipopts dev $interface
- [ "$new_routers" ] && /sbin/ip route add default via ${new_routers%%,*} dev $interface
- [ "$new_domain_name" ] && echo "domain $new_domain_name" > /etc/resolv.conf
- if [ "$new_domain_search" ]; then
- echo "search $new_domain_search" |sed 's/,//g' >> /etc/resolv.conf
- elif [ "$new_domain_name" ]; then
- echo "search $new_domain_name" >> /etc/resolv.conf
- fi
- for s in $new_domain_name_servers; do
- echo "nameserver $s" >> /etc/resolv.conf
+LOG=/dhclient.$$.log
+ERR=/network.$$.err
+PATH=$PATH:/sbin:/usr/sbin
+
+. /lib/dracut-lib
+
+getarg netdebug && {
+ exec >/dhclient.$interface.$$.out
+ exec 2>>/dhclient.$interface.$$.out
+ set -x
+}
+
+log_err() {
+ # avoid the need for cat on the image
+ echo "On $netif, the following command:" > $ERR
+ echo " " "$CMD" >> $ERR
+ echo "had errors:" >> $ERR
+ while read line; do echo " $line"; done < $LOG >> $ERR
+}
+
+# Catch unlikely initial errors
+trap 'echo Errors preparing to configure $netif > $ERR; exit 0' EXIT
+
+netif=$interface
+ip=$new_ip_address
+mtu=$new_interface_mtu
+mask=$new_subnet_mask
+bcast=$new_broadcast_address
+gw=${new_routers%%,*}
+domain=$new_domain_name
+search=$new_domain_search
+namesrv=$new_domain_name_servers
+hostname=$new_host_name
+
+[ -f /net.$interface.override ] && . /net.$interface.override
+
+# save the offending command and let udev move on if we have an error
+trap 'log_err; exit 0' EXIT
+
+run() {
+ CMD="$@"
+ "$@" >> $LOG 2>&1
+}
+
+setup_interface() {
+ [ -n "$mtu" ] && {
+ run ip link set $netif down
+ run ip link set $netif mtu $mtu
+ run ip link set $netif up
+ }
+
+ run ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif
+ [ -n "$gw" ] && run ip route add default via $gw
+ [ -n "${search}${domain}" -a -n "$namesrv" ] && {
+ echo search $search $domain > /etc/resolv.conf
+ for s in $namesrv; do
+ echo nameserver $s >> /etc/resolv.conf
done
- set |grep -E '^new_[a-z_]+=' |while read line; do
- echo "${line%%=*}='${line#*=}'">>/net.$interface.dhcpopts
+ }
+ [ -e /hostname.set ] || {
+ [ -n "$hostname" ] && mknod /hostname.set p && run hostname $hostname
+ }
+}
+
+case $reason in
+ PREINIT)
+ run /sbin/ip link set $netif up
+ ;;
+ BOUND)
+ setup_interface
+ set | while read line; do
+ [ "${line#new_}" = "$line" ] && continue
+ echo "$line" >>/net.$netif.dhcpopts
done
- >/net.$interface.up ;;
+ >/net.$netif.up
+ echo online > /sys/class/net/$netif/uevent ;;
*) ;;
esac
+
+trap - EXIT
+exit 0
diff --git a/modules.d/40network/ifup b/modules.d/40network/ifup
index 744a2ae..284c9df 100755
--- a/modules.d/40network/ifup
+++ b/modules.d/40network/ifup
@@ -1,36 +1,112 @@
#!/bin/sh
+PATH=$PATH:/sbin:/usr/sbin
+
+. /lib/dracut-lib
+
+getarg netdebug && {
+ exec >/ifup.$1.$$.out
+ exec 2>>/ifup.$1.$$.out
+ set -x
+}
+
+netif=$1
+
# bail immediatly if the interface is already up
-[ -f "/net.$1.up" ] && exit 0
+[ -f "/net.$netif.up" ] && exit 0
# loopback is always handled the same way
-[ "$1" = "lo" ] && {
- /sbin/ip link set lo up
- /sbin/ip addr add 127.0.0.1/8 dev lo
+[ "$netif" = "lo" ] && {
+ ip link set lo up
+ ip addr add 127.0.0.1/8 dev lo
+ >/net.$netif.up
exit 0
}
+# XXX need error handling like dhclient-script
+
+die() {
+ echo $netif: "$@" 1>&2
+ exit 1
+}
+
+do_static() {
+ [ -n "$ip" ] || die "static: need IP address"
+ [ -n "$mask" ] || {
+ net=${ip%%.*}
+ mask=255.0.0.0
+ [ $net -ge 128 ] && mask=255.255.0.0
+ [ $net -ge 192 ] && mask=255.255.255.0
+ }
+ ip addr add $ip/$mask dev $netif || die "static: setting IP $ip/$mask"
+ [ -n "$gw" ] && {
+ ip route add default via $gw dev $netif ||
+ die "static: setting default route via $gw"
+ }
+ ip link set $netif up
+ [ -e /hostname.set ] || {
+ [ -n "$hostname" ] && mknod /hostname.set p 2>/dev/null &&
+ hostname $hostname
+ }
+ [ -n "$srv" ] &&
+ echo "new_dhcp_server_identifier=$srv" > /net.$netif.dhcpopts
+
+ >/net.$netif.up
+ echo online > /sys/class/net/$netif/uevent
+}
+
+do_dhcp() {
+ reqs=subnet-mask,broadcast-address,routers,domain-name
+ reqs=${reqs},domain-name-servers,domain-search
+ reqs=${reqs},host-name,root-path,interface-mtu
+
+ for i in ip srv gw mask hostname; do
+ eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
+ done > /net.$netif.override
+ [ -n "$ip" ] && echo bcast= >> /net.$netif.override
+
+ # /sbin/dhclient-script will mark the netif up and generate the online
+ # event for nfsroot
+ # XXX add -V vendor class and option parsing per kernel
+ dhclient -1 -q -R ${reqs} -pf /dhclient.$netif.pid $netif
+}
+
+ip_to_var() {
+ local v=${1}:
+ set --
+ while [ -n "$v" ]; do
+ set -- "$@" "${v%%:*}"
+ v=${v#*:}
+ done
+
+ unset ip srv gw mask hostname dev autoconf
+ case $# in
+ 0) autoconf=off ;;
+ 1) autoconf=$1 ;;
+ 2) dev=$1; autoconf=$2 ;;
+ *) ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7
+ case $autoconf in
+ ''|none|off) [ -n "$ip" ] && autoconf=static ;;
+ esac
+ esac
+ [ -n "$dev" ] || dev=$netif
+ [ -n "$autoconf" ] || autoconf=off
+}
+
# spin through the kernel command line, looking for ip= lines
for p in $(cat /proc/cmdline); do
- [ "${p%%=*}" = "ip" ] || continue
- ip=${p#ip=}
- case $ip in
- none|off) exit 0;; # we were told to not configure anything
- dhcp|on|any) >/net.$1.dhcp; exit 0;;
- bootp|rarp|both) exit 0;; #dunno how to do this
- *) echo ${ip} | \
- (IFS=':' read client server gw netmask hostname device autoconf
- if [ -z "$device" -o "$device" = "$1" ]; then
- case $autoconf in
- dhcp|on|any) >/net.$1.dhcp ;;
- none|off|'') # do some basic configuration
- /sbin/ip link set $1 up
- /sbin/ip addr add $client/$netmask dev $1
- [ "$gw" ] && /sbin/ip route add default via $gw dev $1
- >/net.$1.up ;;
- esac
- fi
- ) ;;
- *) continue;;
+ [ -n "${p%ip=*}" ] && continue
+ ip_to_var ${p#ip=}
+
+ # If this option isn't directed at our interface, skip it
+ [ "$dev" = "$netif" ] || continue
+
+ case $autoconf in
+ static) do_static ;;
+ dhcp|on|any) do_dhcp ;;
+ bootp|rarp|both) die "autoconfig type $autoconf is not supported" ;;
+ ''|none|off) ;;
esac
+ break
done
+exit 0
diff --git a/modules.d/40network/install b/modules.d/40network/install
index c0c13fc..7a13348 100755
--- a/modules.d/40network/install
+++ b/modules.d/40network/install
@@ -1,10 +1,9 @@
#!/bin/bash
-dracut_install ip dhclient grep
+dracut_install ip dhclient hostname
instmods ${modules:-=net}
inst "$moddir/ifup" "/sbin/ifup"
inst "$moddir/dhclient-script" "/sbin/dhclient-script"
instmods =networking ecb arc4
inst_rules "$moddir/60-net.rules"
inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"
-inst_hook pre-mount 70 "$moddir/run-dhclient.sh"
mkdir -p "${initdir}/var/run"
diff --git a/modules.d/40network/kill-dhclient.sh b/modules.d/40network/kill-dhclient.sh
index 70deda6..d1d15f4 100755
--- a/modules.d/40network/kill-dhclient.sh
+++ b/modules.d/40network/kill-dhclient.sh
@@ -1,4 +1,5 @@
#!/bin/sh
-pid=$(pidof dhclient)
-[ -n "$pid" ] && kill $pid
+for f in /dhclient.*.pid; do
+ [ "$f" != "/dhclient.*.pid" ] && kill $(cat $f)
+done
diff --git a/modules.d/40network/run-dhclient.sh b/modules.d/40network/run-dhclient.sh
deleted file mode 100755
index bc32883..0000000
--- a/modules.d/40network/run-dhclient.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-for i in /net.*.dhcp; do
- [ "$i" = '/net.*.dhcp' ] && break
- dev=${i#/net.}; dev=${dev%.dhcp}
- [ -f "/net.$dev.up" ] && continue
- dhclient -R 'subnet-mask,broadcast-address,time-offset,routers,domain-name,domain-name-servers,host-name,nis-domain,nis-servers,ntp-servers,root-path' -1 -q $dev &
-done
-wait
-
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH 5/5] nfsroot: mount NFS root from udev rules
[not found] ` <cover.1243053563.git.dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
` (3 preceding siblings ...)
2009-05-23 2:43 ` [RFC PATCH 4/5] network: prepare network configuration engine for udev-based nfsroot David Dillow
@ 2009-05-23 2:53 ` David Dillow
4 siblings, 0 replies; 6+ messages in thread
From: David Dillow @ 2009-05-23 2:53 UTC (permalink / raw)
Work-in-progress to mount NFS root from udev, using the DHCP options and
allowing an override from the kernel command line. Supports NFSv4 w/locking
and NFSv2/v3 with nolock.
This is just an RFC patch, you'll note all the XXX markings where I've been
thinking about how to best do things. In addition, we really want to retry
DHCP and NFS mounting in a loop, in case the servers are down or overloaded
like when booting a full diskless cluster.
---
dracut | 5 +-
modules.d/40nfsroot/60-nfsroot.rules | 1 +
modules.d/40nfsroot/check | 5 +
modules.d/40nfsroot/install | 27 +++++
modules.d/40nfsroot/nfsroot | 125 ++++++++++++++++++++++++
modules.d/40nfsroot/nfsroot-cleanup.sh | 9 ++
6 files changed, 171 insertions(+), 1 deletions(-)
diff --git a/dracut b/dracut
index 0cf00c6..4c06588 100755
--- a/dracut
+++ b/dracut
@@ -99,10 +99,13 @@ hookdirs="pre-udev pre-mount pre-pivot mount emergency"
readonly initdir=$(mktemp -d -t initramfs.XXXXXX)
trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.
+# Need to be able to have non-root users read stuff (rpcbind etc)
+chmod 755 "$initdir"
+
export initdir hookdirs dsrc dracutmodules modules debug beverbose
# Create some directory structure first
-for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do
+for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts var/run; do
mkdir -p "$initdir/$d";
done
diff --git a/modules.d/40nfsroot/60-nfsroot.rules b/modules.d/40nfsroot/60-nfsroot.rules
new file mode 100644
index 0000000..99a2acf
--- /dev/null
+++ b/modules.d/40nfsroot/60-nfsroot.rules
@@ -0,0 +1 @@
+ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/nfsroot $env{INTERFACE}"
diff --git a/modules.d/40nfsroot/check b/modules.d/40nfsroot/check
new file mode 100755
index 0000000..b7378c3
--- /dev/null
+++ b/modules.d/40nfsroot/check
@@ -0,0 +1,5 @@
+#!/bin/sh
+#
+# This is not a module that should be selected when we try to
+# autoconfigure the initrd
+exit 1
diff --git a/modules.d/40nfsroot/install b/modules.d/40nfsroot/install
new file mode 100755
index 0000000..965c63c
--- /dev/null
+++ b/modules.d/40nfsroot/install
@@ -0,0 +1,27 @@
+#!/bin/sh
+dracut_install rpcbind rpc.statd mount.nfs mount.nfs4
+dracut_install /etc/netconfig /etc/passwd /etc/services
+
+# XXX debug stuff
+dracut_install rpcinfo ping strace dmesg nc free df
+
+dracut_install rpc.idmapd /etc/idmapd.conf
+
+instmods nfs
+inst_rules "$moddir/60-nfsroot.rules"
+inst_hook pre-pivot 70 "$moddir/nfsroot-cleanup.sh"
+inst "$moddir/nfsroot" "/sbin/nfsroot"
+mkdir -p "$initdir/var/lib/nfs/rpc_pipefs"
+mkdir -p "$initdir/var/lib/rpcbind"
+mkdir -p "$initdir/var/lib/nfs/statd/sm"
+
+# XXX debug
+mkdir -p "$initdir/mnt"
+
+# Rather than copy the passwd file in, just set a user for rpcbind
+# We'll save the state and restart the daemon from the root anyway
+#echo "rpc:x:32:32:Rpcbind:/var/lib/rpcbind:/bin/false" >> "$initdir/etc/passwd"
+
+# rpc user needs to be able to write to this directory to save the warmstart
+# file
+chmod 777 "$initdir/var/lib/rpcbind"
diff --git a/modules.d/40nfsroot/nfsroot b/modules.d/40nfsroot/nfsroot
new file mode 100755
index 0000000..f5b6ec1
--- /dev/null
+++ b/modules.d/40nfsroot/nfsroot
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+. /lib/dracut-lib
+
+PATH=$PATH:/sbin:/usr/sbin
+
+# XXX needs error handling like ifup/dhclient-script
+
+# XXX need to lock our attempts if we're doing the mount here
+
+getarg netdebug && {
+ exec > /nfsroot.$1.$$.out
+ exec 2>> /nfsroot.$1.$$.out
+ set -x
+}
+
+[ "$NFS_LOCKED" ] || {
+ NFS_LOCKED=true
+ export NFS_LOCKED
+ exec flock -xo /nfs.lock -c "$0 $*"
+ exit 1
+}
+
+[ -e /nfsdone ] && exit 0
+
+nfs_done() {
+ >/nfsdone
+ exit 0
+}
+
+root=$(getarg root)
+case $root in
+ nfs|/dev/nfs) type=nfs ;;
+ nfs4|/dev/nfs4) type=nfs4 ;;
+ auto|'') type=auto ;;
+esac
+
+rootfstype=$(getarg rootfstype)
+case $rootfstype in
+ nfs|nfs4|auto) type=$rootfstype ;;
+esac
+
+# If we're not doing NFS at all, don't keep banging our head
+[ -n "$type" ] || nfs_done
+
+[ -e /net.$1.dhcpopts ] && . /net.$1.dhcpopts
+
+nfsroot=$(getarg nfsroot)
+[ -n "$nfsroot" ] || nfsroot="$new_root_path"
+[ -n "$nfsroot" ] || nfs_done
+
+# check for IP address at front, if there is none, use
+# new_dhcp_server_identifier
+#
+# XXX kernel nfsroot uses , to separate NFS options at end
+#
+nfsserver=${nfsroot%%:*}; nfsroot=${nfsroot#*:}
+nfspath=${nfsroot%%:*}
+flags=${nfsroot#*:}
+[ "$nfsserver" = "$nfspath" ] && nfsserver=$new_dhcp_server_identifier
+[ "$nfspath" = "$flags" ] && unset flags
+
+[ -n "$nfsserver" ] || no_nfs
+
+# look through the flags and see if any are overridden by the command line
+while [ -n "$flags" ]; do
+ f=${flags%%,*}; flags=${flags#*,}
+ [ "$f" = "nfs" -o "$f" = "nfs4" ] && {
+ [ "$type" = "auto" ] && type=$f
+ continue
+ }
+ [ "$f" = "ro" -o "$f" = "rw" ] && {
+ nfsrw=$f
+ continue
+ }
+ [ "$f" = "lock" -o "$f" = "nolock" ] && {
+ nfslock=$f
+ continue
+ }
+ nfsflags=${nfsflags+$nfsflags,}$f
+done
+
+getarg ro && nfsrw=ro
+getarg rw && nfsrw=rw
+nfsflags=${nfsflags+$nfsflags,}${nfsrw}
+
+# load our modules explicitly, so we can fail fast in the future
+modprobe nfs || nfs_done
+
+# XXX don't forget to move /var/lib/nfs/rpc_pipefs to new /
+# XXX need host name set before now?
+
+# Start rpcbind and rpc.statd as mount won't let us use locks on a NFSv4
+# filesystem without talking to them, even though they are unneeded
+# XXX occasionally saw 'rpcbind: fork failed: No such device' -- why?
+[ -n "$(pidof rpcbind)" ] || rpcbind
+[ -n "$(pidof rpc.statd)" ] || rpc.statd
+
+# XXX should I do rpc.idmapd here, or wait and start in the new root
+# XXX waiting assumes root can read everything it needs right up until
+# XXX we start it...
+
+# XXX really, want to retry in a loop I think, but not here...
+
+[ "$type" = "nfs4" -o "$type" = "auto" ] && {
+ # XXX really needed? Do we need non-root users before we start it in
+ # XXX the real root image?
+ [ -n "$(pidof rpc.idmapd)" ] || rpc.idmapd
+
+ # NFSv4 does locks internally
+ mount -t nfs4 -o${nfsflags}${nfslock+,$nfslock} \
+ $nfsserver:$nfspath /sysroot && nfs_done
+
+ # If we're specified to be NFSv4, then stop when we fail
+ # Don't mark us done, as this may be transient
+ [ "$type" = "nfs4" ] && exit 0
+}
+
+# we're NFSv{2,3} or auto and NFSv4 failed. We don't support using locks
+# on NFSv{2,3} because that requires a helper to transfer the rpcbind state
+# rpcbind to the new root
+[ -z "$nfslock" -o "$nfslock" = "lock" ] &&
+ echo "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
+mount -t nfs -onolock,$nfsflags $nfsserver:$nfspath /sysroot && nfs_done
+exit 0
diff --git a/modules.d/40nfsroot/nfsroot-cleanup.sh b/modules.d/40nfsroot/nfsroot-cleanup.sh
new file mode 100755
index 0000000..7bdec0a
--- /dev/null
+++ b/modules.d/40nfsroot/nfsroot-cleanup.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+pid=$(pidof rpc.statd)
+[ -n "$pid" ] && kill $pid
+
+pid=$(pidof rpcbind)
+[ -n "$pid" ] && kill $pid
+
+mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/var/lib/nfs/rpc_pipefs
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RFC PATCH 0/5] WIP: NFS root mount from udev rules
@ 2009-05-23 4:39 David Dillow
[not found] ` <cover.1243053563.git.dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: David Dillow @ 2009-05-23 4:39 UTC (permalink / raw)
This is my current patch queue for mount the NFS root via the udev rules.
It worked well when I stopped activity on it in mid-April, but I've not
tested it after porting to today's HEAD.
The first two patches are bug fixes, though Victor posted a different
fix to the default config file issue in his cleanup series.
Mainly, I'm looking to see what you guys think of the direction.
Thanks for any comments you care to share!
David Dillow (5):
dracut-funtions: fix 'instmods =XXX'
dracut: fix fallback to default configuration file
lib: create a library for useful shell functions
network: prepare network configuration engine for udev-based nfsroot
nfsroot: mount NFS root from udev rules
dracut | 7 +-
dracut-functions | 2 +-
modules.d/40network/dhclient-script | 98 +++++++++++++++----
modules.d/40network/ifup | 124 +++++++++++++++++++-----
modules.d/40network/install | 3 +-
modules.d/40network/kill-dhclient.sh | 5 +-
modules.d/40network/run-dhclient.sh | 9 --
modules.d/40nfsroot/60-nfsroot.rules | 1 +
modules.d/40nfsroot/check | 5 +
modules.d/40nfsroot/install | 27 +++++
modules.d/40nfsroot/nfsroot | 125 ++++++++++++++++++++++++
modules.d/40nfsroot/nfsroot-cleanup.sh | 9 ++
modules.d/99base/dracut-lib | 16 +++
modules.d/99base/init | 12 +--
modules.d/99base/install | 1 +
15 files changed, 374 insertions(+), 70 deletions(-)
delete mode 100755 modules.d/40network/run-dhclient.sh
create mode 100644 modules.d/40nfsroot/60-nfsroot.rules
create mode 100755 modules.d/40nfsroot/check
create mode 100755 modules.d/40nfsroot/install
create mode 100755 modules.d/40nfsroot/nfsroot
create mode 100755 modules.d/40nfsroot/nfsroot-cleanup.sh
create mode 100644 modules.d/99base/dracut-lib
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-05-23 4:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-23 4:39 [RFC PATCH 0/5] WIP: NFS root mount from udev rules David Dillow
[not found] ` <cover.1243053563.git.dave-i1Mk8JYDVaaSihdK6806/g@public.gmane.org>
2009-05-23 2:12 ` [RFC PATCH 1/5] dracut-funtions: fix 'instmods =modname' David Dillow
2009-05-23 2:16 ` [RFC PATCH 2/5] dracut: fix fallback to default configuration file David Dillow
2009-05-23 2:29 ` [RFC PATCH 3/5] lib: create a library for useful shell functions David Dillow
2009-05-23 2:43 ` [RFC PATCH 4/5] network: prepare network configuration engine for udev-based nfsroot David Dillow
2009-05-23 2:53 ` [RFC PATCH 5/5] nfsroot: mount NFS root from udev rules David Dillow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox