Menu

FYI: script to remaster Clonezilla iso file

ggsf
2009-10-26
2013-04-05
  • ggsf

    ggsf - 2009-10-26

    According to Clonezilla FAQ/Q&A, question "40. How can I remaster Clonezilla iso file ?" I have been using the script provided by Casual J. Programmer
    http://www.freewebs.com/casualprogrammer/Downloads/editCZCD
    to remaster Clonezilla iso file.

    This very useful script ,is for previous versions of Clonezilla that used the /pkg/opt_drbl.tgz file for the Clonezilla related files.

    Since version 1.2.0-1, a squashfs filesystem is used, so a modified version of the script must be used.

    I did not find an option to attach the file so i add it "inline" to this text (following the script there are same instructions to use it)

    --- Begin script ---

        #!/bin/sh

        # editCZCD version Fr 11. Jan 18:02:48 CET 2008

        # Use the editCzCD script to modify clonezilla live cd content and burn a CD from it.

        # Copyright (C) Casual J. Programmer <cprogrammer@users.sourceforge.net> partially

        # based on script ocs-iso by Steven Shiau <steven _at_ nchc org tw>

        # The script is provided as is under GPL, no responsibilty taken for any damage caused using it.

        # Suggestions and Feedback welcome, have a lot of fun …

        # Maybe freely used and copied provided this header remains intact.

        # Tecnología de la Información <ti@imm.gub.uy>

        # Modified to handle new versions of Clonezilla (since 1.2.0-1) which use squashfs

        # Use genisoimage instead of mkisofs. genisoimage is a fork of mkisofs

        # Details on mkisofs with man mkisofs. Parameters used here:

        #

        # -A Application ID written to Volume Header

        # -b Eltorito boot image

        # -boot-load-size Load # sectors on boot

        # -c Boot catalog, required for eltorito CD

        # -J Generate Joliet directory records

        # -r Files and directories are globally readable on the client.

        # -l Allow full 31-character filenames

        # -no-emul-boot No disk emulation for boot

        # -o Filename of the iso image to generate

        # -p Preparer

        # -publisher

        # -V Volume label-V $VOLUME

        #CZVERSION="clonezilla-live-1.0.9-1.iso"

        CZVERSION="clonezilla-live-1.2.2-31.iso"

        #Set to the version you want to use, for details see http://clonezilla.sourceforge.net/

        PREFIX="cjp-"

        ISO_FILE="${PREFIX}${CZVERSION}"

        APPLICATION="Clonezilla Live CD"

        PUBLISHER="DRBL/Clonezilla http://drbl.name http://clonezilla.org"

        #Leave application and publisher alone

        VOLUME="CJP's special CZCD"

        PREPARER="Casual J. Programmer <cprogrammer@users.sourceforge.net>"

        #Set volume to your liking, preparer to your name and email or leave blank

        DLFROM="http://mesh.dl.sourceforge.net/sourceforge/clonezilla"

        # http://puzzle.dl.sourceforge.net/sourceforge/clonezilla

        # The download host that suits you best

        BASEDIR=/tmp

        TMPDIRO=$BASEDIR/clonezilla

        TMPDIRN=$BASEDIR/clonezillan

        MAKE="-makeiso"

        ##OUTPUTDEV=$(cdrecord -devices | grep 0 | cut -characters=10-18)

        #may be /dev/scd0 or other on your system, use cdrecord -devices to identify

        # use wodim instead of cdrecord. wodim is a fork of cdrecord

        # identify devices only when -b is specified

        #OUTPUTDEV=$(wodim -devices | grep 0 | cut -delimiter=\' -fields=2)

        if ; then

          echo "$0 should be run as root!"

          exit 1

        fi

        if ! type genisoimage &>/dev/null; then

          echo "Program genisoimage is not available! You have to install it."

          exit 1

        fi

        if ; then

          if ! type wodim &>/dev/null; then

            echo "Program wodim is not available! You have to install it."

            exit 1

          fi

          OUTPUTDEV=$(wodim -devices | grep 0 | cut -delimiter=\' -fields=2)

           && echo "-b option specified but no drive found!" && exit 1

        fi

        if ! type unsquashfs &>/dev/null; then

          echo "Program unsquashfs is not available! You have to install it."

          exit 1

        fi

        if ! type mksquashfs &>/dev/null; then

          echo "Program mksquashfs is not available! You have to install it."

          exit 1

        fi

        rm -rf $TMPDIRO

        rm -rf $TMPDIRN

        if ; then

            wget -P $BASEDIR $DLFROM/$CZVERSION

        fi

        mkdir $TMPDIRO

        mkdir $TMPDIRN

        echo "Preparing to decompress filesystem.squashfs…"

        mount -o loop $BASEDIR/$CZVERSION $TMPDIRO

        cp -a $TMPDIRO/* $TMPDIRN

        ##chmod -R 755 $TMPDIRN

        umount $TMPDIRO

        ##cd $TMPDIRN/pkg

        ##tar xzf opt_drbl.tgz

        cd $TMPDIRN/live

        unsquashfs filesystem.squashfs

        echo "Now edit any part of clonezilla live-cd in ${TMPDIRN}/live/squashfs-root/opt/drbl/"

        echo "when finished leave this shell by typing exit, if called with -b option"

        echo "place an empty CD or CD/RW in the drive."

        ##cd $TMPDIRN/pkg/opt/drbl

        cd $TMPDIRN/live/squashfs-root/opt/drbl

        sh

        echo "modified on $(date) by $PREPARER" >> $TMPDIRN/"Clonezilla-Live-Version"

        ##cd $TMPDIRN/pkg

        ##tar czf opt_drbl.tgz opt

        ##rm -rf opt

        echo "Creating new filesystem.squashfs…"

        cd $TMPDIRN/live/

        #

        blocksize=$(unsquashfs -s filesystem.squashfs | grep "Block size" | awk '{print $3}')

        b=""

        if

        then

          b="-b $blocksize"

        fi

        rm -f filesystem.squashfs

        mksquashfs squashfs-root filesystem.squashfs $b

        rm -rf squashfs-root

        cd $BASEDIR

        echo "Creating $BASEDIR/$ISO_FILE…"

        # use genisoimage instead of mkisofs. genisoimage is a fork of mkisofs

        genisoimage \

         -A "$APPLICATION" \

         -V "$VOLUME" \

         -p "$PREPARER" -publisher "$PUBLISHER" \

         -b isolinux/isolinux.bin -c isolinux/boot.cat \

         -no-emul-boot -boot-load-size 4 -boot-info-table \

          -r -J -l -input-charset iso8859-1 $TMPDIRN | \

          (

           case "$1" in

            "-b")

               umount $OUTPUTDEV 2>/dev/null

               ##cdrecord -dev=$OUTPUTDEV blank=fast

               ##cdrecord dev=$OUTPUTDEV -data -eject -v -

               wodim dev=$OUTPUTDEV blank=fast

               wodim dev=$OUTPUTDEV -data -eject -v -

               echo "Created $VOLUME"

               ;;

            *)

               # use /dev/stdout as the bridge

               cat - > $BASEDIR/$ISO_FILE

               echo "Created $BASEDIR/$ISO_FILE"

               ;;

           esac

          )

        if type isohybrid &>/dev/null; then

          if ; then

            echo -n "Isohybriding $BASEDIR/$ISO_FILE… "

            isohybrid $BASEDIR/$ISO_FILE

            echo "done!"

          fi

        fi

        # end editCZCD

    --- End script ---

    Instructions to use the script

    1- Copy the code to a file, for example  editCZCDsquashfs.sh
    2- Give it execute permissions:
        chmox +x  editCZCDsquashfs.sh
    3- Set the variable CZVERSION to the version you want to remaster
    4- Copy the version of Clonezilla you want to remaster to /tmp/ (otherwise the file will be downloaded form Internet, by default from the host defined in the variable DLFROM)
    5- run the script as root, make any necesary changes and when done leave by typing exit, if called with -b option" place an empty CD or CD/RW in the drive. (this was not tested)

    Prerequisites:

    The following software must be installed for the script to work

    syslinux (at least version 3.80)
    genisoimage (Tested with version 1.1.9)
    wodim (version 1.1.6. Used with version -b, not tested)
    squashfs-tools (for unsquashfs and mksquashfs)
    isohybrid (optional, for "Isohybriding" the iso file)

    I installed a virtual machine (using VirtualBox) with Debian lenny, kernel 2.6.29, squashfs-tools 4.0 and syslinux 3.80 from backports.undebian.org

    The squashfs filesystem with the Clonezilla files is version 4.0 so the 2.6.29 kernel was used.

    To add the backports repository:

    For the kernel:

    Add the following line to your /etc/apt/sources.list:

    deb http://backports.undebian.org/repositories/backports-kernel/ ./

    Add the key:

    wget -q -O - http://backports.undebian.org/repositories/backports-kernel/archive-key.asc | apt-key add -

    for syslinux

    deb http://backports.undebian.org/repositories/backports-other/ ./

    It is not necessary to add the key from /backports-other/archive-key.asc, it is the same that the key added for the kernel from /backports-kernel/archive-key.asc

    Best regards

     
  • ggsf

    ggsf - 2009-10-26

    Sorry, but by using "Markdown syntax" for the code, there are characters that make it useless as a script

    Sending it without pretty formating, but since i can't (do not know how to) preview it i do not know what th result may be…

    --- Begin script ---

    #!/bin/sh
    # editCZCD version Fr 11. Jan 18:02:48 CET 2008
    # Use the editCzCD script to modify clonezilla live cd content and burn a CD from it.
    # Copyright (C) Casual J. Programmer <cprogrammer@users.sourceforge.net> partially
    # based on script ocs-iso by Steven Shiau <steven _at_ nchc org tw>
    # The script is provided as is under GPL, no responsibilty taken for any damage caused using it.
    # Suggestions and Feedback welcome, have a lot of fun …
    # Maybe freely used and copied provided this header remains intact.

    # Tecnología de la Información <ti@imm.gub.uy>
    # Modified to handle new versions of Clonezilla (since 1.2.0-1) which use squashfs

    # Use genisoimage instead of mkisofs. genisoimage is a fork of mkisofs
    # Details on mkisofs with man mkisofs. Parameters used here:
    #
    # -A Application ID written to Volume Header
    # -b Eltorito boot image
    # -boot-load-size Load # sectors on boot
    # -c Boot catalog, required for eltorito CD
    # -J Generate Joliet directory records
    # -r Files and directories are globally readable on the client.
    # -l Allow full 31-character filenames
    # -no-emul-boot No disk emulation for boot
    # -o Filename of the iso image to generate
    # -p Preparer
    # -publisher
    # -V Volume label-V $VOLUME

    #CZVERSION="clonezilla-live-1.0.9-1.iso"
    CZVERSION="clonezilla-live-1.2.2-31.iso"
    #clonezilla-live-1.0.7-18.iso
    #Set to the version you want to use, for details see http://clonezilla.sourceforge.net/

    PREFIX="cjp-"
    ISO_FILE="${PREFIX}${CZVERSION}"

    APPLICATION="Clonezilla Live CD"
    PUBLISHER="DRBL/Clonezilla http://drbl.name http://clonezilla.org"
    #Leave application and publisher alone

    VOLUME="CJP's special CZCD"
    PREPARER="Casual J. Programmer <cprogrammer@users.sourceforge.net>"
    #Set volume to your liking, preparer to your name and email or leave blank

    DLFROM="http://mesh.dl.sourceforge.net/sourceforge/clonezilla"
    # http://puzzle.dl.sourceforge.net/sourceforge/clonezilla
    # The download host that suits you best

    BASEDIR=/tmp
    TMPDIRO=$BASEDIR/clonezilla
    TMPDIRN=$BASEDIR/clonezillan
    MAKE="-makeiso"
    ##OUTPUTDEV=$(cdrecord -devices | grep 0 | cut -characters=10-18)
    #may be /dev/scd0 or other on your system, use cdrecord -devices to identify

    # use wodim instead of cdrecord. wodim is a fork of cdrecord
    # identify devices only when -b is specified
    #OUTPUTDEV=$(wodim -devices | grep 0 | cut -delimiter=\' -fields=2)

    if ; then
      echo "$0 should be run as root!"
      exit 1
    fi

    if ! type genisoimage &>/dev/null; then
      echo "Program genisoimage is not available! You have to install it."
      exit 1
    fi

    if ; then
      if ! type wodim &>/dev/null; then
        echo "Program wodim is not available! You have to install it."
        exit 1
      fi
      OUTPUTDEV=$(wodim -devices | grep 0 | cut -delimiter=\' -fields=2)
       && echo "-b option specified but no drive found!" && exit 1
    fi

    if ! type unsquashfs &>/dev/null; then
      echo "Program unsquashfs is not available! You have to install it."
      exit 1
    fi

    if ! type mksquashfs &>/dev/null; then
      echo "Program mksquashfs is not available! You have to install it."
      exit 1
    fi

    rm -rf $TMPDIRO
    rm -rf $TMPDIRN

    if ; then
            wget -P $BASEDIR $DLFROM/$CZVERSION
    fi

    mkdir $TMPDIRO
    mkdir $TMPDIRN

    echo "Preparing to decompress filesystem.squashfs…"
    mount -o loop $BASEDIR/$CZVERSION $TMPDIRO

    cp -a $TMPDIRO/* $TMPDIRN
    ##chmod -R 755 $TMPDIRN

    umount $TMPDIRO

    ##cd $TMPDIRN/pkg
    ##tar xzf opt_drbl.tgz

    cd $TMPDIRN/live
    unsquashfs filesystem.squashfs

    echo "Now edit any part of clonezilla live-cd in ${TMPDIRN}/live/squashfs-root/opt/drbl/"
    echo "when finished leave this shell by typing exit, if called with -b option"
    echo "place an empty CD or CD/RW in the drive."

    ##cd $TMPDIRN/pkg/opt/drbl
    cd $TMPDIRN/live/squashfs-root/opt/drbl

    sh

    echo "modified on $(date) by $PREPARER" >> $TMPDIRN/"Clonezilla-Live-Version"
    ##cd $TMPDIRN/pkg
    ##tar czf opt_drbl.tgz opt
    ##rm -rf opt

    echo "Creating new filesystem.squashfs…"
    cd $TMPDIRN/live/
    #
    blocksize=$(unsquashfs -s filesystem.squashfs | grep "Block size" | awk '{print $3}')
    b=""
    if
    then
      b="-b $blocksize"
    fi
    rm -f filesystem.squashfs
    mksquashfs squashfs-root filesystem.squashfs $b
    rm -rf squashfs-root
    cd $BASEDIR

    echo "Creating $BASEDIR/$ISO_FILE…"
    # use genisoimage instead of mkisofs. genisoimage is a fork of mkisofs
    genisoimage \
    -A "$APPLICATION" \
    -V "$VOLUME" \
    -p "$PREPARER" -publisher "$PUBLISHER" \
    -b isolinux/isolinux.bin -c isolinux/boot.cat \
    -no-emul-boot -boot-load-size 4 -boot-info-table \
      -r -J -l -input-charset iso8859-1 $TMPDIRN | \
      (
       case "$1" in
        "-b")
           umount $OUTPUTDEV 2>/dev/null
           ##cdrecord -dev=$OUTPUTDEV blank=fast
           ##cdrecord dev=$OUTPUTDEV -data -eject -v -
           wodim dev=$OUTPUTDEV blank=fast
           wodim dev=$OUTPUTDEV -data -eject -v -
           echo "Created $VOLUME"
           ;;
        *)
           # use /dev/stdout as the bridge
           cat - > $BASEDIR/$ISO_FILE
           echo "Created $BASEDIR/$ISO_FILE"
           ;;
       esac
      )

    if type isohybrid &>/dev/null; then
      if ; then
        echo -n "Isohybriding $BASEDIR/$ISO_FILE… "
        isohybrid $BASEDIR/$ISO_FILE
        echo "done!"
      fi
    fi

    # end editCZCD

    --- End script ---

     
  • ggsf

    ggsf - 2009-10-26

    useless too, what a shame…

    In the first, formatted script it's necessary to convert those HTML entities…

     
  • Steven Shiau

    Steven Shiau - 2009-10-28

    Gsusterman,

    Could you please send that to me (steven _at_ nchc org tw)

    BTW, I have suggested to sourceforge that we should have a way to escape the "Markdown syntax", i.e. we should be able to choose not to use that for the whole post, not just a few lines. However, looks like it's not accepted…

    Steven.

     
  • ggsf

    ggsf - 2009-10-28

    I have sent the script.

    This reply is only to confirm that i read your reply and i sent the script.
    Just in case the mail does not arrive you do not have to wonder whether the mail was sent or not. 

     
  • ggsf

    ggsf - 2009-10-29

    The formatting in the original message appears to have been "magically" fixed

    i would be very interested to know how

     

Log in to post a comment.