Changeset 3057 in MondoRescue


Ignore:
Timestamp:
Nov 2, 2012, 8:28:12 PM (11 years ago)
Author:
Bruno Cornec
Message:
  • Fix #611 by changing make-me-bootable to first desactivate all active partitions on the given disk, and then reactivate only the one needed (change of interface for this script). This remains not very satisfactory, and storing active flags at backup time would probably be better, but would require to handle HW modification cases with this script anyway.
Location:
branches/3.0/mondo/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/mondorestore/mondo-prep.c

    r3048 r3057  
    16911691
    16921692    if (pout_to_fdisk) {
    1693 // mark relevant partition as bootable
    1694         sprintf(tmp, "a\n%s\n",
    1695                 call_program_and_get_last_line_of_output
    1696                 ("make-me-bootable /tmp/mountlist.txt dummy"));
    1697         fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    1698 // close fdisk
     1693        // close fdisk
    16991694        fput_string_one_char_at_a_time(pout_to_fdisk, "p\n");
    17001695        fput_string_one_char_at_a_time(pout_to_fdisk, "w\n");
     1696        paranoid_pclose(pout_to_fdisk);
    17011697        system("sync");
    1702         paranoid_pclose(pout_to_fdisk);
    1703         log_msg(0,
    1704                 "------------------- fdisk.log looks like this ------------------");
     1698        log_msg(0,"------------------- fdisk.log looks like this ------------------");
    17051699        sprintf(tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);
    17061700        system(tmp);
    1707         log_msg(0,
    1708                 "------------------- end of fdisk.log...       ------------------");
     1701        // mark relevant partition as bootable
     1702        mr_asprintf(&tmp1,"make-me-bootable /tmp/mountlist.txt %s noaction",drivename);
     1703        call_program_and_get_last_line_of_output(tmp1);
     1704        mr_free(tmp1);
     1705        log_msg(0,"------------------- end of fdisk.log...       ------------------");
     1706        system("sync");
    17091707        sprintf(tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG);
    17101708        if (!run_program_and_log_output(tmp, 5)) {
  • branches/3.0/mondo/src/restore-scripts/mondo/make-me-bootable

    r2196 r3057  
    22
    33
    4 if [ "$#" -ne "1" ] && [ "$#" -ne "2" ] ; then
    5     echo "make-me-bootable <fname> (dummy)"
     4if [ "$#" -ne "2" ] && [ "$#" -ne "3" ] ; then
     5    echo "make-me-bootable <fname> <drive> [noaction]"
    66    exit 1
    77fi
    88
    9 dummy=$2
     9drivetouse=$2
    1010boot_drv=""
    1111boot_part=""
    1212root_drv=""
    1313root_part=""
     14if [ ! "$LOGFILE" ]; then
     15    LOGFILE="/tmp/mondorestore2.log"
     16fi
     17dummy="$3"
    1418
    15 HAVE_ACTIVE="false"
     19activepart=`parted2fdisk -l $drivetouse | tr -s '\t' ' ' | grep "$drivetouse" | grep '*' | cut -d' ' -f1`
     20
    1621for i in `cat $1 | tr -s '\t' ' ' | cut -d' ' -f1 | grep -vE "/dev/fd|none|#"` ; do
    17     mountpt=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f2`
    18     format=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f3`
    1922    # Warning wrong if LVM !
    2023    drive=`echo $i | sed -e 's/[0-9]*$//' -e 's/\([0-9]\)p$/\1/'`
    21     partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
     24    if [ "$drivetouse" = "$drive" ]; then
     25        # We can continue as this is the drive we ned to work on
     26        partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
     27        mountpt=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f2`
    2228
    23     if [ "$HAVE_ACTIVE" = "false" ] && [ "`parted2fdisk -l $drive | tr -s '\t' ' ' | grep "$i " | grep -v "*"`" ] ; then
    2429        if [ "$mountpt" = "/" ] ; then
    2530            root_drv=$drive
    26         root_part=$partno
     31            root_part=$partno
    2732        elif [ "$mountpt" = "/boot" ] ; then
    2833            boot_drv=$drive
     
    4651
    4752if [ "$drive" ] ; then
     53    if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
     54        partno="1"
     55    fi
     56    cmd=""
     57    for p in "$activepart"; do
     58        # First desactivate active partitions (coming from previous usage)
     59        cmd="${cmd}a\n$p\n"
     60        if [ "$dummy" != "" ] ; then
     61            echo "Will desactivate $p on $drive" >> $LOGFILE
     62        fi
     63    done
     64    # Then activate the one which should
    4865    if [ "$dummy" != "" ] ; then
    49         if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
    50             partno="1"
    51         fi
    52         echo "$partno"
    53     else
    54         echo -en "a\n$partno\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
    55     fi
     66        echo "Will activate $p on $drive" >> $LOGFILE
     67    else
     68        echo -en "${cmd}a\n$partno\np\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
     69    fi
    5670fi
    5771exit 0
Note: See TracChangeset for help on using the changeset viewer.