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