[PATCH] add capability to anaconda to not update MBR when grub2 installed

Gene Czarcinski gczarcinski at ec.rr.com
Mon Sep 15 20:13:48 UTC 2014

This patch is in response to RHBZ#886502.  It adds the
boot parameter "nombr" to suppress updating the MBR while
still completely installing grub2 and creating the grub.cfg
file.  The actual suppression adds "--grub-setup=/bin/true" to
the execution of "/sbin/grub-install"

Kickstart, regular, and live installs are supported.

Note: a separate patch to the pykickstart package add the --nombr
option to kickstart's bootloader command.
 anaconda                  | 3 +++
 data/anaconda_options.txt | 8 ++++++++
 pyanaconda/bootloader.py  | 6 ++++++
 pyanaconda/flags.py       | 2 ++
 4 files changed, 19 insertions(+)

diff --git a/anaconda b/anaconda
index 4d4676e..d0ba975 100755
--- a/anaconda
+++ b/anaconda
@@ -509,6 +509,8 @@ def parseArguments(argv=None, boot_cmdline=None):
     ap.add_argument("--extlinux", action="store_true", default=False,
+    ap.add_argument("--nombr", action="store_true", default=False,
+                    help=help_parser.help_text("nombr"))
     ap.add_argument("--dnf", action="store_true", default=False,
     ap.add_argument("--mpathfriendlynames", action="store_true", default=True,
@@ -1043,6 +1045,7 @@ if __name__ == "__main__":
     flags.noverifyssl = opts.noverifyssl
     flags.armPlatform = opts.armPlatform
     flags.extlinux = opts.extlinux
+    flags.nombr = opts.nombr
     flags.dnf = opts.dnf
     flags.mpathFriendlyNames = opts.mpathfriendlynames
     flags.debug = opts.debug
diff --git a/data/anaconda_options.txt b/data/anaconda_options.txt
index a1e3143..12a10d9 100644
--- a/data/anaconda_options.txt
+++ b/data/anaconda_options.txt
@@ -215,6 +215,14 @@ Use extlinux as the bootloader. Note that there's no attempt to validate
 that this will work for your platform or anything; it assumes that if you
 ask for it, you want to try.
+If nombr is specified the grub2 bootloader will be installed but the
+MBR will not be updated.  Therefore, when the system reboot, a previously
+installed OS will be booted.  /etc/grub.d/40_custom can be used with
+manually created menuentrys which can use configfile to point to the
+grub.cfg on the newly installed OS.
 Use the experimental DNF package management backend instead of the YUM backend
 that is used by default. For more information about the DNF project see:
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 509796e..5b233fc 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -1588,6 +1588,12 @@ class GRUB2(GRUB):
                 # This is hopefully a temporary hack. GRUB2 currently refuses
                 # to install to a partition's boot block without --force.
                 grub_args.insert(0, '--force')
+            else:
+                if flags.nombr:
+                    grub_args.insert(0,'--grub-setup=/bin/true')
+                    log.info("bootloader.py mbr update by grub2 disabled")
+                else:
+                    log.info("bootloader.py mbr will be updated for grub2")
             rc = iutil.execWithRedirect("grub2-install", grub_args,
diff --git a/pyanaconda/flags.py b/pyanaconda/flags.py
index 5403f75..49393aa 100644
--- a/pyanaconda/flags.py
+++ b/pyanaconda/flags.py
@@ -61,6 +61,7 @@ class Flags(object):
         self.askmethod = False
         self.eject = True
         self.extlinux = False
+        self.nombr = False
         self.gpt = False
         self.leavebootorder = False
         self.testing = False
@@ -78,6 +79,7 @@ class Flags(object):
     def read_cmdline(self):
         for f in ("selinux", "debug", "leavebootorder", "testing", "extlinux",
+                  "nombr",
                   "gpt", "dnf"):

More information about the anaconda-patches mailing list