[patch] pxe with tftp improvement

Post there if you plan to contribute to this SystemCd
Post Reply
maxx
Posts: 4
Joined: 18 Mar 2011, 15:13

[patch] pxe with tftp improvement

Post by maxx » 18 Apr 2011, 18:59

I posted this a while ago on the wrong board...
(http://www.sysresccd.org/forums/posting ... 18&p=11730)

Hopefully here it is right and will be included in the next release...


In order to simplify booting sysreccd by PXE i made some improvements
to initram.igz:/init

With these changes you can simpify the pxelinux configuration when
using tftp:

Code: Select all

label mybootentry3
  kernel rescuecd
  append initrd=initram.igz dodhcp netboot=tftp
  ipappend 3
In this case the sysrcd.dat will be obtained from the same server/directory
where the kernel and initrd are.


--- BEGIN PATCH -------------------------------------------------------

Code: Select all

--- init_orig	2011-03-12 14:13:55.000000000 +0100
+++ init	2011-03-12 14:12:33.000000000 +0100
@@ -659,15 +659,20 @@
 		sysresccd_panic "Cannot create tmpfs on ${BOOTPATH}"
 	fi
 
-	if ! echo "${TFTPBOOT}" | grep -q '^tftp://'
+	if [ "${TFTPBOOT}" = "tftp" -a "${ip}" ]
 	then
+		tftpip="`echo ${ip} | cut -d: -f2`"
+		tftpurl="`dirname ${BOOT_IMAGE}`/${LOOPDAT}"
+	elif echo "${TFTPBOOT}" | grep -q '^tftp://'
+	then
+		url="$(echo ${TFTPBOOT} | sed 's!tftp://!!g')" # remote the 'tftp://' prefix
+		tftpip="${url%%/*}"
+		tftpurl="/${url#*/}"
+	else
 		sysresccd_panic "You requested an tftp boot, the address is not a valid tftp:// url."
 	fi
 
-	good_msg "Downloading ${LOOPDAT} from ${TFTPBOOT}"
-	url="$(echo ${TFTPBOOT} | sed 's!tftp://!!g')" # remote the 'tftp://' prefix
-	tftpip="${url%%/*}"
-	tftpurl="/${url#*/}"
+	good_msg "Downloading ${LOOPDAT} from tftp://${tftpip}/${tftpurl}"
 	BOOTMD5=$(echo ${tftpurl} | sed -e "s/${LOOPDAT}/${LOOPMD5}/g") # URL of the md5 file
 	cmd1="/bin/busybox tftp -g -r ${BOOTMD5} -l ${BOOTPATH}/${LOOPMD5} ${tftpip}"
 	echo "$cmd1"
@@ -1321,6 +1326,12 @@
 			NETCONFIG='1'
 			NONETMGR='1'
 			;;
+		netboot\=tftp)
+			TFTPBOOT=`parse_opt "${x}"`
+			STAGE0='tftp'
+			NETCONFIG='1'
+			NONETMGR='1'
+			;;
 		netboot\=nfs://*)
 			NFSBOOT=`parse_opt "${x}"`
 			STAGE0='nfs'
--- END PATCH ---------------------------------------------------------

I hope you will include this to upcoming releases.

Thank you

Max

BTW. Busybox has a bug displaying the tftp progress bar, don't worry, the
file will be obtained correctly even if the status says "stalled".
--> I reported that bug and now it is fixed in the snapshot (already veryfied by myself)
and so it should be available in the next release (> 1.18.4).
Perhaps you can update busybox then?

maxx
Posts: 4
Joined: 18 Mar 2011, 15:13

Re: [patch] pxe with tftp improvement

Post by maxx » 23 Jul 2011, 19:53

Nobody interested???

gernot
Posts: 1131
Joined: 07 Apr 2010, 16:19

Re: [patch] pxe with tftp improvement

Post by gernot » 23 Jul 2011, 20:32

Hello Max,
the pxebootserver prefill the pxelinux bootmenu with the correct serveraddress and boot source.
So normal no interaction is needful to boot via PXE.

Gernot

Post Reply