system: Fix for NFS booting with interface config via DHCP
PATCH 1/1 system: Fix for NFS booting with interface config via DHCP
Configuring the network interface with DHCP via /etc/network/interfaces generally does work when NFS booting. The DHCP configuration will initially bring the interface down and system then hangs at that point as the root filesystem is no longer accessable. See bug 4709.
The system config option adds a script to if-pre-up.d that will check for a NFS root filesystem and if the interface to be configured is used for access to the NFS server. If this is the case, then it returns a failure code so that ifup will not configure the interface. This works for DHCP and another config methods (static, bootp, etc.). This system does detect if the interface to be configured isn't the one used for NFS and doesn't skip it when that is the case.
NFS filesystems that aren't the root fs aren't considered.
---
Example when the interface is used for NFS:
# ifup eth0 Skipping eth0, used for NFS from 192.168.1.123 run-parts: /etc/network/if-pre-up.d/nfs_check: exit status 1
Example when the interface isn't used for NFS:
# ifup eth1 [brings interface up]
An alternative to putting the script in if-pre-up.d would be to add pre-up lines to the interfaces file. This would allow running the script just for certain interfaces. It also removes the "run-parts" message to do it this way.
package/skeleton/nfs_check | 7 +++++++ package/skeleton/skeleton.mk | 7 +++++++ system/Config.in | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100755 package/skeleton/nfs_check
package/skeleton/nfs_check new file +7 -0
@@ -0,0 +1,7 @@ +#!/bin/sh + +nfsip=`awk '$3=="nfs" && $2=="/"{ sub(/:.*/,"",$1); print $1; }' /proc/mounts` +if [ -n "$nfsip" ] && ip route get to "$nfsip" | grep -q "dev $IFACE"; then + echo Skipping $IFACE, used for NFS from $nfsip + exit 1 +fi
package/skeleton/skeleton.mk +7 -0
@@ -33,6 +33,12 @@ define SKELETON_USR_SYMLINKS_OR_DIRS endef endif +ifeq ($(BR2_SYSTEM_IFUP_NFS_ROOT),y) +define SKELETON_INSTALL_NFS_CHECK + $(INSTALL) -m 0755 -D package/skeleton/nfs_check $(TARGET_DIR)/etc/network/if-pre-up.d/nfs_check +endef +endif + define SKELETON_INSTALL_TARGET_CMDS rsync -a --ignore-times $(SYNC_VCS_EXCLUSIONS) \ --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
@@ -98,6 +104,7 @@ define SET_NETWORK mkdir -p $(TARGET_DIR)/etc/network/ $(SET_NETWORK_LOCALHOST) $(SET_NETWORK_DHCP) + $(SKELETON_INSTALL_NFS_CHECK) endef TARGET_FINALIZE_HOOKS += SET_NETWORK
system/Config.in +19 -0
@@ -358,6 +358,25 @@ config BR2_SYSTEM_DHCP For more complicated network setups use an overlay to overwrite /etc/network/interfaces or add a networkd configuration file. +config BR2_SYSTEM_IFUP_NFS_ROOT + bool "Have network interface configuration cope with NFS root boot" + default y + depends on BR2_SYSTEM_DHCP != "" + help + This allows NFS booting to work while also enabling the + option to configure the network interface via DHCP. + Otherwise, a NFS booted system will likely hang during DHCP + configuration. + + Attempting to configure the network interface used for NFS + will initially bring that network down. Since the root + filesystem is accessed over this network, the system hangs. + + This option will add a script to the ifup system that will + attempt to detect if a NFS root mount uses the interface to + be configured, and if so does not configure it. This should + allow the same build to be disk/flash booted or NFS booted. + comment "automatic network configuration via DHCP is not compatible with networkd" depends on BR2_PACKAGE_SYSTEMD_NETWORKD
Signature · 1 line
1.8.3.1
PATCH 1/1 system: Fix for NFS booting with interface config via DHCP
Quoted 14 lines · Trent Piepho
Configuring the network interface with DHCP via
/etc/network/interfacesgenerally does work when NFS booting. The DHCP configuration will initially bring the interface down and system then hangs at that point as the root filesystem is no longer accessable. See bug 4709.The system config option adds a script to if-pre-up.d that will check for a NFS root filesystem and if the interface to be configured is used for access to the NFS server. If this is the case, then it returns a failure code so that ifup will not configure the interface. This works for DHCP and another config methods (static, bootp, etc.). This system does detect if the interface to be configured isn't the one used for NFS and doesn't skip it when that is the case.
Quoted 3 lines
NFS filesystems that aren't the root fs aren't considered.
Signed-off-by Trent Piepho <[email protected]>
Good one! A few small remarks below.
Quoted 7 lines
---
Example when the interface is used for NFS:
# ifup eth0 Skipping eth0, used for NFS from 192.168.1.123 run-parts: /etc/network/if-pre-up.d/nfs_check: exit status 1
Quoted 8 lines
Example when the interface isn't used for NFS:
# ifup eth1 [brings interface up]An alternative to putting the script in if-pre-up.d would be to add pre-up lines to the interfaces file. This would allow running the script just for certain interfaces. It also removes the "run-parts" message to do it this way.
But I think ifup would still report an error, no?
Quoted 13 lines
package/skeleton/nfs_check | 7 +++++++ package/skeleton/skeleton.mk | 7 +++++++ system/Config.in | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100755 package/skeleton/nfs_checkpackage/skeleton/nfs_check new file +0
-0
package/skeleton/nfs_check line 3
Quoted 3 lines
package/skeleton/nfs_check new file +3
-0@@ -0,0 +1,7 @@ +#!/bin/sh + +nfsip=`awk '$3=="nfs" && $2=="/"{ sub(/:.*/,"",$1); print $1; }' /proc/mounts`
sed is generally better-known so we prefer it if possible. Like
sed -n '/^\([0-9.]*\):[^ ]* \/ nfs .*/s//\1/p' /proc/mounts
However, why don't we just check if the interface is already up? Like
ip link show $IFACE | cut -d ' ' -f 3 | grep -q UP
Quoted 9 lines
package/skeleton/nfs_check new file +4
-0+if [ -n "$nfsip" ] && ip route get to "$nfsip" | grep -q "dev $IFACE"; then + echo Skipping $IFACE, used for NFS from $nfsip + exit 1 +fipackage/skeleton/skeleton.mk +0
-0
package/skeleton/skeleton.mk define SKELETON_USR_SYMLINKS_OR_DIRS · line 38
Quoted 6 lines
package/skeleton/skeleton.mk +3
-0@@ -33,6 +33,12 @@ define SKELETON_USR_SYMLINKS_OR_DIRS endef endif +ifeq ($(BR2_SYSTEM_IFUP_NFS_ROOT),y) +define SKELETON_INSTALL_NFS_CHECK + $(INSTALL) -m 0755 -D package/skeleton/nfs_check $(TARGET_DIR)/etc/network/if-pre-up.d/nfs_check
Please use $(SKELETON_PKGDIR) instead of package/skeleton in new code, and also
split this long line.
Quoted 19 lines
package/skeleton/skeleton.mk +4
-0+endef +endif + define SKELETON_INSTALL_TARGET_CMDS rsync -a --ignore-times $(SYNC_VCS_EXCLUSIONS) \ --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \@@ -98,6 +104,7 @@ define SET_NETWORK mkdir -p $(TARGET_DIR)/etc/network/ $(SET_NETWORK_LOCALHOST) $(SET_NETWORK_DHCP) + $(SKELETON_INSTALL_NFS_CHECK) endef TARGET_FINALIZE_HOOKS += SET_NETWORKsystem/Config.in +0
-0
system/Config.in config BR2_SYSTEM_DHCP · line 361
Quoted 4 lines
system/Config.in +1
-0@@ -358,6 +358,25 @@ config BR2_SYSTEM_DHCP For more complicated network setups use an overlay to overwrite /etc/network/interfaces or add a networkd configuration file. +config BR2_SYSTEM_IFUP_NFS_ROOT
I wonder if it is useful to have this optional. The overhead of running this
extra script is minimal, and we know for sure that NFS-root will not boot without it. So I'd always install it if BR2_SYSTEM_DHCP. And people who don't want it can still get rid of it in an overlay.
That said, we can always remove this option later.
Great help text BTW.
Regards,
Arnout
Quoted 22 lines
system/Config.in +18
-0+ bool "Have network interface configuration cope with NFS root boot" + default y + depends on BR2_SYSTEM_DHCP != "" + help + This allows NFS booting to work while also enabling the + option to configure the network interface via DHCP. + Otherwise, a NFS booted system will likely hang during DHCP + configuration. + + Attempting to configure the network interface used for NFS + will initially bring that network down. Since the root + filesystem is accessed over this network, the system hangs. + + This option will add a script to the ifup system that will + attempt to detect if a NFS root mount uses the interface to + be configured, and if so does not configure it. This should + allow the same build to be disk/flash booted or NFS booted. + comment "automatic network configuration via DHCP is not compatible with networkd" depends on BR2_PACKAGE_SYSTEMD_NETWORKD
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 system: Fix for NFS booting with interface config via DHCP
Quoted 9 lines · Arnout Vandecappelle
Quoted 9 lines
Example when the interface is used for NFS:
# ifup eth0 Skipping eth0, used for NFS from 192.168.1.123 run-parts: /etc/network/if-pre-up.d/nfs_check: exit status 1Example when the interface isn't used for NFS:
# ifup eth1 [brings interface up]
Quoted 6 lines
Quoted 4 lines
An alternative to putting the script in if-pre-up.d would be to add pre-up lines to the interfaces file. This would allow running the script just for certain interfaces. It also removes the "run-parts" message to do it this way.
But I think ifup would still report an error, no?
Not really, error exit status but no message:
# ifup eth0 ; echo $? Skipping eth0, used for NFS from 192.168.1.123 1
The skipping message is from my script.
Quoted 6 lines
package/skeleton/nfs_check line 3
Quoted 2 lines
package/skeleton/nfs_check new file +2
-0+ +nfsip=`awk '$3=="nfs" && $2=="/"{ sub(/:.*/,"",$1); print $1; }' /proc/mounts`sed is generally better-known so we prefer it if possible. Like
sed -n '/^\([0-9.]*\):[^ ]* \/ nfs .*/s//\1/p'
/proc/mounts
Ok, that's simpler too.
Quoted 4 lines
However, why don't we just check if the interface is already up? Like
ip link show $IFACE | cut -d ' ' -f 3 | grep -q UP
It's currently ok to call ifup on an interface that's already up. It will reconfigure it. The interface, while up, might not have been assigned an ip.
It wouldn't be tied to NFS at that point either.
Quoted 4 lines
I wonder if it is useful to have this optional. The overhead of running this
extra script is minimal, and we know for sure that NFS-root will not boot without it. So I'd always install it ifBR2_SYSTEM_DHCP. And people who don't want it can still get rid of it in an overlay.
I didn't think that being option was that useful either. But it's possible for NFS root to work without having this, if the NFS interface is not the same one that is being configured with DHCP.
PATCH 1/1 system: Fix for NFS booting with interface config via DHCP
Quoted 16 lines · Trent Piepho
Quoted 14 lines · Arnout Vandecappelle
Quoted 13 lines
Example when the interface is used for NFS:
# ifup eth0 Skipping eth0, used for NFS from 192.168.1.123 run-parts: /etc/network/if-pre-up.d/nfs_check: exit status 1Example when the interface isn't used for NFS:
# ifup eth1 [brings interface up]An alternative to putting the script in if-pre-up.d would be to add pre-up lines to the interfaces file. This would allow running the script just for certain interfaces. It also removes the "run-parts" message to do it this way.
Quoted 8 lines
Quoted 1 line
But I think ifup would still report an error, no?
Not really, error exit status but no message:
# ifup eth0 ; echo $? Skipping eth0, used for NFS from 192.168.1.123 1The skipping message is from my script.
In that case, a pre-up line seems better to me.
Quoted 11 lines
Quoted 6 lines
package/skeleton/nfs_check line 3
Quoted 2 lines
package/skeleton/nfs_check new file +2
-0+ +nfsip=`awk '$3=="nfs" && $2=="/"{ sub(/:.*/,"",$1); print $1; }' /proc/mounts`sed is generally better-known so we prefer it if possible. Like
sed -n '/^\([0-9.]*\):[^ ]* \/ nfs .*/s//\1/p'
/proc/mountsOk, that's simpler too.
Quoted 2 lines
Quoted 8 lines
Quoted 2 lines
However, why don't we just check if the interface is already up? Like
ip link show $IFACE | cut -d ' ' -f 3 | grep -q UPIt's currently ok to call ifup on an interface that's already up. It will reconfigure it. The interface, while up, might not have been assigned an ip.
It wouldn't be tied to NFS at that point either.
Right, so your approach is better then.
BTW are we sure that /proc/mounts contains the IP address and not the host name?
Regards,
Arnout
Quoted 9 lines
Quoted 4 lines
I wonder if it is useful to have this optional. The overhead of running this
extra script is minimal, and we know for sure that NFS-root will not boot without it. So I'd always install it ifBR2_SYSTEM_DHCP. And people who don't want it can still get rid of it in an overlay.I didn't think that being option was that useful either. But it's possible for NFS root to work without having this, if the NFS interface is not the same one that is being configured with DHCP.
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 system: Fix for NFS booting with interface config via DHCP
Quoted 8 lines · Arnout Vandecappelle
Quoted 8 lines
Quoted 3 lines
However, why don't we just check if the interface is already up? Like
ip link show $IFACE | cut -d ' ' -f 3 | grep -q UPIt's currently ok to call ifup on an interface that's already up. It will reconfigure it. The interface, while up, might not have been assigned an ip.
Quoted 5 lines
Quoted 1 line
It wouldn't be tied to NFS at that point either.
Right, so your approach is better then.
BTW are we sure that
/proc/mountscontains the IP address and not the host name?
I believe the nfsroot mount option only allows IP addresses and not hostnames. Since the kernel would have to do the DNS lookup. And the kernel docs say "<server-ip>", which seems to imply only an IP will work. It didn't work when I tried it. And the busybox mount command appears to only accept an IP ("mount: bad address 'hostname'").
But the util linux mount does accept a hostname and it does show up in /proc/mounts as a hostname.
So you can get a hostname, but I don't think it's possible in a NFS root case. The mount options also in /proc/mounts will have addr=<ip>, which is a way to get the numeric ip even if the hostname is present. It does make the sed parsing harder to get the value from there.
PATCH 1/1 system: Fix for NFS booting with interface config via DHCP
In reply to Trent PiephoDear Trent Piepho,
Thanks for working on this issue and proposing a solution for it!
Quoted 2 lines · Trent Piepho
Configuring the network interface with DHCP via
/etc/network/interfacesgenerally does work when NFS booting. The
Isn't there a missing "not" in this sentence ?
package/skeleton/nfs_check
Quoted 5 lines
package/skeleton/nfs_check new file +0
-0
I think this should be in the initscripts package, not the skeleton package. The initscripts package is the one that installs S40network, which is the initscript calling ifup.
However, it's true that the skeleton package is currently the one that generates the 'interfaces' file. Does that make sense? Is systemd using the interfaces file at all?
package/skeleton/nfs_check line 6
Quoted 7 lines
package/skeleton/nfs_check new file +6
-0@@ -0,0 +1,7 @@ +#!/bin/sh + +nfsip=`awk '$3=="nfs" && $2=="/"{ sub(/:.*/,"",$1); print $1; }' /proc/mounts` +if [ -n "$nfsip" ] && ip route get to "$nfsip" | grep -q "dev $IFACE"; then + echo Skipping $IFACE, used for NFS from $nfsip + exit 1
I think we generally use tabs for indentation in shell scripts.
Quoted 8 lines
package/skeleton/nfs_check new file +8
-0+config BR2_SYSTEM_IFUP_NFS_ROOT + bool "Have network interface configuration cope with NFS root boot" + default y + depends on BR2_SYSTEM_DHCP != "" + help + This allows NFS booting to work while also enabling the + option to configure the network interface via DHCP. + Otherwise, a NFS booted system will likely hang during DHCP
package/skeleton/nfs_check
Quoted 10 lines
package/skeleton/nfs_check new file +10
-0+ configuration. + + Attempting to configure the network interface used for NFS + will initially bring that network down. Since the root + filesystem is accessed over this network, the system hangs. + + This option will add a script to the ifup system that will + attempt to detect if a NFS root mount uses the interface to + be configured, and if so does not configure it. This should + allow the same build to be disk/flash booted or NFS booted.
Like Arnout said, I'm not sure this option is really needed. Just always install this script when DHCP is used. You can put this text as a big comment at the beginning of the nfs-check script, or inside the .mk file above the command that installs this script to TARGET_DIR.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 system: Fix for NFS booting with interface config via DHCP
Quoted 9 lines · Thomas Petazzoni
Dear Trent Piepho,
Thanks for working on this issue and proposing a solution for it!
Quoted 2 lines · Trent Piepho
Configuring the network interface with DHCP via
/etc/network/interfacesgenerally does work when NFS booting. TheIsn't there a missing "not" in this sentence ?
yes
Quoted 11 lines
package/skeleton/nfs_check
Quoted 6 lines
package/skeleton/nfs_check new file +0
-0I think this should be in the initscripts package, not the skeleton package. The initscripts package is the one that installs S40network, which is the initscript calling ifup.
Quoted 3 lines
However, it's true that the skeleton package is currently the one that generates the 'interfaces' file. Does that make sense? Is systemd using the interfaces file at all?
It seems like since the script was optional, and the option to control it was part of skeleton, that it should be there too. But if it's not optional, then I suppose it could go into initscripts. The autogenerated interfaces file in the skeleton package would need to add the pre-up line.
I haven't looked into systemd yet so I can't saw how that works. I don't see any code in skeleton to generate a different configuration for systemd, so I guess either it uses that file or it doesn't work.
Quoted 24 lines
package/skeleton/nfs_check line 6
Quoted 8 lines
package/skeleton/nfs_check new file +6
-0@@ -0,0 +1,7 @@ +#!/bin/sh + +nfsip=`awk '$3=="nfs" && $2=="/"{ sub(/:.*/,"",$1); print $1; }' /proc/mounts` +if [ -n "$nfsip" ] && ip route get to "$nfsip" | grep -q "dev $IFACE"; then + echo Skipping $IFACE, used for NFS from $nfsip + exit 1I think we generally use tabs for indentation in shell scripts.
Quoted 13 lines
package/skeleton/nfs_check new file +13
-0+config BR2_SYSTEM_IFUP_NFS_ROOT + bool "Have network interface configuration cope with NFS root boot" + default y + depends on BR2_SYSTEM_DHCP != "" + help + This allows NFS booting to work while also enabling the + option to configure the network interface via DHCP. + Otherwise, a NFS booted system will likely hang during DHCP + configuration. + + Attempting to configure the network interface used for NFS + will initially bring that network down. Since the root + filesystem is accessed over this network, the system hangs.
Quoted 8 lines
package/skeleton/nfs_check
Quoted 5 lines
package/skeleton/nfs_check new file +5
-0+ + This option will add a script to the ifup system that will + attempt to detect if a NFS root mount uses the interface to + be configured, and if so does not configure it. This should + allow the same build to be disk/flash booted or NFS booted.Like Arnout said, I'm not sure this option is really needed. Just always install this script when DHCP is used. You can put this text as
If the script is only installed when DHCP is used, then wouldn't it make sense to put it in skeleton since the other code that depends on BR2_SYSTEM_DHCP is there.
Quoted 6 lines
a big comment at the beginning of the nfs-check script, or inside the .mk file above the command that installs this script to
TARGET_DIR.Best regards,
Thomas
PATCH v2 1/1 system: Fix for NFS booting with interface config via DHCP
In reply to Thomas PetazzoniConfiguring the network interface with DHCP via /etc/network/interfaces generally does not work when NFS booting. The DHCP configuration will initially bring the interface down and system then hangs at that point as the root filesystem is no longer accessable. See bug 4709.
This adds a script to be run via a pre-up line in /etc/network/interfaces. It checks for a NFS root filesystem and if the interface to be configured is used for access to the NFS server. If this is the case, then it returns a failure code so that ifup will not configure the interface. This works for DHCP and another config methods (static, bootp, etc.). This system does detect if the interface to be configured isn't the one used for NFS and doesn't skip it when that is the case.
NFS filesystems that aren't the root fs aren't considered.
--- package/skeleton/nfs_check | 20 ++++++++++++++++++++ package/skeleton/skeleton.mk | 3 +++ 2 files changed, 23 insertions(+) create mode 100755 package/skeleton/nfs_check
package/skeleton/nfs_check new file +20 -0
@@ -0,0 +1,20 @@ +#!/bin/sh + +# This allows NFS booting to work while also being able to configure +# the network interface via DHCP when not NFS booting. Otherwise, a +# NFS booted system will likely hang during DHCP configuration. + +# Attempting to configure the network interface used for NFS will +# initially bring that network down. Since the root filesystem is +# accessed over this network, the system hangs. + +# This script is run by ifup and will attempt to detect if a NFS root +# mount uses the interface to be configured (IFACE), and if so does +# not configure it. This should allow the same build to be disk/flash +# booted or NFS booted. + +nfsip=`sed -n '/^[^ ]*:.* \/ nfs.*[ ,]addr=\([0-9.]\+\).*/s//\1/p' /proc/mounts` +if [ -n "$nfsip" ] && ip route get to "$nfsip" | grep -q "dev $IFACE"; then + echo Skipping $IFACE, used for NFS from $nfsip + exit 1 +fi
package/skeleton/skeleton.mk +3 -0
@@ -89,8 +89,11 @@ define SET_NETWORK_DHCP echo ; \ echo "auto $(NETWORK_DHCP_IFACE)"; \ echo "iface $(NETWORK_DHCP_IFACE) inet dhcp"; \ + echo " pre-up /etc/network/nfs_check"; \ echo " wait-delay 15"; \ ) >> $(TARGET_DIR)/etc/network/interfaces + $(INSTALL) -m 0755 -D $(SKELETON_PKGDIR)/nfs_check \ + $(TARGET_DIR)/etc/network/nfs_check endef endif
Signature · 1 line
1.8.3.1
PATCH v2 1/1 system: Fix for NFS booting with interface config via DHCP
Quoted 15 lines · Trent Piepho
Configuring the network interface with DHCP via
/etc/network/interfacesgenerally does not work when NFS booting. The DHCP configuration will initially bring the interface down and system then hangs at that point as the root filesystem is no longer accessable. See bug 4709.This adds a script to be run via a pre-up line in
/etc/network/interfaces. It checks for a NFS root filesystem and if the interface to be configured is used for access to the NFS server. If this is the case, then it returns a failure code so that ifup will not configure the interface. This works for DHCP and another config methods (static, bootp, etc.). This system does detect if the interface to be configured isn't the one used for NFS and doesn't skip it when that is the case.
Quoted 3 lines
NFS filesystems that aren't the root fs aren't considered.
Signed-off-by Trent Piepho <[email protected]>
I checked that the addr= appears in /proc/mounts since at least 2.6.17.
IMHO this is still for 2015.11.
Regards,
Arnout
Quoted 49 lines
--- package/skeleton/nfs_check | 20 ++++++++++++++++++++ package/skeleton/skeleton.mk | 3 +++ 2 files changed, 23 insertions(+) create mode 100755 package/skeleton/nfs_checkpackage/skeleton/nfs_check new file +20
-0@@ -0,0 +1,20 @@ +#!/bin/sh + +# This allows NFS booting to work while also being able to configure +# the network interface via DHCP when not NFS booting. Otherwise, a +# NFS booted system will likely hang during DHCP configuration. + +# Attempting to configure the network interface used for NFS will +# initially bring that network down. Since the root filesystem is +# accessed over this network, the system hangs. + +# This script is run by ifup and will attempt to detect if a NFS root +# mount uses the interface to be configured (IFACE), and if so does +# not configure it. This should allow the same build to be disk/flash +# booted or NFS booted. + +nfsip=`sed -n '/^[^ ]*:.* \/ nfs.*[ ,]addr=\([0-9.]\+\).*/s//\1/p' /proc/mounts` +if [ -n "$nfsip" ] && ip route get to "$nfsip" | grep -q "dev $IFACE"; then + echo Skipping $IFACE, used for NFS from $nfsip + exit 1 +fipackage/skeleton/skeleton.mk +3
-0@@ -89,8 +89,11 @@ define SET_NETWORK_DHCP echo ; \ echo "auto $(NETWORK_DHCP_IFACE)"; \ echo "iface $(NETWORK_DHCP_IFACE) inet dhcp"; \ + echo " pre-up /etc/network/nfs_check"; \ echo " wait-delay 15"; \ ) >> $(TARGET_DIR)/etc/network/interfaces + $(INSTALL) -m 0755 -D $(SKELETON_PKGDIR)/nfs_check \ + $(TARGET_DIR)/etc/network/nfs_check endef endif
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Thomas Petazzoni
AppliedPATCH v2 1/1 system: Fix for NFS booting with interface config via DHCP
In reply to Trent PiephoDear Trent Piepho,
Quoted 15 lines · Trent Piepho
Configuring the network interface with DHCP via
/etc/network/interfacesgenerally does not work when NFS booting. The DHCP configuration will initially bring the interface down and system then hangs at that point as the root filesystem is no longer accessable. See bug 4709.This adds a script to be run via a pre-up line in
/etc/network/interfaces. It checks for a NFS root filesystem and if the interface to be configured is used for access to the NFS server. If this is the case, then it returns a failure code so that ifup will not configure the interface. This works for DHCP and another config methods (static, bootp, etc.). This system does detect if the interface to be configured isn't the one used for NFS and doesn't skip it when that is the case.
Quoted 8 lines
NFS filesystems that aren't the root fs aren't considered.
Signed-off-by Trent Piepho <[email protected]>--- package/skeleton/nfs_check | 20 ++++++++++++++++++++ package/skeleton/skeleton.mk | 3 +++ 2 files changed, 23 insertions(+) create mode 100755 package/skeleton/nfs_check
Applied to next, thanks! I only had to adjust the bug number, it's fixing #4790, not #4709.
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com