Ignore:
Timestamp:
Dec 23, 2011, 1:09:06 AM (12 years ago)
Author:
Bruno Cornec
Message:
  • Fix #500 and #473 by adding support of old metadata format for mdadm if using grub < 0.9x or lilo on a md boot device (to be tested)
File:
1 edited

Legend:

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

    r2770 r2928  
    1010#include "mondoprep.h"
    1111#include "../common/libmondo.h"
     12#include "../common/libmondo-tools-EXT.h"
    1213#include "mondo-rstr-tools-EXT.h"
    1314#include <sys/ioctl.h>
     
    4445
    4546FILE *g_fprep = NULL;
    46 
    47 
     47extern char *g_mondo_cfg_file;  // where m*ndo-restore.cfg (the config file) is stored
    4848
    4949int g_partition_table_locked_up = 0;
    50 
    51 
    52 
    53 
    54 
    55 
    56 
    5750
    5851
     
    569562  char *level   = NULL;
    570563  char *program = NULL;
     564  char *tmp = NULL;
     565  char *oldmd = NULL;
     566  char *bootdevice;
     567  char *name;
     568
     569  malloc_string(bootdevice);
     570  malloc_string(name);
    571571 
    572572  // leave straight away if raidlist is initial or has no entries
     
    615615  // - faulty devices ignored
    616616  // - persistent superblock always used as this is recommended
    617   mr_asprintf(&program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries);
     617  // As per bug #473, the parameter "-e 0.90" is used only when:
     618  //   1) It detects that system boots from Raid-1
     619  //   2) grub bootloader < v1 is used.
     620  // Otherwise it won't boot which is bad.
     621    read_cfg_var(g_mondo_cfg_file, "bootloader.device", bootdevice);
     622    read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
     623    if (strcmp(name,"GRUB") == 0) {
     624        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output("grub --version"));
     625        if ((strstr(tmp, "GRUB 0.9") != NULL) && (strcmp(raidlist->el[i].raid_device,device) == 0)) {
     626            mr_free(oldmd);
     627            mr_asprintf(&oldmd, "-e 0.90");
     628            log_it("Forcing old metadata 0.90 for md on %s for old GRUB", device);
     629        }
     630    } else if ((strcmp(name,"LILO") == 0) && (strcmp(raidlist->el[i].raid_device,device) == 0)) {
     631        mr_free(oldmd);
     632        mr_asprintf(&oldmd, "-e 0.90");
     633        log_it("Forcing old metadata 0.90 for md on %s for LILO", device);
     634    } else {
     635        mr_asprintf(&oldmd, "");
     636    }
     637    mr_free(device);
     638    mr_free(name);
     639
     640  mr_asprintf(&program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d %s", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries, oldmd);
     641  mr_free(oldmd);
    618642  if (raidlist->el[i].parity != -1) {
    619643    mr_asprintf(&strtmp, "%s", program);
Note: See TracChangeset for help on using the changeset viewer.