2 RCSID='$Revision: 12159 $ $Date: 2011-02-17 23:16:30 +0100 (czw) $'
6 # if we should init NFS at boot
9 # return true if node is nfs
10 # @param string $node device node to be examined
15 if is_yes "$(awk -vnode="$node" 'BEGIN { if (node ~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/) print "yes" }')"; then
22 # find modules for for nfs
27 if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ]; then
28 die "root on NFS but /usr/bin/pcidev not found. Please install correct pci-database package and rerun $PROGRAM."
31 if [ ! -f /proc/bus/pci/devices ]; then
32 warn "Remember to add network card modules in /etc/sysconfig/geninitrd, example:"
33 warn "BASICMODULES=\"e1000 ne2k-pci mii 8139too 3c59x\""
36 [ -z "$NFS_ETH_MODULES" ] && NFS_ETH_MODULES=$(/usr/bin/pcidev /m net | xargs)
37 msg "NOTE: Network card(s) module(s) $NFS_ETH_MODULES is for this machine"
38 for m in $NFS_ETH_MODULES; do
46 warn "Remember to use \`root=/dev/ram0 init=/linuxrc' when starting kernel"
47 warn "or you will have problems like init(xx) being child process of swapper(1)."
50 # generate initrd fragment
53 if ! is_yes "$have_nfs"; then
57 # use root=/dev/ram0 init=/linuxrc when starting kernel or you will
58 # have problems like init(XX) being child process of swapper(1).
59 debug "Adding rootfs on NFS support to initrd (dhcp)"
60 mknod "$DESTDIR/dev/urandom" c 1 9
61 mkdir "$DESTDIR/newroot"
63 ifconfig lo 127.0.0.1 up
64 route add -net 127.0.0.0 mask 255.0.0.0 lo
66 udhcpc -i eth0 -f -q -s /bin/setdhcp
70 [ -x /sbin/chroot ] && exec /sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1
73 cat <<-'EOF' > "$DESTDIR/bin/setdhcp"
75 [ "$1" != "bound" ] && exit
76 [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
77 [ -n "$subnet" ] && NETMASK="netmask $subnet"
78 ifconfig $interface $ip $BROADCAST $NETMASK up
79 if [ -n "$router" ]; then
81 route add default gw $r dev $interface
85 if [ -n "$hostname" ]; then
92 rootpath=${o#nfsroot=}
97 if [ -n "$rootpath" ]; then
98 mount -n -t nfs -o ro,nolock,posix,tcp,wsize=8192,rsize=8192 $rootpath /newroot
100 echo "Missing rootpath in what DHCP server sent to us. Failing..."
101 echo "All seen variables are listed below:"
106 chmod 755 "$DESTDIR/bin/setdhcp"