Changeset 3522


Ignore:
Timestamp:
Mar 3, 2016, 9:06:23 AM (19 months ago)
Author:
bruno
Message:

Important mindi modifications to share ISO and USB code

  • Remove the need for BOOT_SIZE variable now computed automatically
  • Share more params in ISO_OPT
  • Rename TurnTgzIntoRdz? into MakeBootInitFile?
  • Remove sages of old_pwd and cd in functions. if a need to change directory then do it in a subshell especially in PrepareDataDiskImages? and MakeBootInitFile?
  • Remove function ListImagesForUser?
  • Fix a bug related to list analysis with echo where the variable needs to be transformed into list before processing
  • Simplify OfferToMakeBootableISO and OfferToMakeBootableUSB to just deal with interactivity and parameter handling and create a shared function MakeBootableDevice? with a parameter for special treatment. This will allow to fix broken USB support and to avoid that type of issue in the future
  • Suppress as well PrepareBootDiskImage? as content is now supported in the shared MakeBootableDevice?
  • Improve on screen and in log file messages
Location:
branches/3.2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/MondoRescue/bin/mr-label

    r3501 r3522  
    151151    pb_log(1,"Previous hex was ***$hex***\n");
    152152    my @loc = ($hex =~ m/../g);
    153     print Dumper(@loc);
     153    #print Dumper(@loc);
    154154    $hex = join('',reverse(@loc));
    155155    pb_log(1,"Previous uuid was ***$hex***\n");
  • branches/3.2/mindi/mindi

    r3520 r3522  
    4444fi
    4545
    46 EXTRA_SPACE=120000      # increase if you run out of ramdisk space
    47 BOOT_SIZE=86000         # size of the boot disk in KB
     46EXTRA_SPACE=150000      # increase if you run out of ramdisk space
    4847
    4948PROMPT_MAKE_CD_IMAGE="yes"
    5049    # Ask if you want to make a CD Image to be written?
    51     # if this is set to 'no', then the image will be created automatically
     50    # if this is set to 'no' in the conf file, then the image will be created automatically
    5251
    5352PROMPT_MAKE_USB_IMAGE="yes"
    5453    # Ask if you want to make a USB Image to be written?
    55     # if this is set to 'no', then the image will be created automatically
     54    # if this is set to 'no' in the conf file, then the image will be created automatically
    5655
    5756USE_OWN_KERNEL="yes"
     
    128127fi
    129128
    130 ISO_OPT="-J -r -v -p Mindi -publisher http://www.mondorescue.org -A Mindi"
     129ISO_OPT="-J -r -v -p Mindi -publisher http://www.mondorescue.org -A Mindi -V Mindi_Image -no-emul-boot -o $MINDI_CACHE/mindi.iso "
    131130
    132131# Mindi set this as default in case it's invoked alone
     
    183182# Should be declared here as used immediately below potentialy
    184183MindiExit() {
    185     LogFile "Mindi $MINDI_VERSION is exiting"
    186     LogFile "End date : `date`"
     184    LogFile "INFO: Mindi $MINDI_VERSION is exiting"
     185    LogFile "INFO: End date : `date`"
    187186    if [ _"$MONDO_SHARE" != _"" ] ; then
    188187        echo "------------- mindi logfile included -------------------------" >> /var/log/mondoarchive.log
     
    307306    mkdir -p $outdir
    308307    incoming=`ReadLine`
    309     counter=0
     308    counter=$3
    310309    > $templog
    311310
    312311    while [ "$incoming" != "" ] ; do
     312        if [ "$3" = "1" ]; then
     313            counter=$(($counter+1))
     314            LogProgress $counter $2
     315        fi
    313316        # Non absolute file names should not arrive till here => skipped
    314317        if [ `echo "$incoming" | cut -c1` != '/' ]; then
     
    325328        done
    326329        if [ -d "$incoming" -a ! -h "$incoming" ]; then
    327             find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir 0
     330            find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir 0 0
    328331        elif [ -e "$incoming" ] && [ $found = "false" ]; then
    329332            if [ ! -h "$incoming" ]; then
     
    341344            fi
    342345            [ -x "$outdir" ] && StripExecutable $outdir
    343             counter=$(($counter+1))
    344             LogProgress $counter $2
    345346        fi
    346347        incoming=`ReadLine`
     
    586587
    587588GenerateGiantDependencyList() {
    588     local incoming loc fname list_of_files i tempfile outfile progress filelist res r mapfile mappath included_list included_item old_pwd tempdepfile modres noof_lines lvmversion lvmresolved
    589 
    590     echo -en "Analyzing dependency requirements"
     589    local incoming loc fname list_of_files i tempfile outfile progress filelist res r mapfile mappath included_list included_item tempdepfile modres noof_lines lvmversion lvmresolved
     590
     591    echo -en "INFO: Analyzing dependency requirements"
    591592    outfile=$1
    592593    tempfile=$MINDI_TMP/$$.txt
     
    669670        done
    670671    fi
    671     echo -en "$DONE\nMaking complete dependency list"
     672    echo -en "$DONE\nINFO: Making complete dependency list"
    672673
    673674    tr -s '/' '/' < $tempfile | sort -u > $tempfile.new
     
    690691        if [ -e "$MINDI_TMP/post-nuke.tgz" ] ; then
    691692            LogAll "\nINFO: Incorporating post-nuke tarball"
    692             old_pwd=`pwd`
    693             cd "$bigdir"
    694             tar -zxf $MINDI_TMP/post-nuke.tgz 2>> $MINDI_TMP/$$.log || LogAll "ERROR: when untarring post-nuke tarball" $MINDI_TMP/$$.log
    695             cd "$old_pwd"
     693            (cd "$bigdir" ; tar -zxf $MINDI_TMP/post-nuke.tgz 2>> $MINDI_TMP/$$.log || LogAll "ERROR: when untarring post-nuke tarball" $MINDI_TMP/$$.log)
    696694        fi
    697695        if cp -f $MINDI_TMP/mondo*restore $bigdir/usr/bin 2>> $LOGFILE ; then
     
    850848
    851849
    852 ListImagesForUser() {
    853     local path fname
    854     path=$MINDI_CACHE
    855     echo -en "In the directory '$path' you will find the images:-\n"
    856     for fname in `ls $path | grep -F mindi-` ; do
    857         printf "%19s " $fname
    858     done
    859     echo " "
    860 }
    861 
    862 
    863850ListKernelModulePaths() {
    864851    local module_list module fname r kern
     
    993980}
    994981
    995 # Called by TurnTgzIntoRdz, to make /tmp/$MRCFG
     982# Called by MakeBootInitFile, to make /tmp/$MRCFG
    996983MakeMondoConfigFile() {
    997984    local outfile use_lzo use_comp use_star
     
    10561043
    10571044    LogFile "------------------------------------"
    1058     LogFile "Your raw fstab file looks like this:"
     1045    LogFile "INFO: Your raw fstab file looks like this:"
    10591046    LogFile "------------------------------------"
    10601047    cat $MY_FSTAB >> $LOGFILE
    10611048    LogAll "-----------------------------------"
    1062     LogAll "Your mountlist will look like this:"
     1049    LogAll "INFO: Your mountlist will look like this:"
    10631050    LogAll "-----------------------------------"
    10641051
     
    12981285
    12991286            # We want a single unique list
    1300             list_of_devices="`echo $l | sort -u`"
     1287            list_of_devices="`echo $l | tr ' ' '\n' | sort -u`"
    13011288
    13021289            for d in `echo $MINDI_EXCLUDE_DEVS | sed 's/|/ /g'`; do
     
    14521439        else
    14531440            if [ "$partition_format" = "dos" ] || [ "$partition_format" = "msdos" ] ; then
    1454                 LogFile "WARNING: vfat should be used instead of dos/msdos as a partition format"
     1441            LogFile "WARNING: vfat should be used instead of dos/msdos as a partition format"
    14551442                partition_format="vfat"
    14561443            fi
     
    14811468}
    14821469
    1483 OfferToMakeBootableISO() {
    1484     local i old_pwd files
    1485     if [ -z "$ISO_CMD" ]; then
    1486         LogAll "ERROR: Neither mkisofs nor genisoimage nor xorriso found, unable to make CD image"
    1487         return
    1488     fi
    1489     if [ "$PROMPT_MAKE_CD_IMAGE" = "yes" ] && [ _"$MONDO_SHARE" = _"" ]; then
    1490         echo -en "Shall I make a bootable CD image? (y/[n]) "
    1491         read i
    1492         [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
    1493     fi
    1494     rm -Rf $MINDI_TMP/iso
    1495     mkdir -p $MINDI_TMP/iso/{images,archives}
    1496     files=`ls $MINDI_CACHE/{*.gz,*.img}`
    1497     cp -f $files $MINDI_TMP/iso/images 2>> $LOGFILE || LogAll "WARNING: OfferToMakeBootableISO: Cannot copy files to $MINDI_TMP/iso/images"
    1498     for i in memdisk memtest.bin memtest.img ; do
    1499         j=$MINDI_LIB/$i
    1500         k=$MINDI_TMP/iso
    1501         if [ -e "$j" ] ; then
    1502             LogAll "INFO: Copying $j to $k"
    1503             cp -f $j $k 2>> $LOGFILE || Die "Failed to copy $j to $k"
    1504             cp -f $j $MINDI_TMP 2>> $LOGFILE || Die "Failed to copy $j to $MINDI_TMP"
    1505             if [ _"$MONDO_SHARE" != _"" ]; then
    1506                 cp -f $j $MONDO_ROOT 2>> $LOGFILE || Die "Failed to copy $j to $MONDO_ROOT"
    1507             fi
    1508         fi
    1509     done
    1510 
    1511     cp $kernelpath $MINDI_TMP/iso/vmlinuz 2>> $LOGFILE || Die "Cannot copy vmlinuz ($kernelpath) to mindi tmp ($MINDI_TMP/iso/vmlinuz). Did you run out of disk space?"
    1512     cp $MINDI_TMP/initrd.img $MINDI_TMP/iso/initrd.img 2>> $LOGFILE || Die "Cannot copy initrd.img ($MINDI_TMP/initrd.img) to $MINDI_TMP/iso/initrd.img. Did you run out of disk space?"
    1513 
    1514     # copy boot stuff now generated in PrepareDataDiskImage
    1515     if [ "$BOOT_TYPE" = "UEFI" ]; then
    1516         (cd $MINDI_TMP/iso ; tar xfz $MINDI_CACHE/all.tar.gz ./EFI)
    1517         tbc="EFI"
    1518     else
    1519         (cd $MINDI_TMP/iso ; tar xfz $MINDI_CACHE/all.tar.gz ./syslinux)
    1520         tbc="syslinux"
    1521     fi
    1522 
    1523     MakeMessageFile $MINDI_TMP/iso/$tbc | cut -c1-80 > $MINDI_TMP/iso/$tbc/message.txt
    1524 
    1525     if [ "$ARCH" != "ia64" ] ; then
    1526         if [ $KERNEL_IS_XEN = "yes" ]; then
    1527             FindMboot32Binary
    1528             cp $xenkernelpath $MINDI_TMP/iso/xen.gz 2>> $LOGFILE || Die "Cannot copy xen.gz ($xenkernelpath) to mindi tmp ($MINDI_TMP/iso/xen.gz). Did you run out of disk space?"
    1529             cp $MBOOTC32 $MINDI_TMP/iso/$tbc/mboot.c32  2>> $LOGFILE || Die "Cannot copy mboot.c32 ($MBOOTC32) to mindi tmp ($MINDI_TMP/iso/$tbc/mboot.c32). Did you run out of disk space?"
    1530         fi
    1531 
    1532         cp $ISOLINUX $MINDI_TMP/iso/$tbc/isolinux.bin 2>> $LOGFILE || Die "Cannot copy isolinux.bin ($ISOLINUX) to $MINDI_TMP/iso - did you run out of disk space?"
    1533 
    1534         if [ -e "$LDLINUXC32" ]; then
    1535             cp $LDLINUXC32 $MINDI_TMP/iso/$tbc 2>> $LOGFILE || Die "Cannot copy $LDLINUXC32 to $MINDI_TMP/iso/$tbc. Did you run out of disk space?"
    1536         fi
    1537 
    1538         if [ _"$MONDO_SHARE" != _"" ]; then
    1539             cp -rf $MINDI_TMP/iso/{initrd.img,vmlinuz,$tbc} $MONDO_ROOT 2>> $LOGFILE || Die "Cannot copy core files to ramdisk for boot disk (under $MONDO_ROOT). Did you run out of disk space?"
    1540             if [ $KERNEL_IS_XEN = "yes" ]; then
    1541                 cp -f $MINDI_TMP/iso/xen.gz $MONDO_ROOT 2>> $LOGFILE || Die "Cannot copy Xen kernel to $MONDO_ROOT. Did you run out of disk space?"
    1542             fi
    1543             cp -f $MONDO_SHARE/autorun $MINDI_TMP/iso 2>> $LOGFILE
    1544         fi
    1545         CMD="$ISO_CMD -U $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b $tbc/isolinux.bin -c $tbc/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
    1546     else
    1547         CMD="$ISO_CMD $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b images/mindi-bootroot.img -c images/boot.cat -no-emul-boot"
    1548     fi
    1549 
    1550     old_pwd=`pwd`
    1551     cd "$MINDI_TMP/iso"
    1552     LogFile "Invoking $CMD"
    1553     $CMD . > /dev/null 2> $MINDI_TMP/mkisofs.log
    1554     if [ "$?" -ne "0" ] ; then
    1555         if [ "$BOOT_TYPE" = "UEFI" ]; then
    1556             CMD=`echo $CMD | perl -p -e 's|--efi-boot |-eltorito-platform 0xEF -eltorito-boot |'`
    1557             CMD=`echo $CMD | perl -p -e 's|-efi-boot |-eltorito-platform 0xEF -eltorito-boot |'`
    1558             $CMD . > /dev/null 2> $MINDI_TMP/mkisofs.log
    1559             if [ "$?" -eq "0" ] ; then
    1560                 LogAll "INFO: Created bootable ISO image at $MINDI_CACHE/mindi.iso"
    1561             else
    1562                 MakeISOErrors
    1563             fi
    1564         else
    1565             MakeISOErrors
    1566         fi
    1567     else
    1568         LogAll "INFO: Created bootable ISO image at $MINDI_CACHE/mindi.iso"
    1569     fi
    1570     rm -f $MINDI_TMP/mkisofs.log
    1571     cd "$old_pwd"
    1572 }
    15731470
    15741471MakeISOErrors() {
    15751472
    15761473LogFile "----------- $ISO_CMD's errors --------------"
    1577 LogAll "$CMD returned the following errors:"
     1474LogAll "$ISO_CMD returned the following errors:"
    15781475cat $MINDI_TMP/mkisofs.log | tee -a $LOGFILE
    15791476LogAll "ERROR: Failed to create ISO image."
    15801477}
    15811478
    1582 
    1583 OfferToMakeBootableUSB() {
    1584     local i files
    1585     if [ "$PROMPT_MAKE_USB_IMAGE" = "yes" ] && [ _"$MONDO_SHARE" = _"" ]; then
    1586         echo -n "Shall I make a bootable USB device ? (y/[n]) "
    1587         read i
    1588         [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
    1589         if [ "$USBDEVICE" = "" ]; then
    1590             echo -en "Please enter the device name of your USB device (e.g. /dev/sda) : "
    1591             read dev
    1592             USBDEVICE=$dev
    1593         fi
    1594         echo "WARNING: This will erase all content on $USBDEVICE"
    1595         echo -en "Are you sure you want to use $USBDEVICE (y/[n]) "
    1596         read i
    1597         [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
    1598     fi
    1599     rm -Rf $MINDI_TMP/usb
    1600     mkdir -p $MINDI_TMP/usb
    1601     USBPART="${USBDEVICE}1"
    1602 
    1603     echo -en "Transforming $USBDEVICE in a Bootable device "
    1604     echo -en "."
    1605     LogFile "INFO: Transforming $USBDEVICE in a Bootable device"
    1606     LogFile "INFO: Checking $USBDEVICE"
     1479MakeBootableDevice() {
     1480
     1481local target tbc retval part size mount_opt
     1482
     1483target="$1"
     1484
     1485rm -Rf $MINDI_TMP/target
     1486mkdir -p $MINDI_TMP/target/{images,archives,tmp}
     1487
     1488LogAll "INFO: Copying $MINDI_CACHE/*.gz to $MINDI_TMP/target/images"
     1489cp -f $MINDI_CACHE/*.gz $MINDI_TMP/target/images 2>> $LOGFILE || LogAll "WARNING: MakeBootableDevice: Cannot copy files to $MINDI_TMP/target/images"
     1490for i in memdisk memtest.bin memtest.img ; do
     1491    j=$MINDI_LIB/$i
     1492    k=$MINDI_TMP/target
     1493    if [ -e "$j" ] ; then
     1494        LogAll "INFO: Copying $j to $k"
     1495        cp -f $j $k 2>> $LOGFILE || LogAll "Failed to copy $j to $k"
     1496        cp -f $j $MINDI_TMP 2>> $LOGFILE || LogAll "Failed to copy $j to $MINDI_TMP"
     1497        if [ _"$MONDO_SHARE" != _"" ]; then
     1498            cp -f $j $MONDO_ROOT 2>> $LOGFILE || LogAll "Failed to copy $j to $MONDO_ROOT"
     1499        fi
     1500    fi
     1501done
     1502
     1503retval=0
     1504LogAll "INFO: Copying $kernelpath to $MINDI_TMP/target/vmlinuz"
     1505cp $kernelpath $MINDI_TMP/target/vmlinuz 2>> $LOGFILE
     1506if [ "$?" -ne "0" ] ; then
     1507    LogAll "ERROR: Failed to copy $kernelpath $MINDI_TMP/target/"
     1508    retval=$(($retval+1))
     1509fi
     1510LogAll "INFO: Copying $MINDI_TMP/initrd.img to $MINDI_TMP/target/initrd.img"
     1511cp $MINDI_TMP/initrd.img $MINDI_TMP/target/ 2>> $LOGFILE
     1512if [ "$?" -ne "0" ] ; then
     1513    LogAll "ERROR: Failed to copy $MINDI_TMP/initrd.img to $MINDI_TMP/target/"
     1514    retval=$(($retval+1))
     1515fi
     1516
     1517# copy boot stuff now generated in PrepareDataDiskImage
     1518if [ "$BOOT_TYPE" = "UEFI" ]; then
     1519    (cd $MINDI_TMP/target ; tar xfz $MINDI_CACHE/all.tar.gz ./EFI)
     1520    tbc="EFI"
     1521else
     1522    (cd $MINDI_TMP/target ; tar xfz $MINDI_CACHE/all.tar.gz ./syslinux)
     1523    tbc="syslinux"
     1524    if [ -f "$MINDI_TMP/target/$tbc/syslinux.cfg" ]; then
     1525        LogFile "----------- syslinux's conf --------------"
     1526        cat $MINDI_TMP/target/$tbc/syslinux.cfg >> $LOGFILE
     1527        LogFile "------------------------------------------"
     1528    fi
     1529    if  [ "$target" = "ISO" ]; then
     1530        cp $ISOLINUX $MINDI_TMP/target/$tbc/ 2>> $LOGFILE
     1531        if [ "$?" -ne "0" ] ; then
     1532            LogAll "ERROR: Failed to copy $ISOLINUX to $MINDI_TMP/target/$tbc"
     1533            retval=$(($retval+1))
     1534        fi
     1535    fi
     1536fi
     1537
     1538if [ "$ARCH" != "ia64" ] ; then
     1539    if [ $KERNEL_IS_XEN = "yes" ]; then
     1540        FindMboot32Binary
     1541        cp $xenkernelpath $MINDI_TMP/target/xen.gz 2>> $LOGFILE
     1542        if [ "$?" -ne "0" ] ; then
     1543            LogAll "ERROR: Failed to copy $xenkernelpath to $MINDI_TMP/target/"
     1544            retval=$(($retval+1))
     1545        fi
     1546        cp $MBOOTC32 $MINDI_TMP/target/$tbc/mboot.c32  2>> $LOGFILE
     1547        if [ "$?" -ne "0" ] ; then
     1548            LogAll "ERROR: Failed to copy $MBOOTC32 to $MINDI_TMP/target/$tbc"
     1549            retval=$(($retval+1))
     1550        fi
     1551    fi
     1552fi
     1553
     1554MakeMessageFile $MINDI_TMP/target/$tbc | cut -c1-80 > $MINDI_TMP/target/$tbc/message.txt
     1555
     1556if [ _"$MONDO_SHARE" != _"" ]; then
     1557    cp -rf $MINDI_TMP/target/$tbc $MONDO_ROOT 2>> $LOGFILE
     1558    if [ "$?" -ne "0" ] ; then
     1559        LogAll "ERROR: Failed to copy $MINDI_TMP/target/$tbc to $MONDO_ROOT"
     1560        LogAll "       Please check the target directory."
     1561        retval=$(($retval+1))
     1562    fi
     1563    if [ $KERNEL_IS_XEN = "yes" ]; then
     1564        cp -f $MINDI_TMP/target/xen.gz $MONDO_ROOT 2>> $LOGFILE
     1565        if [ "$?" -ne "0" ] ; then
     1566            LogAll "ERROR: Failed to copy $MINDI_TMP/target/xen.gz to $MONDO_ROOT"
     1567            LogAll "       Please check the target directory."
     1568            retval=$(($retval+1))
     1569        fi
     1570    fi
     1571    cp -f $MONDO_SHARE/autorun $MINDI_TMP/target 2>> $LOGFILE
     1572fi
     1573
     1574if [ -f "$MINDI_TMP/$MRCFG" ]; then
     1575    cp -f $MINDI_TMP/$MRCFG $MINDI_TMP/target/tmp
     1576fi
     1577
     1578LogFile "----------- target dir content -----------"
     1579LogFile "------------------------------------------"
     1580ls -lR $MINDI_TMP/target >> $LOGFILE
     1581LogFile "------------------------------------------"
     1582LogFile "----------- target dir sizes -------------"
     1583du -sk $MINDI_TMP/target/* >> $LOGFILE
     1584LogFile "------------------------------------------"
     1585
     1586if [ "$retval" -ne "0" ] ; then
     1587    LogFile "--------------------------------"
     1588    LogFile "INFO: Size of $MINDI_TMP/target:"
     1589    du -sk $MINDI_TMP/target/* >> $LOGFILE
     1590    LogFile "--------------------------------"
     1591    echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n" >> $LOGFILE
     1592    umount $MINDI_TMP/target
     1593    LogAll "ERROR: Problems while creating boot media."
     1594    LogAll "       Please unload some of your modules and try again."
     1595    Die    "       Try to increase EXTRA_SPACE in $MINDI_CONFIG"
     1596fi
     1597
     1598mkdir -p $MINDI_TMP/mpt
     1599
     1600if  [ "$target" = "USB" ]; then
     1601    LogAll "INFO: Transforming $USBDEVICE in a Bootable device"
     1602    LogAll "INFO: Checking $USBDEVICE"
    16071603    $FDISK -l $USBDEVICE 2>&1 >> $LOGFILE
    16081604    if [ $? -ne 0 ]; then
     
    16111607        MindiExit -1
    16121608    fi
    1613     echo -en "."
    16141609    # Some distro do auto mount at that point (Ubuntu)
    1615     LogFile "INFO: Unmounting $USBPART just in case"
     1610    LogAll "INFO: Unmounting $USBPART just in case"
    16161611    umount $USBPART 2>> $LOGFILE 1>> $LOGFILE
    16171612    if [ "$BOOT_TYPE" = "BIOS" ]; then
     
    16201615        if [ -r $MBRFILE ]; then
    16211616            LogAll "INFO: Installing an MBR ($MBRFILE) on $USBDEVICE"
    1622             dd if=$MBRFILE of=$USBDEVICE
     1617            dd if=$MBRFILE of=$USBDEVICE >> $LOGFILE 2>> $LOGFILE
    16231618        else
    16241619            LogAll "WARNING: You may need to install an MBR (usually in $MBRFILE, but not found on your system)"
     
    16261621        fi
    16271622    fi
    1628     LogFile "INFO: Preparing $USBDEVICE"
     1623    LogAll "INFO: Preparing $USBDEVICE"
    16291624    cat > $MINDI_TMP/fdisk.txt << EOF
    16301625d
     
    16551650    LogFile "----------------"
    16561651    rm -f $MINDI_TMP/fdisk.txt
    1657     LogFile "INFO: The USB device $USBDEVICE now looks like this:"
     1652    LogAll "INFO: The USB device $USBDEVICE now looks like this:"
    16581653    $FDISK -l $USBDEVICE 2>&1 | tee -a $LOGFILE
    1659     echo -en "."
    16601654    # Calling kpartx in case devices were not created
    16611655    if [ -x "/sbin/kpartx" ]; then
     
    16631657    fi
    16641658    # Some distro do auto mount at that point (Ubuntu)
    1665     LogFile "INFO: Unmounting $USBPART just in case again"
     1659    LogAll "INFO: Unmounting $USBPART just in case again"
    16661660    umount $USBPART 2>> $LOGFILE 1>> $LOGFILE
    1667     echo -en "."
    16681661    # Some distro have a dmsetup conf at that point so removing it Cf: http://trac.mondorescue.org/ticket/651
    16691662    if [ "`which dmsetup`" != "" ]; then
    16701663        block_id="`echo $USBPART | sed 's/\/dev\///g'`"
    16711664        if [[ "`dmsetup ls | awk '{print $1}' | grep $block_id`" != "" ]]; then
    1672             LogFile "INFO: Removing $block_id from device mapper."
     1665            LogAll "INFO: Removing $block_id from device mapper."
    16731666            sleep 1
    16741667            dmsetup remove $block_id
    16751668        fi
    16761669    fi
    1677     echo -en "."
    1678     LogFile "INFO: Creating a vfat filesystem on $USBPART"
    1679     mkdosfs -F 32 $USBPART 2>&1 >> $LOGFILE
    1680     if [ $? -ne 0 ]; then
    1681         LogAll "ERROR: Unable to create a vfat filesystem on $USBPART"
    1682         LogAll "       Make sure your USB device is plugged in and partitioned ($USBPART must exist on it)"
     1670    part=$USBPART
     1671    mount_opt=""
     1672else
     1673    # ISO image
     1674    part=$MINDI_TMP/mindi-bootroot.img
     1675    size=`du -sk $MINDI_TMP/target 2> /dev/null | cut -f1`
     1676    # Adds 10 MB to allow for additional space
     1677    size=$(($size+10000))
     1678    LogAll "INFO: Creating a $size KB empty file for boot device of the ISO image"
     1679    dd if=/dev/zero of=$part bs=1k count=$size &> /dev/null || Die "Cannot dd blank $part"
     1680    mount_opt="-o loop"
     1681fi
     1682
     1683LogAll "INFO: Creating a vfat filesystem on $part"
     1684mkdosfs -F 32 $part 2>&1 >> $LOGFILE
     1685if [ $? -ne 0 ]; then
     1686    LogAll "ERROR: Unable to create a vfat filesystem on $part"
     1687    if  [ "$target" = "USB" ]; then
     1688        LogAll "       Make sure your USB device is plugged in and partitioned ($part must exist on it)"
    16831689        $FDISK -l $USBDEVICE 2>&1 | tee -a $LOGFILE
    1684         MindiExit -1
    1685     fi
    1686     echo -en "."
    1687     LogFile "INFO: Mounting $USBPART on $MINDI_TMP/usb"
    1688     mount $USBPART $MINDI_TMP/usb 2>> $LOGFILE
    1689     if [ $? -ne 0 ]; then
    1690         LogAll "ERROR: Unable to mount $USBPART on $MINDI_TMP/usb"
    1691         LogAll "       Make sure your USB device is plugged in, partitioned and formated ($USBPART must exist on it)"
     1690    fi
     1691    MindiExit -1
     1692fi
     1693LogAll "INFO: Mounting $part on $MINDI_TMP/mpt"
     1694mount -t vfat $mount_opt $part $MINDI_TMP/mpt 2>> $LOGFILE
     1695if [ $? -ne 0 ]; then
     1696    LogAll "ERROR: Unable to mount $part on $MINDI_TMP/mpt"
     1697    if  [ "$target" = "USB" ]; then
     1698        LogAll "       Make sure your USB device is plugged in, partitioned and formated ($part must exist on it)"
    16921699        $FDISK -l $USBDEVICE 2>&1 | tee -a $LOGFILE
    1693         MindiExit -1
    1694     fi
    1695     echo -en "."
    1696     mkdir -p $MINDI_TMP/usb/images
    1697     files=`ls $MINDI_CACHE/{*.gz,*.img}`
    1698     cp -f $files $MINDI_TMP/usb/images 2>> $LOGFILE || LogAll "ERROR: OfferToMakeBootableUSB: Cannot copy files to $MINDI_TMP/usb/images"
    1699     echo -en "."
    1700     for i in memdisk memtest.bin memtest.img ; do
    1701         j=$MINDI_LIB/$i
    1702         k=$MINDI_TMP/usb
    1703         if [ -e "$j" ] ; then
    1704             LogFile "INFO: Copying $j to $k"
    1705             cp -f $j $k 2>> $LOGFILE || Die "Failed to copy $j to $k"
    1706             cp -f $j $MINDI_TMP 2>> $LOGFILE || Die "Failed to copy $j to $MINDI_TMP"
    1707         fi
    1708     done
    1709     echo -en "."
    1710     MakeMessageFile $MINDI_TMP/usb | cut -c1-80 > $MINDI_TMP/usb/message.txt
    1711     echo -en "."
    1712     cp $kernelpath $MINDI_TMP/usb/vmlinuz 2>> $LOGFILE || Die "Cannot copy vmlinuz ($kernelpath) to mindi tmp ($MINDI_TMP/usb/vmlinuz). Did you run out of disk space?"
    1713     echo -en "."
    1714     cp $MINDI_TMP/initrd.img $MINDI_TMP/usb/initrd.img 2>> $LOGFILE
    1715     echo -en "."
    1716     MakeBootConfFile syslinux > $MINDI_TMP/usb/syslinux.cfg
    1717     echo -en "."
    1718     LogAll "----------- syslinux's conf --------------"
    1719     cat $MINDI_TMP/usb/syslinux.cfg |tee -a $LOGFILE
    1720     LogAll "------------------------------------------"
    1721     umount $MINDI_TMP/usb
     1700    fi
     1701    MindiExit -1
     1702fi
     1703
     1704LogAll "INFO: Moving boot info on $MINDI_TMP/mpt"
     1705mv $MINDI_TMP/target/* $MINDI_TMP/mpt
     1706if [ "$?" -ne "0" ] ; then
     1707    LogFile "--------------------------------"
     1708    LogFile "INFO: Size of $MINDI_TMP/mpt:"
     1709    du -sk $MINDI_TMP/mpt/* >> $LOGFILE
     1710    LogFile "--------------------------------"
     1711    umount $MINDI_TMP/mpt
     1712    LogAll "ERROR: Problems while creating boot media."
     1713    LogAll "       Please unload some of your modules and try again."
     1714    Die    "       Try to increase EXTRA_SPACE in $MINDI_CONFIG"
     1715fi
     1716
     1717if  [ "$target" = "ISO" ]; then
     1718    # ISO
     1719    if [ "$ARCH" != "ia64" ] ; then
     1720        CMD="$ISO_CMD $ISO_OPT -b $tbc/isolinux.bin -c $tbc/boot.cat -U -boot-load-size 4 -boot-info-table"
     1721    else
     1722        CMD="$ISO_CMD $ISO_OPT -b images/mindi-bootroot.img -c images/boot.cat"
     1723    fi
     1724    LogAll "INFO: Invoking $CMD"
     1725    (cd "$MINDI_TMP/mpt" ; $CMD .) > /dev/null 2> $MINDI_TMP/mkisofs.log
     1726    if [ "$?" -ne "0" ] ; then
     1727        if [ "$BOOT_TYPE" = "UEFI" ]; then
     1728            CMD=`echo $CMD | perl -p -e 's|--efi-boot |-eltorito-platform 0xEF -eltorito-boot |; s|-efi-boot |-eltorito-platform 0xEF -eltorito-boot |;'`
     1729            (cd "$MINDI_TMP/mpt" ; $CMD .) > /dev/null 2> $MINDI_TMP/mkisofs.log
     1730            if [ "$?" -eq "0" ] ; then
     1731                LogAll "INFO: Created bootable ISO image at $MINDI_CACHE/mindi.iso"
     1732            else
     1733                MakeISOErrors
     1734            fi
     1735        else
     1736            MakeISOErrors
     1737        fi
     1738    else
     1739        LogAll "INFO: Created bootable ISO image at $MINDI_CACHE/mindi.iso"
     1740    fi
     1741    rm -f $MINDI_TMP/mkisofs.log
     1742fi
     1743
     1744umount $MINDI_TMP/mpt || Die "Unable to unmount $MINDI_TMP/mpt"
     1745
     1746if  [ "$target" = "ISO" ]; then
     1747    # ISO
     1748    if [ "$BOOT_TYPE" = "BIOS" ]; then
     1749        # syslinux should be run on a  local file (doen't work through NFS Cf: #297)
     1750        # and run after the formating for versions > 6 it seems
     1751        syslinux $part >> $LOGFILE 2>> $LOGFILE
     1752    fi
     1753    cp $part $MINDI_CACHE
     1754else
     1755    # USB
    17221756    if [ "$ARCH" != "ia64" ] ; then
    17231757        syslinux -v 2>&1 | grep -q 4.02
     
    17361770            LogIt "ERROR: Failed to create USB image."
    17371771        else
    1738             echo -e "$DONE"
    17391772            LogFile "INFO: Created bootable USB image on $USBDEVICE"
    17401773        fi
     
    17441777        MindiExit -1
    17451778    fi
     1779fi
     1780}
     1781
     1782
     1783OfferToMakeBootableUSB() {
     1784
     1785local i files
     1786
     1787if [ "$PROMPT_MAKE_USB_IMAGE" = "yes" ] && [ _"$MONDO_SHARE" = _"" ]; then
     1788    echo -en "\nShall I make a bootable USB device ? (y/[n]) "
     1789    read i
     1790    [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
     1791    if [ "$USBDEVICE" = "" ]; then
     1792        echo -en "Please enter the device name of your USB device (e.g. /dev/sda) : "
     1793        read dev
     1794        USBDEVICE=$dev
     1795    fi
     1796    echo "WARNING: This will erase all content on $USBDEVICE"
     1797    echo -en "Are you sure you want to use $USBDEVICE (y/[n]) "
     1798    read i
     1799    [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
     1800else
     1801    if [ "$PROMPT_MAKE_USB_IMAGE" = "no" ] && [ _"$MONDO_SHARE" = _"" ] && [ "$USBDEVICE" = "" ]; then
     1802        Die "No USBDEVICE environment variable declared, aborting"
     1803    fi
     1804fi
     1805USBPART="${USBDEVICE}1"
     1806
     1807MakeBootableDevice USB
     1808}
     1809
     1810
     1811OfferToMakeBootableISO() {
     1812
     1813local i files
     1814
     1815if [ -z "$ISO_CMD" ]; then
     1816    LogAll "ERROR: Neither mkisofs nor genisoimage nor xorriso found, unable to make CD image"
     1817    return
     1818fi
     1819
     1820if [ "$PROMPT_MAKE_CD_IMAGE" = "yes" ] && [ _"$MONDO_SHARE" = _"" ]; then
     1821    echo -en "\nShall I make a bootable CD image? (y/[n]) "
     1822    read i
     1823    [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
     1824fi
     1825
     1826MakeBootableDevice ISO
     1827
    17461828}
    17471829
     
    17771859                echo -en "$BOOT_MEDIA_MESSAGE"
    17781860            elif [ ! "$MINDI_TMP" ] ; then
    1779                 echo -en "FYI, this is _not_ a Mondo Rescue CD.\n"
    1780                 if [ -e "$MINDI_LIB/memtest.img" ] ; then
    1781                  echo -en "Type 'memtest' <Enter> to test your PC's memory intensively.\nJust press <Enter> to go to the main test menu.\n"
    1782                 fi
     1861                echo -en "FYI, this is _not_ a MondoRescue CD.\n"
     1862                if [ -e "$MINDI_LIB/memtest.img" ] ; then
     1863                    echo -en "Type 'memtest' <Enter> to test your PC's memory intensively.\nJust press <Enter> to go to the main test menu.\n"
     1864                fi
    17831865            else
    17841866                echo -en "$BOOT_MEDIA_MESSAGE"
     
    19182000}
    19192001
    1920 PrepareBootDiskImage() {
    1921     # LILO originally
    1922     local dev imagefile fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootconf bootimage
    1923     kernelpath=$1
    1924     retval=0
    1925 
    1926     old_pwd=`pwd`
    1927     [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
    1928     TurnTgzIntoRdz $MINDI_LIB/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into initrd.img; are you SURE your kernel supports loopfs?"
    1929     echo -en "Making "$BOOT_SIZE"KB boot disk..."
    1930     imagefile=$MINDI_TMP/mindi-bootroot.img
    1931     mkdir -p $mountpoint
    1932     dd if=/dev/zero of=$imagefile bs=1k count=$BOOT_SIZE &> /dev/null || Die "Cannot dd blank file"
    1933     echo -en "..."
    1934     #if [ "$BOOT_TYPE" = "UEFI" ]; then
    1935         # Should be GPT in that case to allow direct boot
    1936         #parted -s $imagefile mklabel gpt
    1937         #parted -s $imagefile mkpart fat32 1 ${BOOT_SIZE}k 2> /dev/null
    1938         #kpartx -a $imagefile
    1939         #imagefile2=/dev/mapper/`kpartx -l $imagefile | awk '{print $1}'`
    1940     #else
    1941         #imagefile2=$imagefile
    1942     #fi
    1943     LogFile "INFO: Creating vfat filesystem on $imagefile"
    1944     mkfs.vfat $imagefile >> $LOGFILE 2>> $LOGFILE
    1945 
    1946     if [ "$BOOT_TYPE" = "BIOS" ]; then
    1947         # syslinux should be run on a  local file (doen't work through NFS Cf: #297)
    1948         # and run after the formating for versions > 6 it seems
    1949         syslinux $imagefile >> $LOGFILE 2>> $LOGFILE
    1950     fi
    1951 
    1952     # Only move it now to its final destination and use it now
    1953     mv $imagefile $MINDI_CACHE
    1954     imagefile=$MINDI_CACHE/mindi-bootroot.img
    1955 
    1956     mount -t vfat -o loop $imagefile $mountpoint || Die "ERROR: Cannot mount $imagefile on $mountpoint (PBDI)"
    1957 
    1958     LogFile "INFO: Copying $MINDI_TMP/initrd.img to $mountpoint/initrd.img..."
    1959     cp -f $MINDI_TMP/initrd.img $mountpoint/initrd.img 2>> $LOGFILE
    1960     if [ "$?" -ne "0" ] ; then
    1961         LogAll "ERROR: Failed to copy $MINDI_TMP/initrd.img to $mountpoint"
    1962         LogAll "       Please unload some of your modules and try again."
    1963         LogAll "ERROR: Cannot incorporate initrd.img in bootdisk (kernel / modules too big?)"
    1964         LogAll "       Try to increase EXTRA_SPACE and BOOT_SIZE in $MINDI_CONFIG"
    1965         retval=$(($retval+1))
    1966     fi
    1967     #MakeMessageFile $mountpoint | cut -c1-80 > $mountpoint/message.txt
    1968 
    1969     mkdir -p $mountpoint/tmp
    1970     if [ -f "$MINDI_TMP/$MRCFG" ]; then
    1971         cp -f $MINDI_TMP/$MRCFG $mountpoint/tmp
    1972     fi
    1973 
    1974     # copy the kernel across
    1975     [ "$mountpoint" != "" ] && rm -Rf $mountpoint/lost+found
    1976     dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
    1977     free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
    1978 
    1979     retval=0
    1980     cp -f $kernelpath $mountpoint/vmlinuz > /dev/null 2>> $LOGFILE
    1981     retval=$?
    1982     if [ $KERNEL_IS_XEN = "yes" ]; then
    1983         cp -f $xenkernelpath $mountpoint/xenkernel &> /dev/null
    1984         let retval+=$?
    1985     fi
    1986  
    1987     if [ "$retval" -ne "0" ] ; then
    1988         LogFile "INFO: Files at mountpoint ($mountpoint) :"
    1989         du -sk $mountpoint/* >> $LOGFILE
    1990         LogFile "--- end of list of files ---"
    1991         echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n" >> $LOGFILE
    1992         [ "$mountpoint" != "" ] && rm -f $mountpoint/vmlinuz
    1993         cd "$old_pwd"
    1994         umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    1995         rmdir $mountpoint || LogAll "ERROR: Cannot rmdir (PBDI)"
    1996         [ "$imagefile" != "" ] && rm -f $imagefile
    1997         LogIt "ERROR: Sorry, your kernel is too big for your image"
    1998         Die "Try to increase EXTRA_SPACE and BOOT_SIZE in $MINDI_CONFIG"
    1999     fi
    2000     max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
    2001     LogFile "INFO: Free space left on image = $free_space KB"
    2002     LogFile "INFO: Max kernel size on $BOOT_SIZE KB image (est'd) = $max_kernel_size K"
    2003 
    2004     # make it bootable
    2005     [ "$mountpoint" != "" ] && rm -f $mountpoint/zero
    2006     [ -e "$MINDI_LIB/memdisk" ] && cp -f $MINDI_LIB/memdisk $mountpoint 2>> $LOGFILE
    2007 
    2008     # copy boot stuff now generated in PrepareDataDiskImage
    2009     if [ "$BOOT_TYPE" = "UEFI" ]; then
    2010         (cd $mountpoint ; tar xfz $MINDI_CACHE/all.tar.gz ./EFI)
    2011     else
    2012         (cd $mountpoint ; tar xfz $MINDI_CACHE/all.tar.gz ./syslinux)
    2013     fi
    2014 
    2015     umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    2016     echo -en "..."
    2017     rmdir $mountpoint || LogAll "ERROR: Cannot rmdir (PBDI)"
    2018 
    2019     if [ "$retval" -eq "0" ] ; then
    2020         echo -en "...$DONE\n"
    2021         LogAll "INFO: $BOOT_SIZE KB boot disks were created OK\n"
    2022     else
    2023         echo -en "...failed\n"
    2024         LogAll "WARNING: $BOOT_SIZE""KB boot disk was NOT created\n"
    2025     fi
    2026     [ "$retval" -ne "0" ] && LogAll "ERROR: PrepareBootDiskImage() is returning $retval"
    2027     return $retval
    2028 }
    2029 
    20302002ParseModprobeForIncludes() {
    20312003local MODPROBE_CONF mpincfile includes include
     
    20492021
    20502022PrepareDataDiskImages() {
    2051     local needlist bigdir diskdir res i j k old_pwd lines lfiles includefile
     2023    local needlist bigdir diskdir res i j k lines lfiles includefile
    20522024
    20532025    rm -f $MINDI_CACHE/mindi.iso
     
    20842056    [ -d "/mnt/.boot.d" ] && echo "GENTOO" > $bigdir/tmp/DUMBASS-GENTOO
    20852057    DropOptimizedLibraries $needlist $bigdir
    2086     echo -en "Assembling dependency files"
    2087 
    2088     CopyDependenciesToDirectory < $needlist $bigdir `wc -l $needlist`
     2058    echo -en "INFO: Assembling dependency files"
     2059
     2060    CopyDependenciesToDirectory < $needlist $bigdir `wc -l $needlist` 1
     2061    echo -e "$DONE"
    20892062
    20902063    # also copy io.sys and msdos.sys, if we can find them
     
    21092082    fi
    21102083
    2111     old_pwd=`pwd`
    2112     cd "$bigdir"
    2113 
    21142084    # Get terminfo content
    21152085    ti="usr/share/terminfo/l"
    21162086    if [ -d /$ti ]; then
    2117         mkdir -p $ti
    2118         cp -Rdf /$ti/* $ti 2>> $LOGFILE || LogAll "ERROR: issue copying terminfo"
     2087        mkdir -p $bigdir/$ti
     2088        cp -Rdf /$ti/* $bigdir/$ti 2>> $LOGFILE || LogAll "ERROR: issue copying terminfo"
    21192089    fi
    21202090    if [ -e "$MONDO_SHARE/restore-scripts" ]; then
     
    21252095        cp -a /lib/dev-state ./lib/ 2>> $MINDI_TMP/$$.log || LogAll "ERROR: Unable to handle /lib/dev-state" $MINDI_TMP/$$.log
    21262096    fi
    2127     cd "$old_pwd"
    2128     echo -e "$DONE"
    21292097    TOTAL_BIGDIR_SIZE=`du -sk $bigdir | cut -f1`
    21302098    MakeMountlist $MINDI_TMP/mountlist.txt
     
    21472115        fi
    21482116    fi
    2149     LogFile "Your mountlist.txt file content is:"
     2117    LogFile "INFO: Your mountlist.txt file content is:"
    21502118    LogFile "-----------------------------------"
    21512119    cat $bigdir/tmp/mountlist.txt >> $LOGFILE
     
    22062174            bootconf="$efidir/elilo.conf"
    22072175        fi
    2208         LogAll "Found $boottype boot type"
     2176        LogAll "INFO: Found $boottype boot type"
    22092177
    22102178        # Copy it so that CD-ROM menu entry is satisfied
     
    22142182            mount /boot/efi
    22152183            if [ $? -ne 0 ]; then
    2216                 echo "You have to mount your (U)EFI partition when using mindi"
     2184                echo "ERROR: You have to mount your (U)EFI partition when using mindi"
    22172185                MindiExit -1
    22182186            fi
     
    22372205        if [ -e "$LDLINUXC32" ]; then
    22382206            LogFile "INFO: Copying $LDLINUXC32 to $bootdir"
    2239             cp $LDLINUXC32 $bootdir 2>> $LOGFILE || Die "Cannot copy $LDLINUXC32 to $bootdir). Did you run out of disk space?"
     2207            cp $LDLINUXC32 $bootdir 2>> $LOGFILE || Die "Cannot copy $LDLINUXC32 to $bootdir. Did you run out of disk space?"
    22402208        fi
    22412209    fi
     
    22432211    MakeBootConfFile $boottype > $bootconf
    22442212
    2245     echo -en "Tarring and zipping the data content..."
     2213    echo -en "INFO: Tarring and zipping the data content..."
    22462214    size_of_all_tools=`du -sk $bigdir | cut -f1`
    22472215    (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)
     
    22522220    echo -e "$DONE"
    22532221
    2254     FRIENDLY_OUTSTRING="Boot and data disk images were created."
    22552222    rm -rf $bigdir
    22562223    rm -f $needlist
     
    24932460
    24942461
    2495 TurnTgzIntoRdz() {
    2496     local tgz_dir_fname rdz_fname tempfile old_pwd nodes kernelsize maxsize res currsize not_copied j k s w needed_modules_path d thelink templog
     2462MakeBootInitFile() {
     2463    local tgz_dir_fname rdz_fname tempfile nodes kernelsize res currsize not_copied j k s w needed_modules_path d thelink templog
    24972464
    24982465    tgz_dir_fname=$1
    24992466    rdz_fname=$2
    25002467    kernelsize=$3
    2501     maxsize=$(($BOOT_SIZE-$kernelsize))
    2502     maxsize=$(($maxsize*2)); # to allow for compression of 50%
    25032468    tempfile=$MINDI_TMP/temp.rd
    25042469    res=0
     
    25062471    > $templog
    25072472
    2508     echo -en "..."
    2509     dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (TurnTgzIntoRdz)"
    2510     echo -en "..."
    2511     LogFile "INFO: Creating ext2 filesystem on $tempfile"
     2473    LogAll "INFO: Making Boot RAM Disk ($ramdisk_size KB)"
     2474    dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (MakeBootInitFile)"
     2475    LogAll "INFO: Creating ext2 filesystem on $tempfile"
    25122476    mke2fs -b 1024 -m 1 -i 2048 -F $tempfile >> $LOGFILE 2>> $LOGFILE || Die "Unable to create an ext2 file system on $tempfile"
    2513     echo -en "..."
    25142477    mkdir -p $mountpoint
    25152478    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."
    2516     echo -en "..."
    2517     old_pwd=`pwd`
    2518     cd "$mountpoint"
    25192479
    25202480    # Check whether /lib64 or /lib or /sbin or /bin is a link and if so explicitly create one in rootfs (Fedora 17 crazyness)
     
    25352495
    25362496    LogFile "INFO: what is now in $mountpoint"
    2537     ls -alR $mountpoint >> $LOGFILE
     2497    ls -al $mountpoint >> $LOGFILE
    25382498   
    25392499    # Check files before copying to discover configuration issues or McAfee preventing mindi reading these files
    25402500    # copy from rootfs into mountpoint
     2501    LogAll "INFO: Copying Mindi files onto $mountpoint"
    25412502    for f in $tgz_dir_fname/*; do
    25422503        if [ ! -r $f ]; then
    25432504            Die "ERROR: Unable to copy $f to the target dir. Check your installation or McAfee presence"
    25442505        else
    2545             cp -af $f . 2>&1 >> $LOGFILE
     2506            cp -af $f $mountpoint 2>&1 >> $LOGFILE
    25462507        fi
    25472508    done
    2548     (cd etc ; ln -sf bashrc profile ; ln -sf bashrc shrc ; ln -sf ../proc/mounts mtab ; ln -sf ../usr/sbin/init linuxrc)
    2549     ln -sf usr/sbin/init linuxrc
    2550 
    2551     cd dev || Die "Can't cd to dev"
    2552     tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz"
    2553     rm -f dev-entries.tgz
    2554     cd ..
     2509    (cd $mountpoint/etc ; ln -sf bashrc profile ; ln -sf bashrc shrc ; ln -sf ../proc/mounts mtab ; ln -sf ../usr/sbin/init linuxrc)
     2510    (cd $mountpoint ; ln -sf usr/sbin/init linuxrc)
     2511
     2512    (cd $mountpoint/dev ; tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz" ; rm -f dev-entries.tgz)
    25552513
    25562514    for w in insmod.static insmod.static.old ; do
    25572515        s=`which $w 2> /dev/null`
    25582516        if [ -e "$s" ] ; then
    2559             tar cf - -C / $s 2> /dev/null | tar xf -
     2517            tar cf - -C / $s 2> /dev/null | (cd $mountpoint ; tar xf -)
    25602518        fi
    25612519    done
     
    25812539    fi
    25822540
    2583     # Copy of files from the minimal env needed as per the deplist.d/minimal.conf & udev.conf file (which includes all busybox deps)
     2541    # Copy of files from the minimal env needed as per the deplist.d/minimal.conf (which includes all busybox deps)
     2542    echo -en "INFO: Gathering dependencies of required files..."
    25842543    rm -f $MINDI_TMP/minimal.lis $MINDI_TMP/minimal2.lis
    2585     for f in `cat $DEPLIST_DIR/minimal.conf $DEPLIST_DIR/udev.conf | grep -vE " *#.*|^#" | sort -u` ; do
     2544    lines=`cat $DEPLIST_DIR/minimal.conf | grep -vE " *#.*|^#" | sort -u`
     2545    noof_lines=`echo $lines | wc -w`
     2546    progress=0
     2547    for f in $lines; do
    25862548        if [ -d $f ]; then
    25872549            for g in `find $f`; do
     
    25952557            fi
    25962558        fi
     2559        progress=$(($progress+1))
     2560        LogProgress $progress $noof_lines
    25972561    done
    2598     LogAll "Processing all dependencies of required files..."
    2599     for f in `sort -u $MINDI_TMP/minimal.lis $MINDI_TMP/minimal2.lis`; do
     2562    echo -e "$DONE"
     2563    echo -en "INFO: Processing all dependencies links..."
     2564    lines=`sort -u $MINDI_TMP/minimal.lis $MINDI_TMP/minimal2.lis`
     2565    noof_lines=`echo $lines | tr ' ' '\n' | wc -l`
     2566    progress=0
     2567    for f in $lines; do
    26002568        mr-read-all-link $f >> $MINDI_TMP/minimal.lis
     2569        progress=$(($progress+1))
     2570        LogProgress $progress $noof_lines
    26012571    done
     2572    echo -e "$DONE"
    26022573    # Initial / are trucated by tar
    26032574    finallist=""
     
    26152586    rm -f $MINDI_TMP/minimal.lis $MINDI_TMP/minimal2.lis
    26162587
    2617     fnllist=`echo $finallist | sort -u`
    2618     #tar cf - $finallist 2> $templog | tar xf - || LogIt "WARNING: Problem in minimal analysis" $templog
    2619     echo "INFO: Copy the minimal env with cp -a --parents $finallist -t $mountpoint" 2>&1 >> $templog
     2588    fnllist=`echo $finallist | tr ' ' '\n' | sort -u | tr '\n' ' '`
     2589    LogFile "INFO: Copy the minimal env with cp -a --parents $fnllist -t $mountpoint"
    26202590    cp -a --parents $fnllist -t $mountpoint 2> $templog || LogIt "WARNING: Problem in minimal analysis" $templog
    26212591
     
    26272597    # For older distributions expecting /sbin/init provides it
    26282598    if [ ! -e "sbin/init" ]; then
    2629         (cd sbin ; ln -sf ../usr/sbin/init .)
     2599        (cd $mountpoint/sbin ; ln -sf ../usr/sbin/init .)
    26302600    fi
    26312601
    26322602    # To improve support for distribution scripts, we now prefer to use bash as the std shell. Also fixes #600
    2633     ln -sf /bin/bash bin/sh
     2603    (cd $mountpoint ; ln -sf /bin/bash bin/sh)
    26342604    LogFile "INFO: Using bash as default shell"
    26352605
     
    26372607    rm -f $mountpoint/etc/ld.so.conf.d/kernelcap*
    26382608
    2639     mkdir -p $mountpoint/tmp
    26402609    # Management of udev (which includes modprobe in rules)
    26412610    ps auxww | grep -v grep | grep -qw udevd
     
    26972666                fi
    26982667            done
    2699             #tar cf - -C / $lis `sort -u $MINDI_TMP/udev.lis` 2> $templog | tar xf - || LogIt "ERROR: Problem in udev.lis analysis" $templog
    2700             echo "INFO: Copying udev related files with cp -a --parents $finallist -t $mountpoint/" 2>&1 >> $templog
    2701             cp -a --parents $finallist -t $mountpoint/ 2> $templog  || LogIt "ERROR: Problem in udev.lis analysis" $templog
     2668            fnllist=`echo $finallist | tr ' ' '\n' | sort -u | tr '\n' ' '`
     2669            LogFile "INFO: Copying udev related files with cp -a --parents $fnllist -t $mountpoint/"
     2670            cp -a --parents $fnllist -t $mountpoint/ 2> $templog  || LogIt "ERROR: Problem in udev.lis analysis" $templog
    27022671            rm -f $MINDI_TMP/udev.lis
    27032672        else
     
    27132682    if [ -d $MINDI_CACHE/bkphw ]; then
    27142683        LogIt "INFO: Hardware Information found and saved ..."
    2715         cp -rp $MINDI_CACHE/bkphw .
     2684        cp -rp $MINDI_CACHE/bkphw $mountpoint
    27162685        if [ -f $MINDI_CACHE/tools.files ]; then
    27172686            lis=`grep -Ev '^#' $MINDI_CACHE/tools.files`
    27182687            LocateDeps $lis > $MINDI_TMP/tools.lis
    2719             tar cf - $lis `sort -u $MINDI_TMP/tools.lis` 2> $templog | tar xf - || LogIt "ERROR: Problem in tools.lis analysis" $templog
     2688            tar cf - $lis `sort -u $MINDI_TMP/tools.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogIt "ERROR: Problem in tools.lis analysis" $templog
    27202689        fi
    27212690        if [ -f $MINDI_CACHE/mindi-rsthw ]; then
    2722             mv -f $MINDI_CACHE/mindi-rsthw .
    2723             chmod 755 ./mindi-rsthw
     2691            mv -f $MINDI_CACHE/mindi-rsthw $mountpoint
     2692            chmod 755 $mountpoint/mindi-rsthw
    27242693        fi
    27252694        rm -f $MINDI_TMP/tools.lis $MINDI_CACHE/tools.files
     
    27272696
    27282697    # Management of perl scripts delivered needed at restore time
    2729     LogAll "Analyzing perl modules dependencies..."
     2698    LogAll "INFO: Analyzing perl modules dependencies..."
    27302699    mindi-get-perl-modules `cat $MINDI_CONF/perl-scripts` /usr/[s]*bin/mr-* 2> $templog > $MINDI_TMP/perl.lis || LogIt "ERROR: Problem in mindi-get-perl-modules" $templog
    27312700    LogFile "DBG4: Perl Modules found:"
     
    27332702    cat $MINDI_TMP/perl.lis >> $LOGFILE
    27342703    LogFile "-------------------------"
    2735     tar cf - `cat $MINDI_TMP/perl.lis` 2> $templog | tar xf - || LogIt "ERROR: Problem in perl scripts analysis" $templog
     2704    tar cf - `cat $MINDI_TMP/perl.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogIt "ERROR: Problem in perl scripts analysis" $templog
    27362705
    27372706    for w in cdrom groovy-stuff ; do
     
    27392708    done
    27402709
    2741     tar cf - -C / /dev/fd0*[1,2][4,7,8]* 2> $templog | tar xf -  || LogIt "ERROR: Problem in fd dev analysis" $templog
    2742 
    2743     echo -en "..."
    2744     cd /
     2710    tar cf - -C / /dev/fd0*[1,2][4,7,8]* 2> $templog | (cd $mountpoint ; tar xf -) || LogIt "ERROR: Problem in fd dev analysis" $templog
    27452711
    27462712    needed_modules=""
     
    27642730    fi
    27652731
    2766     [ -e "$needed_modules_path" ] || LogIt "WARNING: path $needed_modules_path does not exist.\n         If you're not using a modular kernel then mindi won't probably work."
    2767     LogAll "Analyzing kernel modules dependencies..."
     2732    [ -e "/$needed_modules_path" ] || LogIt "WARNING: path $needed_modules_path does not exist.\n         If you're not using a modular kernel then mindi won't probably work."
     2733    LogAll "INFO: Analyzing kernel modules dependencies..."
    27682734    needed_modules=`mr-kernel-get-modules $mkgmopt $list_of_groovy_mods`
    27692735
     
    28202786            lis="/usr/bin/sg_map /usr/bin/sg_inq /usr/bin/sg_reset /usr/bin/rev"
    28212787            LocateDeps $lis > $MINDI_TMP/obdr.lis
    2822             (cd $mountpoint ; tar cf - $lis -C /  `sort -u $MINDI_TMP/obdr.lis` 2> $templog | tar xf - || LogIt "ERROR: Problem in obdr.lis analysis" $templog)
     2788            tar cf - $lis -C /  `sort -u $MINDI_TMP/obdr.lis` 2> $templog | (cd $mountpoint ; tar xf -) || LogIt "ERROR: Problem in obdr.lis analysis" $templog
    28232789            LogIt "INFO: Copying /usr/bin/sg_reset to ramdisk for improved SCSI OBDR support"
    28242790            found=1
     
    28352801        rm -f $mountpoint/sbin/devfsd
    28362802    fi
    2837     cd "$old_pwd"
    28382803    [ "$TAPEDEV" ] && echo -en "$TAPEDEV" > $mountpoint/tmp/TAPEDEV-LIVES-HERE
    28392804    if [ _"$MONDO_SHARE" != _"" ]; then
     
    28502815        echo $m >> $mountpoint/tmp/modules
    28512816    done
    2852 
    2853     # copy boot stuff now generated in PrepareDataDiskImage
    2854     if [ "$BOOT_TYPE" = "UEFI" ]; then
    2855         (cd $mountpoint ; tar xfz $MINDI_CACHE/all.tar.gz ./EFI)
    2856     else
    2857         (cd $mountpoint ; tar xfz $MINDI_CACHE/all.tar.gz ./syslinux)
    2858     fi
    28592817
    28602818    mkdir -p $mountpoint/proc
     
    28772835        LogFile "INFO: Creating an $gvFileSystem initrd image..."
    28782836        # kernel expects linuxrc in ext2 filesystem
    2879         ( cd "$mountpoint" && ln -sf usr/sbin/init linuxrc )
     2837        (cd "$mountpoint" && ln -sf usr/sbin/init linuxrc)
    28802838        # unmount loop filesystem and create image file using the standard approach
    28812839        umount $mountpoint || Die "Cannot unmount $tempfile"
    2882         dd if=$tempfile bs=1k 2> /dev/null > ${rdz_fname}.tmp 2> /dev/null
     2840        dd if=$tempfile bs=1k of=${rdz_fname}.tmp > /dev/null 2> /dev/null
    28832841        if [ "$gvFileSystem" = "ext4fs" ] && [ -x "/sbin/tune4fs" ]; then
    28842842            bs=`/sbin/tune4fs -l ${rdz_fname}.tmp | grep -E '^Block size:' | cut -d: -f2 | sed 's/^ *//'`
     
    28902848        rm -f ${rdz_fname}.tmp
    28912849        # log that we are done
    2892         LogFile "      ...done."
    28932850    elif [ "$gvFileSystem" = "initramfs" ]; then
    28942851        # say what will be used
     
    28962853        # make sure that cpio is there
    28972854        which cpio &> /dev/null; [ $? -eq 0 ] || Die "cpio not found. Please install package cpio and try again."
    2898         # go into filesystem
    2899         cd "$mountpoint"
    29002855        # kernel expects init in cpio filesystem
    2901         ln -sf usr/sbin/init init
     2856        (cd "$mountpoint" ; ln -sf usr/sbin/init init)
    29022857        # create cpio image file and unmount loop filesystem
    2903         find . -print | cpio -o -H newc | gzip -9 > $rdz_fname 2> /dev/null
    2904         cd "$old_pwd"
     2858        (cd "$mountpoint" ; find . -print | cpio -o -H newc | gzip -9 > $rdz_fname 2> /dev/null)
    29052859        umount $mountpoint || Die "Cannot unmount $tempfile"
    29062860        # log that we are done
    2907         LogFile "      ...done."
    29082861    else
    29092862        Die "Filesystem $gvFileSystem not supported for initrd image. Terminating."
     
    29112864
    29122865    if [ "$res" -eq "0" ] ; then
    2913         echo -en "..."
     2866        echo -en "\rINFO: MakeBootInitFile finished without error.      \n"
    29142867    else
    2915         echo -en "\rMade an rdz WITH ERRORS.           \n"
     2868        echo -en "\rWARNING: MakeBootInitFile exits WITH ERRORS.           \n"
    29162869    fi
    29172870    return 0
     
    29792932LogFile "--------"
    29802933LogFile "EXTRA_SPACE = $EXTRA_SPACE"
    2981 LogFile "BOOT_SIZE = $BOOT_SIZE"
    29822934LogFile "--------"
    29832935
     
    31973149    LogFile "WARNING:  - Disable the scanner during the backup"
    31983150fi
    3199 
    3200 FLOPPY_WAS_MOUNTED=""
    3201 for mtpt in /media/floppy /mnt/floppy /floppy ; do
    3202     if mount | grep -w $mtpt &> /dev/null ; then
    3203         FLOPPY_WAS_MOUNTED="$FLOPPY_WAS_MOUNTED $mtpt"
    3204         umount $mtpt
    3205     fi
    3206 done
    32073151
    32083152#
     
    34093353if [ "$kernelpath" = "" ] ; then
    34103354    [ _"$MONDO_SHARE" != _"" ] && Die "Please use -k <path> to specify kernel."
    3411     echo -en "Do you want to use your own kernel to build the boot disk ([y]/n) ?"
     3355    echo -en "\nDo you want to use your own kernel to build the boot disk ([y]/n) ?"
    34123356    read ch
    34133357    if [ "$ch" != "n" ] && [ "$ch" != "N" ] ; then
     
    34323376
    34333377export ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE))
    3434 
    34353378LogFile "INFO: Ramdisk will be $ramdisk_size KB"
    3436 PrepareBootDiskImage $kernelpath || Die "Failed to create boot disk image."
     3379
     3380MakeBootInitFile $MINDI_LIB/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not create initrd.img"
    34373381
    34383382[ -e "$MINDI_LIB/memtest.img" ] && BOOT_MEDIA_MESSAGE="$BOOT_MEDIA_MESSAGE\n\
     
    34403384
    34413385if [ _"$MONDO_SHARE" = _"" ]; then
    3442     ListImagesForUser
    34433386    OfferToMakeBootableISO
    34443387    if [ "$PROMPT_MAKE_USB_IMAGE" = "yes" ]; then
    34453388        OfferToMakeBootableUSB
    34463389    fi
    3447     LogAll "Finished."
     3390    LogAll "INFO: Mindi Finished"
    34483391elif [ "$TAPEDEV" ] ; then
    34493392    if [ "$ARCH" != "ia64" ] ; then
     
    34793422fi
    34803423# cleanup
    3481 LogAll "INFO: $FRIENDLY_OUTSTRING"
    3482 for mtpt in $FLOPPY_WAS_MOUNTED ; do
    3483     mount $mtpt
    3484 done
    34853424MindiExit 0
  • branches/3.2/mindi/mindi.conf

    r3521 r3522  
    1111#
    1212# EXTRA_SPACE=80152     # increase if you run out of ramdisk space
    13 # BOOT_SIZE=32768       # size of the boot disk
    1413# MINDI_ADDITIONAL_BOOT_PARAMS="devfs=nomount noresume selinux=0 barrier=off udevtimeout=10 acpi=off"
    1514# 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.