[readonly/geninitrd/devel: 205/334] (Almost) working root on NFS support.
draenog
draenog at pld-linux.org
Sat Nov 2 19:28:45 CET 2013
commit 5c4cec756ddbb6f7143d08dbe5e2c90e1d1d1cdf
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sat Jun 5 19:32:30 2004 +0000
(Almost) working root on NFS support.
svn-id: @4147
geninitrd | 50 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 9 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index c109271..6e4641e 100755
--- a/geninitrd
+++ b/geninitrd
@@ -543,13 +543,14 @@ find_modules_for() {
if [ -z "$1" ]; then
echo "ERROR: no argument passed to find_modules_for()" >&2
exit
- elif is_yes "`echo "$1" | awk '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:/ { print "yes"; }'`"; then
- if [ ! -x /usr/bin/pcidev ] ; then
+ elif is_yes "`echo "$1" | awk '/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/ { print "yes"; }'`"; then
+ if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ] ; then
echo "ERROR: root on NFS but /usr/bin/pcidev not found." >&2
echo "Please install correct pci-database package and rerun $0." >&2
exit 1
fi
- for m in $(/usr/bin/pcidev /m net | xargs); do
+ [ -z "$NFS_ETH_MODULES" ] && NFS_ETH_MODULES=$(/usr/bin/pcidev /m net | xargs)
+ for m in $NFS_ETH_MODULES; do
findmodule "$m"
done
findmodule "-ipv4"
@@ -1027,17 +1028,48 @@ fi
if is_yes "$usenfs" ; then
[ -n "$verbose" ] && echo "Adding rootfs on NFS support to initrd (dhcp)"
- mkdir "$MNTIMAGE/newroot/"
+ mkdir "$MNTIMAGE/newroot"
mkdir "$MNTIMAGE/newroot/initrd"
mkdir "$MNTIMAGE/newroot/dev"
mknod "$MNTIMAGE/newroot/dev/console" c 5 1
mknod "$MNTIMAGE/newroot/dev/null" c 1 3
mknod "$MNTIMAGE/newroot/dev/zero" c 1 5
- echo "busybox udhcpc" >> "$s"
- echo "mount -n -t nfs -o ro $rootdev1 /newroot" >> "$s"
- echo "cd /new_root" >> "$s"
- echo "pivot_root /new_root /new_root/initrd" >> "$s"
- echo "exec chroot . /sbin/init" >> "$s"
+ echo "ifconfig lo 127.0.0.1 up" >> "$s"
+ echo "route add -net 127.0.0.0 netmask 255.0.0.0 lo" >> "$s"
+ echo "ifconfig eth0 0.0.0.0 up" >> "$s"
+ echo "busybox udhcpc -i eth0 -s /bin/setdhcp" >> "$s"
+ cat << EOF > "$MNTIMAGE/bin/setdhcp"
+#!/bin/sh
+[ "\$1" != "bound" ] && exit
+[ -n "\$broadcast" ] && BROADCAST="broadcast \$broadcast"
+[ -n "\$subnet" ] && NETMASK="netmask \$subnet"
+set -x
+ifconfig \$interface \$ip \$BROADCAST \$NETMASK up
+set +x
+if [ -n "\$router" ]; then
+ for r in \$router; do
+ set -x
+ route add default gw \$r dev \$interface
+ set +x
+ done
+fi
+if [ -n "\$rootpath" ]; then
+ set -x
+ mount -n -t nfs -o ro,nolock \$rootpath /newroot
+ set +x
+else
+ set +x
+ echo "Missing rootpath in what DHCP server sent to us. Failing..."
+ echo "All seen variables are listed below:"
+ set
+ set -x
+fi
+EOF
+ chmod 755 "$MNTIMAGE/bin/setdhcp"
+ echo "cd /newroot" >> "$s"
+ echo "pivot_root /newroot /newroot/initrd" >> "$s"
+ echo "exec /usr/sbin/chroot . /sbin/init" >> "$s"
+ echo "echo CRITICAL PROBLEM - BOOT FAILED" >> "$s"
fi
if is_yes "$uselvm" ; then
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/398807324938659207036e520c0950a61ef50c11
More information about the pld-cvs-commit
mailing list