Changeset 3692


Ignore:
Timestamp:
Oct 7, 2017, 1:30:27 AM (12 days ago)
Author:
bruno
Message:

mindi reorganization:

  • Auto computes now the space needed for initrd reducing the role and importance of EXTRA_SPACE
  • MakeBootInitFile? split with a new PrepareTargetDir? (work done in a dir before packing to compute size) mount of that dir is split and realized later on
  • PrepareDataDiskImage? => PrepareBigDir? (idem)
  • PrepareAllTar? => PrepareBigDirTar? (same changes)
  • Adds CleanBigDir? and CleanTargetDir? to allow cleanup separately
  • use now 2 global variable bigdir and targetdir to manage the related contents
  • Use the RAMDISK_SIZE macro in boot file that will be substitued later on when size of ramdisk is known and adds a PatchBootFiles? function for that
  • Review local variables
  • mr-process-ldd doesn't report the files passed as parameters so adding them
Location:
branches/3.3/mindi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi/mindi

    r3688 r3692  
    4444fi
    4545
    46 EXTRA_SPACE=200000      # increase if you run out of ramdisk space
     46EXTRA_SPACE=20000       # increase if you run out of ramdisk space - Default 20 MB
    4747
    4848PROMPT_MAKE_CD_IMAGE="yes"
     
    195195
    196196Die() {
    197     local i
    198197    if [ "$1" = "" ] ; then
    199198        LogAll "FATAL ERROR"
     
    230229
    231230AbortHere() {
    232     [ "$mountpoint" ] && sync && umount $mountpoint 2>> $LOGFILE
    233231    Die "Program is terminating in response to signal received from OS/user"
    234232}
     
    716714
    717715GenerateListForFile() {
    718     local files_found loc fname incoming i res
     716    local files_found fname incoming
    719717    incoming="$1"
    720718    files_found=""
    721     res=0
    722719
    723720    for fname in $incoming ; do
     
    832829
    833830ListAllPartitions() {
    834     local res currline partition all_partitions ap_orig remaining i j
    835 
    836831    grep -Evx " *#.*| *none.*" $MY_FSTAB | $AWK '/^\/dev\/[imhs]d||^LABEL=\/|^UUID=/ && !/\/fdd|\/cdr|\/zip|\/floppy/ {print $1}'
    837832    [ -e "/etc/raidtab" ] && $AWK '/^ *device/ {print $2}' /etc/raidtab
     
    905900        fi
    906901    done
    907     mr-read-all-link `mr-process-ldd $deps | sort -u` | sort -u
     902    mr-read-all-link `mr-process-ldd $deps | sort -u` $deps | sort -u
    908903}
    909904
    910905
    911906LocateFile() {
    912     local i j path fname_to_find location output resolved tmp stub cache_id loclist
     907    local j dn newdn bn path fname_to_find output
    913908    fname_to_find="$1"
    914909    # It's an absolute path
     
    976971}
    977972
    978 # Called by MakeBootInitFile, to make /tmp/$MRCFG
     973# Called by PrepareTargetDir, to make /tmp/$MRCFG
    979974MakeMondoConfigFile() {
    980     local outfile use_lzo use_comp use_star
     975    local outfile use_lzo use_comp use_star use_gzip use_lzma
    981976    outfile=$1
    982977    > $outfile
     
    10221017# Get PV's for an LV
    10231018GetPVsForLV() {
     1019    local vg
     1020
    10241021    if [ -n "$1" ]; then
    10251022        vg=`$LVMCMD lvdisplay $1 2>/dev/null |awk '/VG Name/{print $NF;exit}'`
     
    15461543fi
    15471544
    1548 # copy boot stuff now generated in PrepareDataDiskImage
     1545# copy boot stuff now generated in PrepareBigDir
    15491546if [ "$BOOT_TYPE" = "UEFI" ]; then
    15501547    (cd $MINDI_TMP/target ; tar xfz $MINDI_CACHE/all.tar.gz ./EFI)
     
    16301627du -sk $MINDI_TMP/target/* >> $LOGFILE
    16311628LogFile "------------------------------------------"
     1629LogFile "Kernel size = `du -sk $kernelpath | cut -f1` K"
     1630LogFile "--------------------------------"
    16321631
    16331632if [ "$retval" -ne "0" ] ; then
    1634     LogFile "--------------------------------"
    1635     LogFile "INFO: Size of $MINDI_TMP/target:"
    1636     du -sk $MINDI_TMP/target/* >> $LOGFILE
    1637     LogFile "--------------------------------"
    1638     echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n" >> $LOGFILE
    16391633    sync
    16401634    umount $MINDI_TMP/target
    16411635    LogAll "ERROR: Problems while creating boot media."
    16421636    LogAll "       Please unload some of your modules and try again."
    1643     Die    "       Try to increase EXTRA_SPACE in $MINDI_CONFIG"
     1637    Die    "       Try using another temporary directory instead of $MINDI_TMP"
    16441638fi
    16451639
     
    17711765    LogAll "ERROR: Problems while creating boot media."
    17721766    LogAll "       Please unload some of your modules and try again."
    1773     Die    "       Try to increase EXTRA_SPACE in $MINDI_CONFIG"
     1767    Die    "       Try using another temporary directory instead of $MINDI_TMP"
    17741768fi
    17751769
     
    18111805    cp $part $MINDI_CACHE
    18121806    if [ "$ARCH" = "ia64" ] || [ "$BOOT_TYPE" = "UEFI" ]; then
     1807        # Mount again !
     1808        LogAll "INFO: Re-Mounting $part on $MINDI_TMP/mpt"
     1809        mount -t vfat $mount_opt $part $MINDI_TMP/mpt 2>> $LOGFILE
    18131810        # We just need the EFI dir and the boot image for this case
    18141811        mkdir -p $MINDI_TMP/mpt2 $MINDI_TMP/mpt/images $MINDI_TMP/mpt/archives
     
    19001897
    19011898MakeBootableDevice ISO
    1902 
    19031899}
    19041900
     
    20412037        [ "$ooo" = "RESTORE" ] && ooo="RESTORE nuke"
    20422038        if [ "$type" = "elilo" ]; then
    2043             outstr="image=/vmlinuz\n\tlabel=$i\n\tinitrd=/initrd.img\n\troot=/dev/ram0 append=\" rw ramdisk_size=$ramdisk_size $ooo $MINDI_ADDITIONAL_BOOT_PARAMS \"\n"
     2039            outstr="image=/vmlinuz\n\tlabel=$i\n\tinitrd=/initrd.img\n\troot=/dev/ram0 append=\" rw ramdisk_size=RAMDISK_SIZE $ooo $MINDI_ADDITIONAL_BOOT_PARAMS \"\n"
    20442040        elif [ "$type" = "grub" ]; then
    2045             outstr="title $i\n\tkernel /vmlinuz root=/dev/ram0 rw ramdisk_size=$ramdisk_size ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n\tinitrd=/initrd.img\n"
     2041            outstr="title $i\n\tkernel /vmlinuz root=/dev/ram0 rw ramdisk_size=RAMDISK_SIZE ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n\tinitrd=/initrd.img\n"
    20462042        elif [ "$type" = "grub2" ]; then
    20472043            if [ "$BOOT_TYPE" = "UEFI" ]; then
     
    20522048                iorder="initrd"
    20532049            fi
    2054             outstr="menuentry '$i' {\n\tinsmod all_video\n\tinsmod gzio\n\tinsmod part_msdos\n\tinsmod part_gpt\n\tinsmod ext2\n\tinsmod xfs\n\techo 'Loading kernel...'\n\t$lorder /vmlinuz root=/dev/ram0 rw ramdisk_size=$ramdisk_size ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n\techo 'Loading ramdisk...'\n\t$iorder /initrd.img\n}\n"
     2050            outstr="menuentry '$i' {\n\tinsmod all_video\n\tinsmod gzio\n\tinsmod part_msdos\n\tinsmod part_gpt\n\tinsmod ext2\n\tinsmod xfs\n\techo 'Loading kernel...'\n\t$lorder /vmlinuz root=/dev/ram0 rw ramdisk_size=RAMDISK_SIZE ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n\techo 'Loading ramdisk...'\n\t$iorder /initrd.img\n}\n"
    20552051        else
    20562052            ps="/"
    20572053            if [ $KERNEL_IS_XEN = "no" ]; then
    2058                 outstr="label $i\n\tkernel ${ps}vmlinuz\n\tappend initrd=${ps}initrd.img root=/dev/ram0 rw ramdisk_size=$ramdisk_size ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n"
     2054                outstr="label $i\n\tkernel ${ps}vmlinuz\n\tappend initrd=${ps}initrd.img root=/dev/ram0 rw ramdisk_size=RAMDISK_SIZE ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS\n"
    20592055            else
    2060                 outstr="label $i\n\tkernel ${ps}mboot.c32\n\tappend ${ps}xen.gz --- ${ps}vmlinuz root=/dev/ram0 rw ramdisk_size=$ramdisk_size  ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS --- ${ps}initrd.img\n"
     2056                outstr="label $i\n\tkernel ${ps}mboot.c32\n\tappend ${ps}xen.gz --- ${ps}vmlinuz root=/dev/ram0 rw ramdisk_size=RAMDISK_SIZE  ${ooo} $MINDI_ADDITIONAL_BOOT_PARAMS --- ${ps}initrd.img\n"
    20612057            fi
    20622058        fi
     
    21032099PrepareBootDir() {
    21042100
    2105         local detect
    2106 # Needs a bigdir variable setup before calling it
     2101    local detect
     2102    # Needs a bigdir variable setup before calling it
    21072103
    21082104    # copy (e)lilo/isolinux/grub/whatever stuff into it as well
     
    22342230    fi
    22352231
    2236     # Here we need to know the ramdisk_size
    2237     size_of_all_tools=`du -sk $bigdir | cut -f1`
    2238     export ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE))
    2239     LogFile "INFO: Ramdisk will be $ramdisk_size KB"
    2240 
    22412232    MakeBootConfFile $boottype > $bootconf
    22422233    LogFile "Boot Conf file $bootconf content is:"
     
    22552246}
    22562247
    2257 PrepareAllTar() {
     2248PrepareBigDirTar() {
    22582249    echo -en "INFO: Tarring and zipping the data content..."
    22592250    (cd "$bigdir" ; tar -b 4096 -cf - . 2>> $MINDI_TMP/$$.log | gzip -9 > $MINDI_CACHE/all.tar.gz || LogAll "ERROR: Problem creating all.tar.gz" $MINDI_TMP/$$.log)
     
    22642255    echo -e "$DONE"
    22652256
    2266     [ "$bigdir" != "/" ] && rm -rf $bigdir
    2267 }
    2268 
    2269 PrepareDataDiskImages() {
    2270     local needlist bigdir diskdir res i j k lines lfiles includefile
     2257}
     2258
     2259CleanBigDir() {
     2260    [ "$bigdir" != "/" ] && echo $bigdir | grep -vq $MINDI_TMP && rm -rf $bigdir
     2261}
     2262
     2263PrepareBigDir() {
     2264    local needlist diskdir res i j k lines lfiles includefile
    22712265
    22722266    rm -f $MINDI_CACHE/mindi.iso
    22732267    needlist=$MINDI_TMP/what-we-need.txt
    2274     bigdir=$MINDI_TMP/bigdir
    22752268    mkdir -p $bigdir/usr/bin
    22762269    mkdir -p $bigdir/usr/sbin
     
    23442337        cp -a /lib/dev-state $bigdir/lib/ 2>> $MINDI_TMP/$$.log || LogAll "ERROR: Unable to handle /lib/dev-state" $MINDI_TMP/$$.log
    23452338    fi
    2346     TOTAL_BIGDIR_SIZE=`du -sk $bigdir | cut -f1`
    23472339    MakeMountlist $MINDI_TMP/mountlist.txt
    23482340    CheckMountlist $MINDI_TMP/mountlist.txt
     
    23792371
    23802372    PrepareBootDir
    2381     PrepareAllTar
     2373
    23822374}
    23832375
     
    26202612
    26212613    conf=$1
     2614    mp=$2
    26222615    echo -en "INFO: Gathering dependencies of $conf.conf..."
     2616    LogFile "INFO: Gathering dependencies of $conf.conf..."
    26232617    lis2=`grep -Ev '^#' $DEPLIST_DIR/$conf.conf | sort -u`
    26242618    noof_lines=`echo $lis2 | wc -w`
     
    26442638    done
    26452639    echo -e "$DONE"
    2646     echo "INFO: Processing all dependencies links for $conf.conf..."
     2640    LogAll "INFO: Processing all dependencies links for $conf.conf..."
    26472641    # And their deps except dirs
    26482642    lines=`sort -u $MINDI_TMP/$conf.lis $MINDI_TMP/$conf.lis2`
     
    26532647    # recent bash says that -d is true for a link to a dir !
    26542648    for f in $lines; do
    2655     #for f in `sort -u $MINDI_TMP/$conf.lis`; do
    26562649        if [ -e "$f" -a ! -d "$f" ] || [ -h "$f" ]; then
    26572650            # Do not overwrite files already in destination (avoid using option -n of cp not portable)
    2658             if [ ! -e "$mountpoint/$f" ]; then
     2651            if [ ! -e "$mp/$f" ]; then
    26592652                finallist="$finallist $f"
    26602653            fi
     
    26622655    done
    26632656    # But adds the directory useful in $lis3
    2664     fnllist=`echo $finallist | tr ' ' '\n' | sort -u | tr '\n' ' '`
    2665     LogFile "INFO: Copying $conf related files with cp -a --parents $fnllist $lis3 -t $mountpoint/"
    2666     cp -a --parents $fnllist $lis3 -t $mountpoint/ 2> $templog  || LogAll "WARNING: Problem in $conf analysis" $templog
     2657    fnllist=`echo $finallist $lis3 | tr ' ' '\n' | sort -u | tr '\n' ' '`
     2658    LogFile "INFO: Copying $conf related files with cp -a --parents $fnllist -t $mp/"
     2659    cp -a --parents $fnllist -t $mp/ 2> $templog  || LogAll "WARNING: Problem in $conf analysis" $templog
    26672660    rm -f $MINDI_TMP/$conf.lis
    26682661}
    26692662
    2670 MakeBootInitFile() {
    2671     local tgz_dir_fname rdz_fname tempfile nodes kernelsize res currsize not_copied j k s w needed_modules_path d thelink templog
    2672 
    2673     tgz_dir_fname=$1
    2674     rdz_fname=$2
    2675     kernelsize=$3
    2676     tempfile=$MINDI_TMP/temp.rd
     2663PrepareTargetDir() {
     2664    local tgz_dir_fname nodes kernelsize res currsize not_copied j k s w needed_modules_path d thelink templog
     2665
     2666    tgz_dir_fname=$MINDI_LIB/rootfs
     2667    rdz_fname=$MINDI_TMP/initrd.img
     2668    kernelsize=`du -sk $kernelpath | cut -f1`
    26772669    res=0
    26782670    templog=$MINDI_TMP/$$.log
    26792671    > $templog
    26802672
    2681     LogAll "INFO: Making Boot RAM Disk ($ramdisk_size KB)"
    2682     dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (MakeBootInitFile)"
    2683     LogAll "INFO: Creating ext2 filesystem on $tempfile"
    2684     mke2fs -b 1024 -m 1 -i 2048 -F $tempfile >> $LOGFILE 2>> $LOGFILE || Die "Unable to create an ext2 file system on $tempfile"
    2685     mkdir -p $mountpoint
    2686     mount -t ext2 -o loop $tempfile $mountpoint || Die "Cannot loopmount $tempfile to $mountpoint! The reason may be missing support for loopfs or ext2 (or both) in the running kernel."
    2687 
     2673    mkdir -p $targetdir
    26882674    # Check whether /lib64 or /lib or /sbin or /bin is a link and if so explicitly create one in rootfs (Fedora 17 crazyness)
    26892675    for d in bin sbin lib lib64; do
    26902676        if [ -h "/$d" ]; then
    26912677            thelink=`readlink /$d`
    2692             mkdir -p $mountpoint/$thelink || LogAll "ERROR: Unable to create $thelink in $mountpoint."
    2693             mv $mountpoint/$d/* $mountpoint/$d/.??* $mountpoint/$thelink 2> /dev/null
    2694             if [ -d "$mountpoint/$d" -a ! -h "$mountpoint/$d" ]; then
    2695                 rmdir $mountpoint/$d
    2696             fi
    2697             if [ ! -h $mountpoint/$d ]; then
    2698                 rm -f $mountpoint/$d 2> /dev/null
    2699                 (cd $mountpoint ; ln -s $thelink $d) || LogAll "ERROR: /$d is a symbolic link, but I couldn't create it in $mountpoint."
     2678            mkdir -p $targetdir/$thelink || LogAll "ERROR: Unable to create $thelink in $targetdir"
     2679            mv $targetdir/$d/* $targetdir/$d/.??* $targetdir/$thelink 2> /dev/null
     2680            if [ -d "$targetdir/$d" -a ! -h "$targetdir/$d" ]; then
     2681                rmdir $targetdir/$d
     2682            fi
     2683            if [ ! -h $targetdir/$d ]; then
     2684                rm -f $targetdir/$d 2> /dev/null
     2685                (cd $targetdir ; ln -s $thelink $d) || LogAll "ERROR: /$d is a symbolic link, but I couldn't create it in $targetdir"
    27002686            fi
    27012687        fi
    27022688    done
    27032689
    2704     LogFile "INFO: what is now in $mountpoint"
    2705     ls -al $mountpoint >> $LOGFILE
     2690    LogFile "INFO: what is now in $targetdir"
     2691    ls -al $targetdir >> $LOGFILE
    27062692   
    27072693    # Check files before copying to discover configuration issues or McAfee preventing mindi reading these files
    2708     # copy from rootfs into mountpoint
    2709     LogAll "INFO: Copying Mindi files onto $mountpoint"
     2694    # copy from rootfs into targetdir
     2695    LogAll "INFO: Copying Mindi files onto $targetdir"
    27102696    for f in $tgz_dir_fname/*; do
    27112697        if [ ! -r $f ]; then
    27122698            Die "ERROR: Unable to copy $f to the target dir. Check your installation or McAfee presence"
    27132699        else
    2714             cp -af $f $mountpoint 2>&1 >> $LOGFILE
     2700            cp -af $f $targetdir 2>&1 >> $LOGFILE
    27152701        fi
    27162702    done
    2717     (cd $mountpoint/etc ; ln -sf bashrc profile ; ln -sf bashrc shrc ; ln -sf ../proc/mounts mtab ; ln -sf ../usr/sbin/init linuxrc)
    2718     (cd $mountpoint ; ln -sf usr/sbin/init linuxrc)
    2719 
    2720     (cd $mountpoint/dev ; tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz" ; rm -f dev-entries.tgz)
     2703    (cd $targetdir/etc ; ln -sf bashrc profile ; ln -sf bashrc shrc ; ln -sf ../proc/mounts mtab ; ln -sf ../usr/sbin/init linuxrc)
     2704    # kernel expects linuxrc in ext2 filesystem
     2705    (cd $targetdir ; ln -sf usr/sbin/init linuxrc)
     2706    # kernel expects init in cpio filesystem
     2707    (cd $targetdir ; ln -sf usr/sbin/init init)
     2708
     2709    (cd $targetdir/dev ; tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz" ; rm -f dev-entries.tgz)
    27212710
    27222711    for w in insmod.static insmod.static.old ; do
    27232712        s=`which $w 2> /dev/null`
    27242713        if [ -e "$s" ] ; then
    2725             tar cf - -C / $s 2> /dev/null | (cd $mountpoint ; tar xf -)
     2714            tar cf - -C / $s 2> /dev/null | (cd $targetdir ; tar xf -)
    27262715        fi
    27272716    done
     
    27302719   
    27312720    # Copy of files mandatory for ssh to automate mount if sshfs is used
    2732     mkdir -p $mountpoint/.ssh $mountpoint/tmp
    2733     cp -a ~root/.ssh/* $mountpoint/.ssh 2> /dev/null
    2734     cat > $mountpoint/tmp/myssh << EOF
    2735 ssh -o StrictHostKeyChecking=no $*
     2721    mkdir -p $targetdir/.ssh $targetdir/tmp
     2722    cp -a ~root/.ssh/* $targetdir/.ssh 2> /dev/null
     2723    cat > $targetdir/tmp/myssh << EOF
     2724ssh -o StrictHostKeyChecking=no \$*
    27362725EOF
    2737     chmod 755 $mountpoint/tmp/myssh
     2726    chmod 755 $targetdir/tmp/myssh
    27382727
    27392728    # Copy of files mandatory for ld.so
    2740     cp -a /etc/ld.so.c* $mountpoint/etc
     2729    cp -a /etc/ld.so.c* $targetdir/etc
    27412730
    27422731    # Handle the case where busybox and mount are dynamically linked
     
    27442733    if [ $? -eq 0 ]; then
    27452734        # We want to use the real mount and all the supported variants (nfs, cifs, ...)
    2746         rm -f $mountpoint/bin/mount
     2735        rm -f $targetdir/bin/mount
    27472736    fi
    27482737
    27492738    # Copy of files from the minimal env needed as per the deplist.d/minimal.conf (which includes all busybox deps)
    2750     CopyFromConf minimal
    2751 
    2752     # In case target /bin dir still doesn't exist, create it before using it
    2753     if [ ! -d $mountpoint/bin ]; then
    2754         mkdir -p $mountpoint/bin
    2755     fi
     2739    CopyFromConf minimal $targetdir
    27562740
    27572741    # For older distributions expecting /sbin/init provides it
    2758     if [ ! -e "$mountpoint/sbin/init" ]; then
    2759         (cd $mountpoint/sbin ; ln -sf ../usr/sbin/init .)
     2742    if [ ! -e "$targetdir/sbin/init" ]; then
     2743        (cd $targetdir/sbin ; ln -sf ../usr/sbin/init .)
    27602744    fi
    27612745
    27622746    # To improve support for distribution scripts, we now prefer to use bash as the std shell. Also fixes #600
    2763     (cd $mountpoint ; ln -sf /bin/bash bin/sh)
     2747    (cd $targetdir ; ln -sf /bin/bash bin/sh)
    27642748    LogFile "INFO: Using bash as default shell"
    27652749
    27662750    # Avoids an issue on some distro (RHEL5)
    2767     rm -f $mountpoint/etc/ld.so.conf.d/kernelcap*
     2751    rm -f $targetdir/etc/ld.so.conf.d/kernelcap*
    27682752
    27692753    # Management of DRBD
     
    27732757        drbdadm sh-dev all | grep -E '^/dev' &> /dev/null
    27742758        if [ $? -eq 0 ]; then
    2775             CopyFromConf drbd
     2759            CopyFromConf drbd $targetdir
    27762760        fi
    27772761        # DRBD requires net activation
     
    27822766    ps auxww | grep -v grep | grep -qw udevd
    27832767    if [ $? -eq 0 ]; then
    2784         echo "udev device manager found" > $mountpoint/tmp/USE-UDEV
     2768        echo "udev device manager found" > $targetdir/tmp/USE-UDEV
    27852769        LogFile "INFO: udev device manager found"
    2786         tar cf - -C / /etc/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /etc/udev analysis" $templog
     2770        tar cf - -C / /etc/udev 2> $templog | (cd $targetdir ; tar xf -)  || LogAll "ERROR: Problem in /etc/udev analysis" $templog
    27872771        # This avoids NIC remapping if on another machine at restore time on Debian/Ubuntu at least
    2788         rm -f $mountpoint/etc/udev/rules.d/[z]*[0-9][0-9][-_]persistent-net.rules
     2772        rm -f $targetdir/etc/udev/rules.d/[z]*[0-9][0-9][-_]persistent-net.rules
    27892773        # Do not do it if it's a link (Ubuntu 64 bits #503)
    27902774        if [ -e "/lib64/udev" ] && [ ! -h "/lib64" ] && [ ! -h "/lib64/udev" ]; then
    2791             tar cf - -C / /lib64/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /lib64/udev analysis" $templog
     2775            tar cf - -C / /lib64/udev 2> $templog | (cd $targetdir ; tar xf -)  || LogAll "ERROR: Problem in /lib64/udev analysis" $templog
    27922776        fi
    27932777        if [ -e "/lib32/udev" ] && [ ! -h "/lib32" ] && [  ! -h "/lib32/udev" ]; then
    2794             tar cf - -C / /lib32/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /lib32/udev analysis" $templog
     2778            tar cf - -C / /lib32/udev 2> $templog | (cd $targetdir ; tar xf -)  || LogAll "ERROR: Problem in /lib32/udev analysis" $templog
    27952779        fi
    27962780        if [ -e "/lib/udev" ] && [ ! -h "/lib" ] && [  ! -h "/lib/udev" ]; then
    2797             tar cf - -C / /lib/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /lib/udev analysis" $templog
     2781            tar cf - -C / /lib/udev 2> $templog | (cd $targetdir ; tar xf -)  || LogAll "ERROR: Problem in /lib/udev analysis" $templog
    27982782        fi
    27992783        if [ -e "/usr/lib/udev" ] && [ ! -h "/usr/lib" ] && [  ! -h "/usr/lib/udev" ]; then
    2800             tar cf - -C / /usr/lib/udev 2> $templog | (cd $mountpoint ; tar xf -)  || LogAll "ERROR: Problem in /usr/lib/udev analysis" $templog
     2784            tar cf - -C / /usr/lib/udev 2> $templog | (cd $targetdir ; tar xf -)  || LogAll "ERROR: Problem in /usr/lib/udev analysis" $templog
    28012785        fi
    28022786        if [ -x /sbin/udevd ] || [ -x /usr/bin/udevd ] || [ -x /usr/lib/systemd/systemd-udevd ] || [ -x /lib/systemd/systemd-udevd ]; then
    2803             CopyFromConf udev
     2787            CopyFromConf udev $targetdir
    28042788        else
    28052789            LogAll "WARNING: udevd daemon not in standard place (/sbin or /usr/bin)"
    28062790            LogAll "         mindi will use static devices which may cause problems"
    2807             rm -f $mountpoint/tmp/USE-UDEV
     2791            rm -f $targetdir/tmp/USE-UDEV
    28082792        fi
    28092793    fi
     
    28142798    if [ -d $MINDI_CACHE/bkphw ]; then
    28152799        LogAll "INFO: Hardware Information found and saved ..."
    2816         cp -rp $MINDI_CACHE/bkphw $mountpoint
     2800        cp -rp $MINDI_CACHE/bkphw $targetdir
    28172801        if [ -f $MINDI_CACHE/tools.files ]; then
    28182802            lis=`grep -Ev '^#' $MINDI_CACHE/tools.files`
    28192803            LocateDeps $lis > $MINDI_TMP/tools.lis
    2820             tar cf - $lis `sort -u $MINDI_TMP/tools.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogAll "ERROR: Problem in tools.lis analysis" $templog
     2804            tar cf - $lis `sort -u $MINDI_TMP/tools.lis` 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in tools.lis analysis" $templog
    28212805        fi
    28222806        if [ -f $MINDI_CACHE/mindi-rsthw ]; then
    2823             mv -f $MINDI_CACHE/mindi-rsthw $mountpoint
    2824             chmod 755 $mountpoint/mindi-rsthw
     2807            mv -f $MINDI_CACHE/mindi-rsthw $targetdir
     2808            chmod 755 $targetdir/mindi-rsthw
    28252809        fi
    28262810        rm -f $MINDI_TMP/tools.lis $MINDI_CACHE/tools.files
     
    28342818    cat $MINDI_TMP/perl.lis >> $LOGFILE
    28352819    LogFile "-------------------------"
    2836     tar cf - `cat $MINDI_TMP/perl.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogAll "ERROR: Problem in perl scripts analysis" $templog
     2820    tar cf - `cat $MINDI_TMP/perl.lis` 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in perl scripts analysis" $templog
    28372821
    28382822    for w in cdrom groovy-stuff ; do
     
    28402824    done
    28412825
    2842     tar cf - -C / /dev/fd0*[1,2][4,7,8]* 2> $templog | (cd $mountpoint ; tar xf -) || LogAll "ERROR: Problem in fd dev analysis" $templog
     2826    tar cf - -C / /dev/fd0*[1,2][4,7,8]* 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in fd dev analysis" $templog
    28432827
    28442828    needed_modules=""
     
    28672851
    28682852    LogFile "INFO: Adding $needed_modules to the rootfs with $mkgmopt"
    2869     cp --parents -aL $needed_modules $mountpoint/ 2> $templog || LogAll "ERROR: Unable to copy modules to $mountpoint" $templog
     2853    cp --parents -aL $needed_modules $targetdir/ 2> $templog || LogAll "ERROR: Unable to copy modules to $targetdir" $templog
    28702854
    28712855    # Uncompress modules if not using udev and native modprobe
    2872     if [ ! -f $mountpoint/tmp/USE-UDEV ]; then
     2856    if [ ! -f $targetdir/tmp/USE-UDEV ]; then
    28732857        for i in $needed_modules; do
    28742858            if [ "`echo "$i" | grep -E ".gz$"`" ]; then
    2875                 gunzip -f $mountpoint/$i
     2859                gunzip -f $targetdir/$i
    28762860            fi
    28772861            if [ "`echo "$i" | grep -E ".bz$"`" ]; then
    2878                 bunzip2 -f $mountpoint/$i
     2862                bunzip2 -f $targetdir/$i
    28792863            fi
    28802864            if [ "`echo "$i" | grep -E ".xz$"`" ]; then
    2881                 unxz -f $mountpoint/$i
     2865                unxz -f $targetdir/$i
    28822866            fi
    28832867            LogFile "INFO: Uncompressing $i"
     
    28862870
    28872871    # Also copy modules.* in case of udev so that normal modprobe works
    2888     tar cf - -C / /$needed_modules_path/modules.* 2> $templog | (cd "$mountpoint" ; tar xf -) || LogAll "ERROR: Unable to copy modules.* to $mountpoint" $templog
     2872    tar cf - -C / /$needed_modules_path/modules.* 2> $templog | (cd "$targetdir" ; tar xf -) || LogAll "ERROR: Unable to copy modules.* to $targetdir" $templog
    28892873
    28902874    # Copy FW in case some drivers needs it
    28912875    for d in "/lib" "/usr/lib"; do
    28922876        if [ -d "$d/firmware" -a ! -h $d ]; then
    2893             cp -a "$d/firmware" "$mountpoint$d"
     2877            cp -a "$d/firmware" "$targetdir$d"
    28942878        fi
    28952879    done
     
    28982882    for d in "/lib" "/usr/lib" "/lib64" "/usr/lib64"; do
    28992883        if [ -d "$d/multipath" -a ! -h $d ]; then
    2900             cp -a "$d/multipath" "$mountpoint$d"
     2884            cp -a "$d/multipath" "$targetdir$d"
    29012885        fi
    29022886    done
    29032887
    29042888    # Ensure that with mindi-busybox 1.21, the links also exists under /bin for older distro which need it for their scripts
    2905     (cd $mountpoint/usr/bin ; for i in `ls`; do if [ ! -e "$mountpoint/bin/$i" ]; then (cd $mountpoint/bin ; ln -sf ../usr/bin/$i .); fi; done)
     2889    (cd $targetdir/usr/bin ; for i in `ls`; do if [ ! -e "$targetdir/bin/$i" ]; then (cd $targetdir/bin ; ln -sf ../usr/bin/$i .); fi; done)
    29062890
    29072891    # Copy an additional ProLiant tool for OBDR support
     
    29092893        found=0
    29102894        if [ -x /usr/bin/hpsa_obdr_mode ]; then
    2911             mkdir -p $mountpoint/usr/bin
    2912             cp -a /usr/bin/hpsa_obdr_mode $mountpoint/usr/bin
     2895            mkdir -p $targetdir/usr/bin
     2896            cp -a /usr/bin/hpsa_obdr_mode $targetdir/usr/bin
    29132897            LogAll "INFO: Copying /usr/bin/hpsa_obdr_mode to ramdisk for improved Smart Array OBDR support"
    29142898            found=1
    29152899        fi
    29162900        if [ -x /usr/bin/sg_wr_mode ]; then
    2917             mkdir -p $mountpoint/usr/bin
     2901            mkdir -p $targetdir/usr/bin
    29182902            lis="/usr/bin/sg_map /usr/bin/sg_inq /usr/bin/sg_reset /usr/bin/rev"
    29192903            LocateDeps $lis > $MINDI_TMP/obdr.lis
    2920             tar cf - $lis -C /  `sort -u $MINDI_TMP/obdr.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogAll "ERROR: Problem in obdr.lis analysis" $templog
     2904            tar cf - $lis -C /  `sort -u $MINDI_TMP/obdr.lis` 2> $templog | (cd $targetdir ; tar xf -) || LogAll "ERROR: Problem in obdr.lis analysis" $templog
    29212905            LogAll "INFO: Copying /usr/bin/sg_reset to ramdisk for improved SCSI OBDR support"
    29222906            found=1
     
    29312915        LogFile "INFO: Deleting devfsd daemon from ramdisk"
    29322916        [ ! -e "/sbin/devfsd" ] && LogFile "      ...because /sbin/devfsd not found"
    2933         rm -f $mountpoint/sbin/devfsd
    2934     fi
    2935     [ "$TAPEDEV" ] && echo -en "$TAPEDEV" > $mountpoint/tmp/TAPEDEV-LIVES-HERE
     2917        rm -f $targetdir/sbin/devfsd
     2918    fi
     2919    [ "$TAPEDEV" ] && echo -en "$TAPEDEV" > $targetdir/tmp/TAPEDEV-LIVES-HERE
    29362920    if [ _"$MONDO_SHARE" != _"" ]; then
    2937         MakeMondoConfigFile $mountpoint/tmp/$MRCFG
    2938         cp -f $mountpoint/tmp/$MRCFG $MINDI_TMP 2>> $LOGFILE || Die "Cannot copy $MRCFG to ramdisk"
    2939         cp -f $MINDI_TMP/mountlist.txt $mountpoint/tmp/ 2>> $LOGFILE || Die "Cannot copy mountlist to ramdisk"
    2940         echo -en "$FILES_IN_FILELIST" > $mountpoint/tmp/FILES-IN-FILELIST
    2941         echo -en "$LAST_FILELIST_NUMBER" > $mountpoint/tmp/LAST-FILELIST-NUMBER
     2921        MakeMondoConfigFile $targetdir/tmp/$MRCFG
     2922        cp -f $targetdir/tmp/$MRCFG $MINDI_TMP 2>> $LOGFILE || Die "Cannot copy $MRCFG to ramdisk"
     2923        cp -f $MINDI_TMP/mountlist.txt $targetdir/tmp/ 2>> $LOGFILE || Die "Cannot copy mountlist to ramdisk"
     2924        echo -en "$FILES_IN_FILELIST" > $targetdir/tmp/FILES-IN-FILELIST
     2925        echo -en "$LAST_FILELIST_NUMBER" > $targetdir/tmp/LAST-FILELIST-NUMBER
    29422926    fi
    29432927
    29442928    # Create module list to load at restore time
    2945     rm -f $mountpoint/tmp/modules
     2929    rm -f $targetdir/tmp/modules
    29462930    for m in $CDROM_MODS; do
    2947         echo $m >> $mountpoint/tmp/modules
     2931        echo $m >> $targetdir/tmp/modules
    29482932    done
    29492933
    2950     mkdir -p $mountpoint/proc
     2934    mkdir -p $targetdir/proc
    29512935    LogFile "---------------------------"
    2952     LogFile "Size of initial ramdisk:"
     2936    LogFile "Content of initial targetdir:"
     2937    LogFile "---------------------------- "
     2938    (cd "$targetdir" ; ls -Rla ) >> $LOGFILE
    29532939    LogFile "---------------------------"
    2954     (cd "$mountpoint" ; du -sh .) >> $LOGFILE
    2955     LogFile "---------------------------"
    2956     LogFile "Content of initial ramdisk:"
    2957     LogFile "---------------------------"
    2958     (cd "$mountpoint" ; ls -Rla ) >> $LOGFILE
    2959     LogFile "---------------------------"
    2960 
     2940}
     2941
     2942CleanTargetDir() {
     2943    [ "$targetdir" != "/" ] && rm -rf $targetdir
     2944}
     2945
     2946PatchBootFiles() {
     2947
     2948    # Patch the real value of RAMDISK_SIZE now we have it
     2949    if [ -d "$bigdir/syslinux" ]; then
     2950        find $bigdir/syslinux -type f 1> $MINDI_TMP/bootf.lis 2> /dev/null
     2951    fi
     2952    if [ -d "$bigdir/EFI" ]; then
     2953        find $bigdir/EFI -type f 1>> $MINDI_TMP/bootf.lis 2> /dev/null
     2954    fi
     2955    for i in `cat $MINDI_TMP/bootf.lis`; do
     2956        perl -pi -e "s/RAMDISK_SIZE/$ramdisk_size/" $i
     2957    done
     2958    rm -f $MINDI_TMP/bootf.lis
     2959
     2960}
     2961
     2962MakeBootInitFile() {
     2963
     2964    local mountpoint tempfile res
     2965    tempfile=$MINDI_TMP/temp.rd
     2966    res=0
     2967
     2968    LogAll "INFO: Making Boot RAM Disk ($ramdisk_size KB)"
     2969    dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (MakeBootInitFile)"
     2970
     2971    LogAll "INFO: Creating ext2 filesystem on $tempfile"
     2972    mke2fs -b 1024 -m 1 -i 2048 -F $tempfile >> $LOGFILE 2>> $LOGFILE || Die "Unable to create an ext2 file system on $tempfile"
     2973    res=$(($res+$?))
     2974
     2975    mountpoint=$MINDI_TMP/mountpoint.$$
     2976    mkdir -p $mountpoint
     2977    mount -t ext2 -o loop $tempfile $mountpoint || Die "Cannot loopmount $tempfile to $mountpoint! The reason may be missing support for loopfs or ext2 (or both) in the running kernel."
     2978    [ "$targetdir" = "/" ] && echo $targetdir | grep -qv $MINDI_TMP && Die "Wrong targetdir $targetdir"
     2979    mv $targetdir/* $targetdir/.??* $mountpoint || Die "Unable to move files from $targetdir to $mountpoint! Please increase EXTRA_SPACE"
     2980    res=$(($res+$?))
     2981    rmdir $targetdir
     2982
     2983    LogFile "INFO: initrd image is $rdz_fname"
    29612984    # Determine what filesystem to use for initrd image
    29622985    LogFile "INFO: Call GetInitrdFilesystemToUse() with parameter ${kernelpath} to get filesystem to use for initrd."
     
    29662989        # say what will be used
    29672990        LogFile "INFO: Creating an $gvFileSystem initrd image..."
    2968         # kernel expects linuxrc in ext2 filesystem
    2969         (cd "$mountpoint" && ln -sf usr/sbin/init linuxrc)
    29702991        # unmount loop filesystem and create image file using the standard approach
    29712992        sync
    29722993        umount $mountpoint || Die "Cannot unmount $tempfile"
    29732994        dd if=$tempfile bs=1k of=${rdz_fname}.tmp > /dev/null 2> /dev/null
     2995        res=$(($res+$?))
    29742996        if [ "$gvFileSystem" = "ext4fs" ] && [ -x "/sbin/tune4fs" ]; then
    29752997            bs=`/sbin/tune4fs -l ${rdz_fname}.tmp | grep -E '^Block size:' | cut -d: -f2 | sed 's/^ *//'`
     
    29793001        MINDI_ADDITIONAL_BOOT_PARAMS="$MINDI_ADDITIONAL_BOOT_PARAMS ramdisk_blocksize=$bs"
    29803002        gzip -c9 ${rdz_fname}.tmp > $rdz_fname
     3003        res=$(($res+$?))
    29813004        rm -f ${rdz_fname}.tmp
    2982         # log that we are done
    29833005    elif [ "$gvFileSystem" = "initramfs" ]; then
    29843006        # say what will be used
     
    29863008        # make sure that cpio is there
    29873009        which cpio &> /dev/null; [ $? -eq 0 ] || Die "cpio not found. Please install package cpio and try again."
    2988         # kernel expects init in cpio filesystem
    2989         (cd "$mountpoint" ; ln -sf usr/sbin/init init)
    29903010        # create cpio image file and unmount loop filesystem
    29913011        (cd "$mountpoint" ; find . -print | cpio -o -H newc 2> /dev/null | gzip -9 > $rdz_fname)
     3012        res=$(($res+$?))
    29923013        sync
    29933014        umount $mountpoint || Die "Cannot unmount $tempfile"
    2994         # log that we are done
    29953015    else
    29963016        Die "Filesystem $gvFileSystem not supported for initrd image. Terminating."
    29973017    fi
    29983018
     3019    # log that we are done
    29993020    if [ "$res" -eq "0" ] ; then
    30003021        LogAll "INFO: MakeBootInitFile finished without error."
     
    30023023        LogAll "WARNING: MakeBootInitFile exits WITH ERRORS."
    30033024    fi
     3025
    30043026    return 0
    30053027}
     
    30123034# Now we can create what we need
    30133035mkdir -p $MINDI_TMP
     3036export bigdir=$MINDI_TMP/bigdir.$$
     3037export targetdir=$MINDI_TMP/targetdir.$$
    30143038
    30153039# --nolog needs to be first, and is used in analyze-my-lvm
     
    33723396        kernelpath=$2
    33733397        BOOT_TYPE=$4
    3374         bigdir=$MINDI_TMP/bigdir
    33753398        # Ironic requires some specific boot parameters
    33763399        MINDI_ADDITIONAL_BOOT_PARAMS="selinux=0 barrier=off udevtimeout=10 systemd.debug-shell boot_method=vmedia"
     
    33823405        fi
    33833406        PrepareBootDir
    3384         PrepareAllTar
     3407        PrepareBigDirTar
     3408        CleanBigDir
    33853409        cp $3 $MINDI_TMP/initrd.img
    33863410        MakeBootableDevice ISO
     
    35503574[ "$(($RANDOM%64))" -eq "0" ] && LogAll "INFO: Dude, I've looked inside your computer and it's really dusty..."
    35513575
    3552 mountpoint=$MINDI_TMP/mountpoint.$$
    3553 PrepareDataDiskImages
    3554 
    3555 MakeBootInitFile $MINDI_LIB/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not create initrd.img"
     3576PrepareBigDir
     3577bigdir_size=`du -sk $bigdir | cut -f1`
     3578LogFile "---------------------------"
     3579LogFile "INFO: bigdir size is $bigdir_size KB"
     3580
     3581PrepareTargetDir || Die "Could not create initrd.img in target dir"
     3582targetdir_size=`du -sk $targetdir | cut -f1`
     3583LogFile "---------------------------"
     3584LogFile "INFO: targetdir size is $targetdir_size KB"
     3585LogFile "---------------------------- "
     3586
     3587# Now we can compute it correctly with some extra in case of...
     3588export ramdisk_size=$(($bigdir_size+$targetdir_size+$EXTRA_SPACE))
     3589# And now we can patch the value in conf files
     3590PatchBootFiles
     3591# And tar them
     3592PrepareBigDirTar
     3593# And prepare boot setup
     3594MakeBootInitFile
     3595# Now cleans up stuff
     3596CleanBigDir
     3597CleanTargetDir
    35563598
    35573599[ -e "$MINDI_LIB/memtest.img" ] && BOOT_MEDIA_MESSAGE="$BOOT_MEDIA_MESSAGE\n\
  • branches/3.3/mindi/mindi.conf

    r3522 r3692  
    1010# DENY_MODS="kqemu vxfen fdomain ipmi_si"
    1111#
    12 # EXTRA_SPACE=80152     # increase if you run out of ramdisk space
     12# EXTRA_SPACE=20000     # increase if you run out of ramdisk space
    1313# MINDI_ADDITIONAL_BOOT_PARAMS="devfs=nomount noresume selinux=0 barrier=off udevtimeout=10 acpi=off"
    1414# MINDI_DEFAULT_BOOT_OPTION="interactive ipconf=eth0:10.0.0.1:255.0.0.0:10.255.255.255:10.2.3.4"
Note: See TracChangeset for help on using the changeset viewer.