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