[patch] pxe with tftp improvement

Questions related to network booting via PXE
maxx
Posts: 4
Joined: 18 Mar 2011, 15:13

[patch] pxe with tftp improvement

Postby maxx » 18 Mar 2011, 15:15

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 1


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".

Return to “Network Boot via PXE”

Who is online

Users browsing this forum: No registered users and 4 guests