Results 1 to 2 of 2

Thread: Bug in minrt.gz:init from 7.2-7.4.2

  1. #1
    Junior Member registered user
    Join Date
    Aug 2007
    Posts
    16

    Bug in minrt.gz:init from 7.2-7.4.2

    Couldnt believed when i saw this go from 7.2-7.4.2 but the long wait for creation of knopix-data.img led me to this.
    first the comment from /init:
    # I thought that creating a sparse file would be quicker than writing
    # all data completely, but unfortunately, it has bad side effects if
    # the underlying FAT file system is fragmented. -KK
    # dd if="$src" of="$1" bs=1M seek="$(($2 - 1))" count=1


    No, Klause the fast way works with a ext2+ fs but it's the bug below that led you to believe it doesn't!
    Please correct me if I am wrong.Check the fix script below that changes 1 byte (what major work you save):



    The bug is described in the details of the fix script (all to fix one byte in the init script!!!!):

    #!/bin/bash
    # Rev: $Id: fixminirt.sh 618 2015-04-13 23:49:24Z knoppix $
    # Author: koolb@hotmail.com
    # Description: Fix minirt.gz to e2fsck knoppix-data.img from Knoppix7.2-4
    # for USB style installations on HD (or USB of course).
    # Usage: # optionally, specify addtional boot areas besides /mnt-system/boot,
    # eg /dev/sda2/boot
    # fixminitrt.sh [/path/to/additional/boot] # where {iso,sys}linux* dirs are
    #
    # Details:
    # This handles an issue Knoppix 7.2-4 for those booting off USB or have
    # multiple usb style boots to HD or otherwise.
    # This is bug in the minitrt/init script's checkfs() function
    # in Knoppix7.2-7.4.2. checkfs() which igores the file passed.
    # # checkfs partition filesystem
    # checkfs(){
    # local p="$1" ... # we assign to $p
    # ...
    # ... e2fsck -y "$h" ... # bug: uses $h instead of $p: fix $h -> $p
    # ...
    # }
    # This will find all minirt.gz files and update the init script in each.
    # . ~/scripts/functions - used for debugging shell scripts
    echo "$0 v$Revison$"
    export DFTDIRS=$(echo /mnt-system/boot/{sys,iso}linux*)
    export USRDIRS
    [ -d "$1" ] && USRDIRS=$(echo $1/{sys,iso}linux*)
    export MRBFN=minirt INIT="init"
    export MRTMP=$MRBFN MRIOZ=$MRBFN.gz
    export MRORG=$MRIOZ.org
    function abort() {
    echo "$@" && exit 1
    }
    sub patch() {
    local fn=$1
    echo "Patching $fn to $fn.new"
    sed -e 's/\(e2fsck.*\$\)h/\1p/' $fn > $fn.new || abort "No patch applied"
    }
    export src
    for src in $DFTDIRS $USRDIRS
    do if test -d $src && cd $src; then
    echo "Processing $src..."
    [ -n "$DBG" ] && set -x
    [ ! -e $MRORG ] && sudo cp -Ta $MRIOZ $MRORG # Backup
    [ ! -e $MRIOZ ] && sudo cp -Ta $MRORG $MRIOZ # Restore
    [ ! -w $MRIOZ ] && sudo chmod o+rw $MRIOZ
    export td="$(echo $src | sed 's@/@/tmp/@')/$MRBFN"
    export tfo=$td.org tfn=$td.new
    [ -d $td ] && sudo rm -rf $td
    mkdir -p $td || abort "$src: Unable to mkdir -p $td"
    echo "Extracting $src/$MRIOZ to $td && cd $td"
    mkdir -p $BOOTISO $BOOTSYS
    echo "Extracting $src/$MRIOZ to $td && cd $td"
    cd $td || abort "$td: Unable to cd $td"
    [ -e $INIT ] || gzip -dc $src/$MRIOZ | tee $tfo | sudo cpio --no-absolute-filenames -i -d -H newc || abort "$td: Unable to extract $MRIOZ "
    patch $INIT
    lines=$(diff $INIT $INIT.new|wc -l) || abort "$td: diff/patch failed."
    [ -w $INIT ] || sudo chmod o+w $INIT|| abort "$td: Unable to make $INIT writeable"
    if [ "$lines" -eq 4 -o "$lines" -eq 0 ]; then
    [ "$lines" -eq 0 ] && echo "$td: Already Patched but recreating..."
    [ -f $INIT.new ] && rm -f "$INIT" && mv "$INIT.new" "$INIT"
    echo "$td: Patch SUCCESS!. creating new $src/$MRIOZ..."
    find . | sudo cpio -o -H newc | tee $tfn | gzip -c > ../$MRIOZ ||
    abort "$td: Unable to create new ../$MRIOZ"
    sudo cp -v "../$MRIOZ" "$src/$MRIOZ" || abort "$td: cp ../$MRIOZ to $src failed: $(ls -l ../$MRIOZ)"
    for f in $tfo $tfn; do file $f; done
    else abort "$td: Bad patch, expected one change: $(diff $INIT $INIT.new)"
    fi
    for f in $src/$MRIOZ $src/$MRORG; do ls -l $f && sum $f; done
    fi
    done
    Last edited by koolb; 04-16-2015 at 11:57 PM.

  2. #2
    Junior Member registered user
    Join Date
    Aug 2007
    Posts
    16
    fixes: sub patch() # should be function patch()
    add chmod 755 $fn.new as last line of the patch() fn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Dell PowerEdge M610 Blade Server E5620@2.2GHZ (6x)8GB RAM (2x)146GB 15K SAS HDD picture

Dell PowerEdge M610 Blade Server E5620@2.2GHZ (6x)8GB RAM (2x)146GB 15K SAS HDD

$75.00



Supermicro 4U 36 Bay Storage Server 2.4Ghz 8-C 128GB 1x1280W Rails TrueNAS ZFS picture

Supermicro 4U 36 Bay Storage Server 2.4Ghz 8-C 128GB 1x1280W Rails TrueNAS ZFS

$721.06



H261-Z61 2U 24SFF AMD Server 8x EPYC 7551 256-Cores 256GB RAM 8x25G NIC 2x2200W picture

H261-Z61 2U 24SFF AMD Server 8x EPYC 7551 256-Cores 256GB RAM 8x25G NIC 2x2200W

$2512.18



Dell PowerEdge R630 8SFF 2.6Ghz 20-Core 128GB Mem 4x1G RJ-45 NIC 2x750W PSU picture

Dell PowerEdge R630 8SFF 2.6Ghz 20-Core 128GB Mem 4x1G RJ-45 NIC 2x750W PSU

$399.04



Dell PowerEdge R720XD Xeon E5-2680 V2 2.8GHz 20 Cores 256GB RAM 12x4TB picture

Dell PowerEdge R720XD Xeon E5-2680 V2 2.8GHz 20 Cores 256GB RAM 12x4TB

$510.00



DELL PowerEdge R730 Server 2x E5-2690v3 2.6GHz =24 Cores 32GB H730 4xRJ45 picture

DELL PowerEdge R730 Server 2x E5-2690v3 2.6GHz =24 Cores 32GB H730 4xRJ45

$275.00



Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 128GB RAM No HDD picture

Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 128GB RAM No HDD

$389.99



Dell PowerEdge R630 2x Xeon E5-2630 V4 2.20GHZ 128GB DDR4-2133MHZ 2x 750W PSU picture

Dell PowerEdge R630 2x Xeon E5-2630 V4 2.20GHZ 128GB DDR4-2133MHZ 2x 750W PSU

$170.95



Dell PowerEdge R620 Rack Server picture

Dell PowerEdge R620 Rack Server

$71.99



HP Proliant DL360 Gen9 28 Core SFF Server 2X E5-2680 V4 16GB RAM P440ar No HDD picture

HP Proliant DL360 Gen9 28 Core SFF Server 2X E5-2680 V4 16GB RAM P440ar No HDD

$191.95