[PATCH] No timeout as running ipconfig for network booting
Hi,
Attached please find the patch file for live-initramfs 1.199.1 to make
ipconfig without running in the background and sleep when network booting.
Since for network booting, IP address is a must for downloading
filesystem.squashfs and it's not easy to find a good timeout time.
Sometimes it's really annoying to wait for the default 15 secs, and
sometimes it will give kernel panic error if the timeout time is too short.
My 2 cents.
Thanks.
Regards,
Steven.
--
Steven Shiau <steven _at_ nchc org tw> <steven _at_ stevenshiau org>
National Center for High-performance Computing, Taiwan. http://www.nchc.org.tw
Public Key Server PGP Key ID: 1024D/9762755A
Fingerprint: A2A1 08B7 C22C 3D06 34DB F4BC 08B3 E3D7 9762 755A
--- a/scripts/live
+++ a/scripts/live
@@ -779,49 +779,55 @@
udevadm trigger
udevadm settle
- # if ethdevice was not specified on the kernel command line
- # make sure we try to get a working network configuration
- # for *every* present network device (except for loopback of course)
- if [ -z "$ETHDEVICE" ] ; then
- echo "If you want to boot from a specific device use bootoption ethdevice=..."
- for device in /sys/class/net/*; do
- dev=${device##*/} ;
- if [ "$dev" != "lo" ] ; then
- ETHDEVICE="$ETHDEVICE $dev"
+ if [ -z "${NETBOOT}" -a -z "${FETCH}" -a -z "${HTTPFS}" -a -z "${FTPFS}" ]
+ then
+
+ # if ethdevice was not specified on the kernel command line
+ # make sure we try to get a working network configuration
+ # for *every* present network device (except for loopback of course)
+ if [ -z "$ETHDEVICE" ] ; then
+ echo "If you want to boot from a specific device use bootoption ethdevice=..."
+ for device in /sys/class/net/*; do
+ dev=${device##*/} ;
+ if [ "$dev" != "lo" ] ; then
+ ETHDEVICE="$ETHDEVICE $dev"
+ fi
+ done
+ fi
+
+ # split args of ethdevice=eth0,eth1 into "eth0 eth1"
+ for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
+ devlist="$devlist $device"
+ done
+
+ [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
+ echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
+
+ # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
+ # an endless loop; iff execution fails give it two further tries, that's
+ # why we use '$devlist $devlist $devlist' for the other for loop
+ for dev in $devlist $devlist $devlist ; do
+ echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
+ ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
+ jobid=$!
+ sleep "$ETHDEV_TIMEOUT" ; sleep 1
+ if [ -r /proc/"$jobid"/status ] ; then
+ echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
+ kill -9 $jobid
+ fi
+
+ # if configuration of device worked we should have an assigned
+ # IP address, iff so let's use the according as $DEVICE for later usage
+ # simple and primitive approach which seems to work fine
+ if ifconfig $dev | grep -q 'inet.*addr:' ; then
+ export DEVICE="$dev"
+ break
fi
done
+ else
+ ipconfig ${DEVICE} | tee /netboot.config
fi
- # split args of ethdevice=eth0,eth1 into "eth0 eth1"
- for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
- devlist="$devlist $device"
- done
-
- [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
- echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
-
- # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
- # an endless loop; iff execution fails give it two further tries, that's
- # why we use '$devlist $devlist $devlist' for the other for loop
- for dev in $devlist $devlist $devlist ; do
- echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
- ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
- jobid=$!
- sleep "$ETHDEV_TIMEOUT" ; sleep 1
- if [ -r /proc/"$jobid"/status ] ; then
- echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
- kill -9 $jobid
- fi
-
- # if configuration of device worked we should have an assigned
- # IP address, iff so let's use the according as $DEVICE for later usage
- # simple and primitive approach which seems to work fine
- if ifconfig $dev | grep -q 'inet.*addr:' ; then
- export DEVICE="$dev"
- break
- fi
- done
-
# source relevant ipconfig output
OLDHOSTNAME=${HOSTNAME}
. /tmp/net-${DEVICE}.conf
Reply to: