From: Trent Piepho Date: Mon, 9 Nov 2015 20:37:20 +0000 Subject: [Buildroot] [PATCH] system: Fix for NFS booting with interface config via DHCP In-Reply-To: <20151108145723.49e07124@free-electrons.com> References: <1446841557.4553.32.camel@rtred1test09.kymeta.local> <20151108145723.49e07124@free-electrons.com> Message-ID: <1447101442.4553.62.camel@rtred1test09.kymeta.local> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net On Sun, 2015-11-08 at 14:57 +0100, Thomas Petazzoni wrote: > Dear Trent Piepho, > > Thanks for working on this issue and proposing a solution for it! > > On Fri, 6 Nov 2015 20:25:56 +0000, Trent Piepho wrote: > > Configuring the network interface with DHCP via > > /etc/network/interfaces generally does work when NFS booting. The > > Isn't there a missing "not" in this sentence ? yes > > > diff --git a/package/skeleton/nfs_check b/package/skeleton/nfs_check > > new file mode 100755 > > index 0000000..1914404 > > --- /dev/null > > +++ b/package/skeleton/nfs_check > > 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? 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. > > > @@ -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. > > > +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. > > 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. > 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