1

Topic: [PATCH] Initrd-patch to allow tftp tranfser for filesystem.squashfs

Hello everybody,

according to the page http://gparted.sourceforge.net/livepxe.php it is only possible to pass http and ftp links to fetch the main "filesystem.squashfs".

I've created a patch for the "live" script which resides inside the initramfs to allow tftp download using command line:
"fetch=tftp://1.2.3.4/path/filesystem.squashfs"

--- live        2008-06-09 12:24:19.000000000 +0000
+++ live.jz     2008-06-09 12:23:27.000000000 +0000
@@ -701,23 +701,53 @@
{
        rc=1
        extension=$(echo "${FETCH}" | sed 's/\(.*\)\.\(.*\)/\2/')
-
-       case "${extension}" in
-               squashfs|tgz|tar)
-                       [ "${quiet}" != "y" ] && log_begin_msg "Trying wget ${FETCH} -O ${mountpoint}/$(basename ${FETCH})"
-                       mkdir -p "${mountpoint}/${LIVE_MEDIA_PATH}"
-                       wget "${FETCH}" -O "${mountpoint}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
-                       [ ${?} -eq 0 ] && rc=0
-                       [ "${extension}" = "tgz" ] && live_dest="ram"
-                       ;;
-
-               *)
-                       [ "${quiet}" != "y" ] && log_begin_msg "Unrecognized archive extension for ${FETCH}"
-       esac
+
+       # http://url
+       # ftp://url
+       # tftp://ip/filename
+
+       FETCHMODE=$(echo ${FETCH}" | cut -d ':' -f1)
+
+       if [ "${FETCHMODE}" = "http"] || [ "${FETCHMODE}" = "ftp"]
+       then
+
+           case "${extension}" in
+                   squashfs|tgz|tar)
+                           [ "${quiet}" != "y" ] && log_begin_msg "Trying wget ${FETCH} -O ${mountpoint}/$(basename ${FETCH})"
+                           mkdir -p "${mountpoint}/${LIVE_MEDIA_PATH}"
+                           wget "${FETCH}" -O "${mountpoint}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
+                           [ ${?} -eq 0 ] && rc=0
+                           [ "${extension}" = "tgz" ] && live_dest="ram"
+                           ;;
+
+                   *)
+                           [ "${quiet}" != "y" ] && log_begin_msg "Unrecognized archive extension for ${FETCH}"
+           esac
+       elif [ "${FETCHMODE}" = "tftp" ]
+       then
+           case "${extension}" in
+                   squashfs|tgz|tar)
+                           [ "${quiet}" != "y" ] && log_begin_msg "Trying tftp ${FETCH} -O ${mountpoint}/$(basename ${FETCH})"
+                           mkdir -p "${mountpoint}/${LIVE_MEDIA_PATH}"
+                           IP=$(echo ${FETCH} | cut -d '/' -f3)
+                           FILENAME=$(echo ${FETCH} | cut -d '/' -f4-)
+                           tftp -g -r "${FILENAME}" "${IP}" -l "${mountpoint}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
+                           [ ${?} -eq 0 ] && rc=0
+                           [ "${extension}" = "tgz" ] && live_dest="ram"
+                           ;;
+
+                   *)
+                           [ "${quiet}" != "y" ] && log_begin_msg "Unrecognized archive extension for ${FETCH}"
+           esac
+       else
+           [ "${quiet}" != "y" ] && log_begin_msg "Unrecognized transport for ${FETCH}"
+       fi

        return ${rc}
}

+
+
do_nfsmount ()
{
        rc=1

2 (edited by marmstro 2008-12-13 02:56:03)

Re: [PATCH] Initrd-patch to allow tftp tranfser for filesystem.squashfs

I am trying to use TFTP to download filesystem.squashfs in a PXE environment.  So far with no luck. I can get PXE to load the kernel and the initrd filesystem but the filesystem.squashfs is not loaded.  WRT your patch I cannot reconcile the patch information with my copy of the "live" script (see below).  Also, my "live" script seems to manage TFTP.  What gives?  I have to admit I am not very familiar with "patch" so I may be misinterpreting the lines in your patch script.  Or perhaps your patch applies to a different version.   My version of the GParted live CDROM (found in the file "GParted-Live-Version") is:

   gparted-live-0.3.9-4
   This GParted Live is created by:
   create-gparted-live -l en -b u -e e -i 0.3.9-4

In any case I haven't been able to find the correct combination of kernel parameters to get PXE to download the file filesystem.squashfs.

Any ideas?
Is there any place where ALL the GParted kernel boot parameters are listed and explained - particularly those that are passed to "init" and then to "live"?

BTW: How are the programs curlftpfs|httpfs|tftp executed?  There is no evidence of them in the initrd filesystem.

======= my live script (part of it) ==============================
708 do_httpmount ()
709 {
710         rc=1
711         dest="${mountpoint}/${LIVE_MEDIA_PATH}"
712         mount -n -t ramfs ram "${mountpoint}"
713         mkdir -p "${dest}"
714
715         for webfile in HTTPFS FTPFS FETCH
716         do
717                 url="$(eval echo \"\$\{${webfile}\}\")"
718                 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
719
720                 if [ -n "$url" ]
721                 then
722                         case "${extension}" in
723                                 squashfs|tgz|tar)
724                                         if [ "${webfile}" = "FETCH" ]
725                                         then
726                                                 case "$url" in
727                                                         tftp*)
728                                                                 ip="$(dirname $url | sed -e 's|tftp://||g')"
729                                                                 log_begin_msg "Trying tftp -g -b 10240 -r $(basename ${url})  -l ${dest}/$(basenam     e ${url}) $ip"
730                                                                 tftp -g -b 10240 -r $(basename ${url})  -l ${dest}/$(basename ${url}) $ip
731                                                         ;;
732
733                                                         *)
734                                                                 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
735                                                                 wget "${url}" -O "${dest}/$(basename ${url})"
736                                                                 ;;
737                                                 esac
738                                         else
739                                                 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
740                                                 if [ "${webfile}" = "FTPFS" ]
741                                                 then
742                                                         FUSE_MOUNT="curlftpfs"
743                                                         url="$(dirname ${url})"
744                                                 else
745                                                         FUSE_MOUNT="httpfs"
746                                                 fi
747                                                 modprobe fuse
748                                                 $FUSE_MOUNT "${url}" "${dest}"
749                                         fi
750                                         [ ${?} -eq 0 ] && rc=0
751                                         [ "${extension}" = "tgz" ] && live_dest="ram"
752                                         break
753                                         ;;
754
755                                 *)
756                                         log_begin_msg "Unrecognized archive extension for ${url}"
757                                         ;;
758                         esac
759                 fi
760         done
761
762         if [ ${rc} != 0 ]
763         then
764             umount "${mountpoint}"
765         fi
766
767         return ${rc}
768 }
769
770 do_nfsmount ()
771 {
772         rc=1
773
774         modprobe -q nfs

3

Re: [PATCH] Initrd-patch to allow tftp tranfser for filesystem.squashfs

gparted is based on Debian live, so you can find the boot parameters of Debian live. One of the URLs you can refer to is:
http://clonezilla.org/clonezilla-live/l … -param.php

4

Re: [PATCH] Initrd-patch to allow tftp tranfser for filesystem.squashfs

I can not use fetch=tftp://1.2.3.4/path/filesystem.squashfs  in v0.4.4-1.  Did it been fixed?

5

Re: [PATCH] Initrd-patch to allow tftp tranfser for filesystem.squashfs

seanlv wrote:

I can not use fetch=tftp://1.2.3.4/path/filesystem.squashfs  in v0.4.4-1.  Did it been fixed?

What's your PXE server config ? Please post it completely.
It will be easier for us to see why.

6

Re: [PATCH] Initrd-patch to allow tftp tranfser for filesystem.squashfs

stevenshiau wrote:
seanlv wrote:

I can not use fetch=tftp://1.2.3.4/path/filesystem.squashfs  in v0.4.4-1.  Did it been fixed?

What's your PXE server config ? Please post it completely.
It will be easier for us to see why.

I believe it is not PXE server related. 

During the Clonezilla boot, all parametter in "fetch" will be transfer to tftp command.
for example, if fetch=tftp://1.2.3.4/path/filesystem.squashfs, then
tftp -g -b 10240 -r filesystem.squashfs -l /live/image/live/filesystem.squashfs 1.2.3.4/path

however, the expected result should be

tftp -g -b 10240 -r path/filesystem.squashfs -l /live/image/live/filesystem.squashfs 1.2.3.4

so there is a bug in the script, which performs transfer fetch's parametter to tftp's.

7

Re: [PATCH] Initrd-patch to allow tftp tranfser for filesystem.squashfs

seanlv wrote:
stevenshiau wrote:
seanlv wrote:

I can not use fetch=tftp://1.2.3.4/path/filesystem.squashfs  in v0.4.4-1.  Did it been fixed?

What's your PXE server config ? Please post it completely.
It will be easier for us to see why.

I believe it is not PXE server related. 

During the Clonezilla boot, all parametter in "fetch" will be transfer to tftp command.
for example, if fetch=tftp://1.2.3.4/path/filesystem.squashfs, then
tftp -g -b 10240 -r filesystem.squashfs -l /live/image/live/filesystem.squashfs 1.2.3.4/path

however, the expected result should be

tftp -g -b 10240 -r path/filesystem.squashfs -l /live/image/live/filesystem.squashfs 1.2.3.4

so there is a bug in the script, which performs transfer fetch's parametter to tftp's.

Yes, I think the live-initramfs has to be patched again. So far the filesystem.squashfs can only be put in the root dir of tftp server.