SVN: geninitrd/trunk: Makefile geninitrd mod-nfs.sh
glen
glen at pld-linux.org
Fri Apr 3 01:13:00 CEST 2009
Author: glen
Date: Fri Apr 3 01:13:00 2009
New Revision: 10294
Added:
geninitrd/trunk/mod-nfs.sh
Modified:
geninitrd/trunk/Makefile
geninitrd/trunk/geninitrd
Log:
- nfs modularized
Modified: geninitrd/trunk/Makefile
==============================================================================
--- geninitrd/trunk/Makefile (original)
+++ geninitrd/trunk/Makefile Fri Apr 3 01:13:00 2009
@@ -1,6 +1,6 @@
# when making release, make sure you do it as RELEASE document describes
VERSION := 10000.3
-MODS := ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb
+MODS := ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs
FILES_MODS := $(MODS:%=mod-%.sh)
FILES := Makefile geninitrd.sysconfig geninitrd functions $(FILES_MODS) geninitrd.8 geninitrd.8.xml ChangeLog
prefix := /usr
Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd (original)
+++ geninitrd/trunk/geninitrd Fri Apr 3 01:13:00 2009
@@ -45,9 +45,6 @@
# are /dev nodes already created from /proc/devices info?
proc_partitions=no
-# if we should init NFS at boot
-have_nfs=no
-
usage() {
uname_r=$(uname -r)
echo "usage: $PROGRAM [--version] [-v] [-f] [--ifneeded] [--preload <module>]"
@@ -480,26 +477,8 @@
return
fi
- if is_yes "`echo "$devpath" | 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
- die "root on NFS but /usr/bin/pcidev not found. Please install correct pci-database package and rerun $PROGRAM."
- fi
- if [ ! -f /proc/bus/pci/devices ]; then
- warn "Remember to add network card modules in /etc/sysconfig/geninitrd, example:"
- warn "BASICMODULES=\"e1000 ne2k-pci mii 8139too 3c59x\""
- else
- local m
- [ -z "$NFS_ETH_MODULES" ] && NFS_ETH_MODULES=$(/usr/bin/pcidev /m net | xargs)
- warn "NOTE: Network card(s) module(s) $NFS_ETH_MODULES is for this machine"
- for m in $NFS_ETH_MODULES; do
- find_module "$m"
- done
- fi
- find_module "-ipv4"
- find_module "nfs"
- have_nfs=yes
- warn "Remember to use \`root=/dev/ram0 init=/linuxrc' when starting kernel"
- warn "or you will have problems like init(xx) being child process of swapper(1)."
+ if is_nfs "$devpath"; then
+ find_modules_nfs "$devpath"
return
fi
@@ -709,55 +688,6 @@
EOF
}
-initrd_gen_nfs() {
- # use root=/dev/ram0 init=/linuxrc when starting kernel or you will
- # have problems like init(XX) being child process of swapper(1).
- debug "Adding rootfs on NFS support to initrd (dhcp)"
- mknod "$DESTDIR/dev/urandom" c 1 9
- mkdir "$DESTDIR/newroot"
- add_linuxrc <<-'EOF'
- ifconfig lo 127.0.0.1 up
- route add -net 127.0.0.0 mask 255.0.0.0 lo
- ifconfig eth0 up
- udhcpc -i eth0 -f -q -s /bin/setdhcp
-
- cd /newroot
- pivot_root . initrd
- [ -x /sbin/chroot ] && exec /sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1
- exec /usr/sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1
- EOF
-
- cat <<-'EOF' > "$DESTDIR/bin/setdhcp"
- #!/bin/sh
- [ "$1" != "bound" ] && exit
- [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
- [ -n "$subnet" ] && NETMASK="netmask $subnet"
- ifconfig $interface $ip $BROADCAST $NETMASK up
- if [ -n "$router" ]; then
- for r in $router; do
- route add default gw $r dev $interface
- done
- fi
-
- for o in $CMDLINE; do
- case $o in
- nfsroot=*)
- rootpath=${o#nfsroot=}
- ;;
- esac
- done
-
- if [ -n "$rootpath" ]; then
- mount -n -t nfs -o ro,nolock,posix,tcp,wsize=8192,rsize=8192 $rootpath /newroot
- else
- echo "Missing rootpath in what DHCP server sent to us. Failing..."
- echo "All seen variables are listed below:"
- set
- fi
- EOF
-
- chmod 755 "$DESTDIR/bin/setdhcp"
-}
initrd_gen_setrootdev() {
debug "Adding rootfs finding based on kernel cmdline root= option support."
@@ -860,7 +790,7 @@
. /etc/sysconfig/geninitrd
fi
-geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb
+geninitrd_load_mods ide luks multipath dmraid lvm md blkid udev tuxonice suspend fbsplash condecor bootsplash uvesafb nfs
while [ $# -gt 0 ]; do
case $1 in
Added: geninitrd/trunk/mod-nfs.sh
==============================================================================
--- (empty file)
+++ geninitrd/trunk/mod-nfs.sh Fri Apr 3 01:13:00 2009
@@ -0,0 +1,99 @@
+#!/bin/sh
+#
+# geninitrd mod: nfs
+
+# if we should init NFS at boot
+have_nfs=no
+
+# return true if node is nfs
+# @param string $node device node to be examined
+# @access public
+is_nfs() {
+ local node="$1"
+
+ if is_yes "`echo "$node" | awk '/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/ { print "yes"; }'`"; then
+ return 1
+ fi
+
+ return 0
+}
+
+# find modules for for nfs
+# @access public
+find_modules_nfs() {
+ local devpath="$1"
+
+ if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ]; then
+ die "root on NFS but /usr/bin/pcidev not found. Please install correct pci-database package and rerun $PROGRAM."
+ fi
+
+ if [ ! -f /proc/bus/pci/devices ]; then
+ warn "Remember to add network card modules in /etc/sysconfig/geninitrd, example:"
+ warn "BASICMODULES=\"e1000 ne2k-pci mii 8139too 3c59x\""
+ else
+ local m
+ [ -z "$NFS_ETH_MODULES" ] && NFS_ETH_MODULES=$(/usr/bin/pcidev /m net | xargs)
+ warn "NOTE: Network card(s) module(s) $NFS_ETH_MODULES is for this machine"
+ for m in $NFS_ETH_MODULES; do
+ find_module "$m"
+ done
+ fi
+ find_module "-ipv4"
+ find_module "nfs"
+
+ have_nfs=yes
+ warn "Remember to use \`root=/dev/ram0 init=/linuxrc' when starting kernel"
+ warn "or you will have problems like init(xx) being child process of swapper(1)."
+}
+
+# generate initrd fragment
+# @access public
+initrd_gen_nfs() {
+ # use root=/dev/ram0 init=/linuxrc when starting kernel or you will
+ # have problems like init(XX) being child process of swapper(1).
+ debug "Adding rootfs on NFS support to initrd (dhcp)"
+ mknod "$DESTDIR/dev/urandom" c 1 9
+ mkdir "$DESTDIR/newroot"
+ add_linuxrc <<-'EOF'
+ ifconfig lo 127.0.0.1 up
+ route add -net 127.0.0.0 mask 255.0.0.0 lo
+ ifconfig eth0 up
+ udhcpc -i eth0 -f -q -s /bin/setdhcp
+
+ cd /newroot
+ pivot_root . initrd
+ [ -x /sbin/chroot ] && exec /sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1
+ exec /usr/sbin/chroot . /sbin/init -i < dev/console > dev/console 2>&1
+ EOF
+
+ cat <<-'EOF' > "$DESTDIR/bin/setdhcp"
+ #!/bin/sh
+ [ "$1" != "bound" ] && exit
+ [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+ [ -n "$subnet" ] && NETMASK="netmask $subnet"
+ ifconfig $interface $ip $BROADCAST $NETMASK up
+ if [ -n "$router" ]; then
+ for r in $router; do
+ route add default gw $r dev $interface
+ done
+ fi
+
+ for o in $CMDLINE; do
+ case $o in
+ nfsroot=*)
+ rootpath=${o#nfsroot=}
+ ;;
+ esac
+ done
+
+ if [ -n "$rootpath" ]; then
+ mount -n -t nfs -o ro,nolock,posix,tcp,wsize=8192,rsize=8192 $rootpath /newroot
+ else
+ echo "Missing rootpath in what DHCP server sent to us. Failing..."
+ echo "All seen variables are listed below:"
+ set
+ fi
+ EOF
+
+ chmod 755 "$DESTDIR/bin/setdhcp"
+}
More information about the pld-cvs-commit
mailing list