[PATCH 2/2] Fix installation of grub stage 1 for md raid 1 boot devices.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Follow-up of commit 21492651413eb245bbab3fada09ba461b6398f05.
For installation into partition, stage1 is installed to both memebers'
partitions (used to be installed to mbrs of disks containing members).
For installation into mbr, stage1 is installed into mbr of first bios disk
and into mbrs of disks containing members.
---
 booty/bootloaderInfo.py |    2 +-
 booty/x86.py            |   65 ++++++++++++++++++++++++-----------------------
 2 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index bdfb1d9..8053ea1 100644
--- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -596,7 +596,7 @@ class efiBootloaderInfo(bootloaderInfo):
                                     stderr = "/dev/tty5")
         return rc
 
-    def installGrub(self, instRoot, bootDevs, grubTarget, grubPath,
+    def installGrub(self, instRoot, bootDev, grubTarget, grubPath,
                     target, cfPath):
         if not iutil.isEfi():
             raise EnvironmentError
diff --git a/booty/x86.py b/booty/x86.py
index 43d3f0e..d5ee192 100644
--- a/booty/x86.py
+++ b/booty/x86.py
@@ -99,34 +99,44 @@ class x86BootloaderInfo(efiBootloaderInfo):
             if rc:
                 return rc
 
-    def installGrub(self, instRoot, bootDevs, grubTarget, grubPath,
+    def installGrub(self, instRoot, bootDev, grubTarget, grubPath,
                     target, cfPath):
         if iutil.isEfi():
-            return efiBootloaderInfo.installGrub(self, instRoot, bootDevs, grubTarget,
-                                                 grubPath, target, cfPath)
+            return efiBootloaderInfo.installGrub(self, instRoot, bootDev, grubTarget,
+                                          grubPath, target, cfPath)
 
         args = "--stage2=/boot/grub/stage2 "
 
-        for bootDev in bootDevs:
-            cmds = []
-            gtPart = self.getMatchingPart(bootDev, grubTarget)
-            gtDisk = self.grubbyPartitionName(getDiskPart(gtPart, self.storage)[0])
-            bPart = self.grubbyPartitionName(bootDev)
-            cmd = "root %s\n" % (bPart,)
+        stage1Devs = self.getPhysicalDevices(grubTarget)
+        bootDevs = self.getPhysicalDevices(bootDev.name)
+        if bootDev.type == "mdarray" and target == "mbr":
+            # install to mbr of drives holding md boot partitions too
+            for mdBootPart in bootDevs:
+                mdBootPartDisk = getDiskPart(mdBootPart, self.storage)[0]
+                if not mdBootPartDisk in stage1Devs:
+                    stage1Devs.append(mdBootPartDisk)
+            # choose grub root partitions corresponding to stage1 targets:
+            mdMbrBootDevs = []
+            for stage1Dev in stage1Devs:
+                dev = bootDevs[0]
+                for mdBootPart in bootDevs:
+                    if stage1Dev == getDiskPart(mdBootPart, self.storage)[0]:
+                        dev = mdBootPart
+                        break
+                mdMbrBootDevs.append(dev)
+            bootDevs = mdMbrBootDevs
 
-            stage1Target = gtDisk
-            if target == "partition":
-                stage1Target = self.grubbyPartitionName(gtPart)
+        cmds = []
+        for stage1Dev, bDev in zip(stage1Devs, bootDevs):
+            stage1Target = self.grubbyPartitionName(stage1Dev)
+            rootPart = self.grubbyPartitionName(bDev)
 
+            cmd = "root %s\n" % (rootPart,)
             cmd += "install %s%s/stage1 d %s %s/stage2 p %s%s/grub.conf" % \
-                (args, grubPath, stage1Target, grubPath, bPart, grubPath)
+                (args, grubPath, stage1Target, grubPath, rootPart, grubPath)
             cmds.append(cmd)
 
-            rc = self.runGrubInstall(instRoot, bootDev, cmds, cfPath)
-            if rc:
-                return rc
-
-        return 0
+        return self.runGrubInstall(instRoot, bootDev.name, cmds, cfPath)
 
     def writeGrub(self, instRoot, bl, kernelList, chainList,
             defaultDev, justConfigFile):
@@ -165,7 +175,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
             f.write("#          all kernel and initrd paths are relative "
                     "to /boot/, eg.\n")
         except KeyError:
-            bootDev = self.storage.fsset.rootDevice
+            bootDev = rootDev
             grubPath = "/boot/grub"
             cfPath = "/boot/"
             f.write("# NOTICE:  You do not have a /boot partition.  "
@@ -347,20 +357,11 @@ class x86BootloaderInfo(efiBootloaderInfo):
         f.close()
             
         if not justConfigFile:
-            return self.installGrub(instRoot, bootDevs, grubTarget, grubPath,
-                                    target, cfPath)
+            return self.installGrub(instRoot, bootDev, grubTarget, grubPath,
+                             target, cfPath)
 
         return 0
 
-    def getMatchingPart(self, bootDev, target):
-        bootName, bootPartNum = getDiskPart(bootDev, self.storage)
-        devices = self.getPhysicalDevices(target)
-        for device in devices:
-            name, partNum = getDiskPart(device, self.storage)
-            if name == bootName:
-                return device
-        return devices[0]
-
     def grubbyDiskName(self, name):
         return "hd%d" % self.drivelist.index(name)
 
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux