diff options
| author | Qing He <qing.he@intel.com> | 2010-05-19 00:24:25 +0800 |
|---|---|---|
| committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-08-09 16:54:08 +0100 |
| commit | 601464b4974e46d15abd02efd46663efcd530da8 (patch) | |
| tree | 30bffdbd2c0b97d55318139afa714c2f0602253b | |
| parent | bca283671f74b79394e9c332b790e5ed0dc44f35 (diff) | |
| download | poky-601464b4974e46d15abd02efd46663efcd530da8.tar.gz | |
nfsroot: allow nfsroot to survive netbase init
The patch adds a script in /etc/network/if-pre-up.d,
the script returns 1 (effectly skip the ifup on the iface) iff:
1. there is a "* / (nfs|nfs4) *" entry in the /proc/mounts
2. the addr field in that entry is routed using $IFACE
Signed-off-by: Qing He <qing.he@intel.com>
| -rw-r--r-- | meta/packages/netbase/netbase/nfsroot | 39 | ||||
| -rw-r--r-- | meta/packages/netbase/netbase_4.41.bb | 4 |
2 files changed, 42 insertions, 1 deletions
diff --git a/meta/packages/netbase/netbase/nfsroot b/meta/packages/netbase/netbase/nfsroot new file mode 100644 index 0000000000..fc384a8ea5 --- /dev/null +++ b/meta/packages/netbase/netbase/nfsroot | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | |||
| 3 | # In case the interface is used as nfsroot, avoid ifup, otherwise | ||
| 4 | # nfsroot may lose response | ||
| 5 | |||
| 6 | nfsroot=0 | ||
| 7 | |||
| 8 | if test "x$IFACE" = xlo ; then | ||
| 9 | exit 0 | ||
| 10 | fi | ||
| 11 | |||
| 12 | exec 9<&0 < /proc/mounts | ||
| 13 | while read dev mtpt fstype rest; do | ||
| 14 | if test $mtpt = "/" ; then | ||
| 15 | case $fstype in | ||
| 16 | nfs | nfs4) | ||
| 17 | nfsroot=1 | ||
| 18 | nfs_addr=`echo $rest | sed -e 's/^.*addr=\([0-9.]*\).*$/\1/'` | ||
| 19 | break | ||
| 20 | ;; | ||
| 21 | *) | ||
| 22 | ;; | ||
| 23 | esac | ||
| 24 | fi | ||
| 25 | done | ||
| 26 | exec 0<&9 9<&- | ||
| 27 | |||
| 28 | test $nfsroot -eq 0 && exit 0 | ||
| 29 | |||
| 30 | if test -x /sbin/ip ; then | ||
| 31 | nfs_iface=`ip route get $nfs_addr | grep dev | sed -e 's/^.*dev \([-a-z0-9.]*\).*$/\1/'` | ||
| 32 | fi | ||
| 33 | |||
| 34 | if test "x$IFACE" = "x$nfs_iface" ; then | ||
| 35 | echo "ifup skipped for nfsroot interface $nfs_iface" | ||
| 36 | exit 1 | ||
| 37 | fi | ||
| 38 | |||
| 39 | exit 0 | ||
diff --git a/meta/packages/netbase/netbase_4.41.bb b/meta/packages/netbase/netbase_4.41.bb index a3e2e87424..88b524ffd2 100644 --- a/meta/packages/netbase/netbase_4.41.bb +++ b/meta/packages/netbase/netbase_4.41.bb | |||
| @@ -17,7 +17,8 @@ INITSCRIPT_PARAMS_slugos = "start 42 S 0 6 ." | |||
| 17 | SRC_URI = "${DEBIAN_MIRROR}/main/n/netbase/netbase_${PV}.tar.gz \ | 17 | SRC_URI = "${DEBIAN_MIRROR}/main/n/netbase/netbase_${PV}.tar.gz \ |
| 18 | file://init \ | 18 | file://init \ |
| 19 | file://hosts \ | 19 | file://hosts \ |
| 20 | file://interfaces" | 20 | file://interfaces \ |
| 21 | file://nfsroot" | ||
| 21 | 22 | ||
| 22 | do_install () { | 23 | do_install () { |
| 23 | install -d ${D}${sysconfdir}/init.d \ | 24 | install -d ${D}${sysconfdir}/init.d \ |
| @@ -33,6 +34,7 @@ do_install () { | |||
| 33 | install -m 0644 etc-protocols ${D}${sysconfdir}/protocols | 34 | install -m 0644 etc-protocols ${D}${sysconfdir}/protocols |
| 34 | install -m 0644 etc-services ${D}${sysconfdir}/services | 35 | install -m 0644 etc-services ${D}${sysconfdir}/services |
| 35 | install -m 0644 ${WORKDIR}/interfaces ${D}${sysconfdir}/network/interfaces | 36 | install -m 0644 ${WORKDIR}/interfaces ${D}${sysconfdir}/network/interfaces |
| 37 | install -m 0755 ${WORKDIR}/nfsroot ${D}${sysconfdir}/network/if-pre-up.d | ||
| 36 | 38 | ||
| 37 | # Disable network manager on machines that commonly do NFS booting | 39 | # Disable network manager on machines that commonly do NFS booting |
| 38 | case "${MACHINE}" in | 40 | case "${MACHINE}" in |
