summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hooks/net72
-rw-r--r--init11
-rw-r--r--install/net11
3 files changed, 88 insertions, 6 deletions
diff --git a/hooks/net b/hooks/net
new file mode 100644
index 0000000..9b97e39
--- /dev/null
+++ b/hooks/net
@@ -0,0 +1,72 @@
+# vim: set ft=sh:
+run_hook ()
+{
+ local line i address rootserver rootpath
+
+ : > /ip_opts
+
+ if [ -n "${ip}" ]; then
+ # setup network and save some values
+ ipconfig "${ip}" | while read line; do
+ # echo ":: ${line}"
+ if [ "${line#"IP-Config:"}" != "${line}" ]; then
+ continue
+ fi
+ line="$(echo ${line} | sed -e 's/ :/:/g;s/: /=/g')"
+ for i in ${line}; do
+ case "${i}" in
+ address=*)
+ echo "${i}" >> /ip_opts
+ ;;
+ netmask=*)
+ echo "${i}" >> /ip_opts
+ ;;
+ gateway=*)
+ echo "${i}" >> /ip_opts
+ ;;
+ dns0=*)
+ echo "${i}" >> /ip_opts
+ ;;
+ dns1=*)
+ echo "${i}" >> /ip_opts
+ ;;
+ rootserver=*)
+ echo "${i}" >> /ip_opts
+ ;;
+ rootpath=*)
+ echo "${i}" >> /ip_opts
+ ;;
+ esac
+ done
+ done
+
+ . /ip_opts
+
+ echo "IP-Config: ${address}/${netmask}"
+ echo "IP-Config: gw: ${gateway} dns0: ${dns0} dns1: ${dns1}"
+
+ # calculate nfs_server, nfs_path and nfs_option for later nfs mount
+ if [ "${root}" = "/dev/nfs" -o "${nfsroot}" != "" ]; then
+ # default rootpath
+ if [ "${rootpath}" = "" ]; then
+ rootpath="/tftpboot/${address}"
+ fi
+
+ # parse nfsroot
+ line="${nfsroot}"
+ nfs_server="${line%%:*}"
+ [ "${nfs_server}" = "${line}" ] && nfs_server="${rootserver}"
+ line="${line#*:}"
+ nfs_path="${line%%,*}"
+ line="${line#"${nfs_path}"}"
+ [ "${nfs_path}" = "" ] && nfs_path="${rootpath}"
+ nfs_option="${line#","}"
+
+ # ensure root and filesystem type are set proper for nfs boot
+ root="/dev/nfs"
+ rootfstype="nfs"
+
+ echo "NFS-root: ${nfs_server}:${nfs_path}"
+ fi
+ fi
+}
diff --git a/init b/init
index 88cefc1..05ec3d5 100644
--- a/init
+++ b/init
@@ -160,8 +160,15 @@ if [ -z "${nfsroot}" -a "${root}" != "/dev/nfs" ]; then
fi
mount ${fstype:+-t ${fstype}} -o ro${rootflags:+,${rootflags}} "${root}" /new_root
else
- # TODO: Actually implement this
- err "Mounting NFS root is not implemented yet."
+ if [ -z "$nfs_server" -o -z "$nfs_path" ]; then
+ err "Unable to mount root filesystem over NFS: wrong parameters."
+ echo "You are being dropped to a recovery shell"
+ echo " Type 'reboot' to reboot"
+ echo " Type 'exit' to try and continue booting"
+ launch_interactive_shell
+ msg "Trying to continue (this will most likely fail) ..."
+ fi
+ nfsmount ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" /new_root
fi
umount /proc
umount /sys
diff --git a/install/net b/install/net
index 69359e9..7b31c09 100644
--- a/install/net
+++ b/install/net
@@ -6,7 +6,10 @@ install ()
BINARIES=""
FILES=""
- SCRIPT=""
+ SCRIPT="net"
+
+ add_binary "/lib/initcpio/ipconfig" "/bin/ipconfig"
+ add_binary "/lib/initcpio/nfsmount" "/bin/nfsmount"
}
help ()
@@ -97,10 +100,10 @@ cat<<HELPEOF
acdirmin = 30
acdirmax = 60
flags = hard, nointr, noposix, cto, ac
-
+
root=/dev/nfs
-
- If you don't use nfsroot= parameter you need to set root=/dev/nfs
+
+ If you don't use nfsroot= parameter you need to set root=/dev/nfs
to boot from a nfs root by autoconfiguration.
HELPEOF
}