Changeset 3746 in MondoRescue


Ignore:
Timestamp:
Nov 19, 2019, 1:25:56 PM (4 years ago)
Author:
Bruno Cornec
Message:

Reinstall mbr.bin (or pgtmbr.bin) from syslinux before calling boot loader restoration to avoid having nothing if we boot from a partition
(tested with SLES 12)

Location:
branches/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi/mindi

    r3744 r3746  
    134134if [ -d "/sys/firmware/efi" ]; then
    135135    BOOT_TYPE="UEFI"
    136 else
    137     # Find MBR in case of bootable USB device to build
    138     MBRFILE=/usr/lib/syslinux/mbr.bin
    139     [ ! -r "$MBRFILE" ] && MBRFILE=/usr/lib64/syslinux/mbr.bin
    140     [ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/syslinux/mbr.bin
    141     [ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/lib/syslinux/mbr.bin
    142     [ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/lib64/syslinux/mbr.bin
    143 fi
     136fi
     137
     138# Find MBR file in case of bootable USB device to build and for restoring it
     139MBRFILE=/usr/lib/syslinux/mbr.bin
     140[ ! -r "$MBRFILE" ] && MBRFILE=/usr/lib64/syslinux/mbr.bin
     141[ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/syslinux/mbr.bin
     142[ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/lib/syslinux/mbr.bin
     143[ ! -r "$MBRFILE" ] && MBRFILE=/usr/share/lib64/syslinux/mbr.bin
     144
     145# Find GPTMBR in case of bootable USB device to build and for restoring it
     146GPTMBRFILE=/usr/lib/syslinux/gptmbr.bin
     147[ ! -r "$GPTMBRFILE" ] && GPTMBRFILE=/usr/lib64/syslinux/gptmbr.bin
     148[ ! -r "$GPTMBRFILE" ] && GPTMBRFILE=/usr/share/syslinux/gptmbr.bin
     149[ ! -r "$GPTMBRFILE" ] && GPTMBRFILE=/usr/share/lib/syslinux/gptmbr.bin
     150[ ! -r "$GPTMBRFILE" ] && GPTMBRFILE=/usr/share/lib64/syslinux/gptmbr.bin
    144151
    145152# Function to log on screen only
     
    24392446            cp -pRdf $MINDI_TMP/$q $bigdir/tmp 2>> $LOGFILE
    24402447        done
     2448        for q in $MBRFILE $GPTMBRFILE; do
     2449            if [ -r $q ]; then
     2450                cp -a $q $bigdir/tmp 2>> $LOGFILE
     2451            else
     2452                LogFile "Unable to copy $q to bigdir. May be unable to restore MBR"
     2453            fi
     2454        done
    24412455    fi
    24422456
     
    33703384$FDISK -l >> $LOGFILE
    33713385LogFile "----------------"
     3386LogFile "MBRFILE = $MBRFILE"
     3387LogFile "GPTMBRFILE = $GPTMBRFILE"
    33723388
    33733389# Compute libata version
  • branches/3.3/mondo/src/common/libmondo-archive.c

    r3650 r3746  
    629629        }
    630630        bootldr_ver = call_program_and_get_last_line_of_output("grub --version 2> /dev/null");
    631         if (strcmp(bootldr_ver,"") ==0) {
     631        if (strcmp(bootldr_ver,"") == 0) {
    632632            mr_free(bootldr_ver);
    633633            bootldr_ver = call_program_and_get_last_line_of_output("grub2-install --version");
  • branches/3.3/mondo/src/common/libmondo-devices.c

    r3719 r3746  
    25152515            }
    25162516        }
     2517        /*  TODO: Useless I think */
    25172518        if (bkpinfo->disaster_recovery) {
    25182519            mr_asprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c

    r3743 r3746  
    99#include "mr_str.h"
    1010#include "mr_file.h"
     11#include "mr_sys.h"
    1112#include "../common/mondostructures.h"
    1213#include "../common/libmondo.h"
     
    12821283  /** malloc *******/
    12831284    char *device = NULL;
     1285    char *disk = NULL;
    12841286    char *name = NULL;
     1287    char *type = NULL;
    12851288    char *cmd = NULL;
    12861289
    12871290    malloc_string(device);
    12881291    malloc_string(name);
     1292    malloc_string(type);
    12891293
    12901294    /* In order to have a working bootloader, we need to have all devices
     
    12941298    mr_asprintf(cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING);
    12951299    run_program_and_log_output(cmd, 3);
    1296     paranoid_free(cmd);
     1300    mr_free(cmd);
    12971301
    12981302    backup_crucial_file(MNT_RESTORING, "/etc/fstab");
     
    13071311    read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);
    13081312    read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
    1309     log_msg(2, "run_boot_loader: device='%s', name='%s'", device, name);
     1313    read_cfg_var(g_mondo_cfg_file, "boot-type", type);
     1314    log_msg(2, "run_boot_loader: device='%s', name='%s', type='%s'", device, name, type);
    13101315    sync();
    13111316
    13121317    offer_to_make_initrd();
     1318
     1319    disk = truncate_to_drive_name(device);
     1320    if (strcmp(type,"BIOS") == 0) {
     1321        // Force installation of a MBR bootloader brought by mindi on the disk
     1322        // in case none was available and we then start from a partition
     1323        log_msg(2, "Reinstalling mbr.bin on %s", disk);
     1324        mr_system("dd bs=440 count=1 conv=notrunc if=/tmp/mbr.bin of=%s &> /dev/null",disk);
     1325    } else {
     1326        // Same for GPT
     1327        log_msg(2, "Reinstalling gptmbr.bin on %s", disk);
     1328        mr_system("dd bs=440 count=1 conv=notrunc if=/tmp/gptmbr.bin of=%s &> /dev/null",disk);
     1329    }
     1330
     1331    // Now reinstall bootloader
    13131332    if (!strcmp(name, "LILO")) {
    13141333        res = run_lilo(offer_to_hack_scripts);
Note: See TracChangeset for help on using the changeset viewer.