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

[PATCH 1/2] Set the default grub2 entry to the OS we just installed.



---
 pyanaconda/bootloader.py |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index 73ef393..0dfe25f 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -1506,6 +1506,7 @@ class GRUB2(GRUB):
         defaults = open(defaults_file, "w+")
         defaults.write("GRUB_TIMEOUT=%d\n" % self.timeout)
         defaults.write("GRUB_DISTRIBUTOR=\"%s\"\n" % productName)
+        defaults.write("GRUB_DEFAULT=saved\n")
         if self.console and self.console.startswith("ttyS"):
             defaults.write("GRUB_TERMINAL=\"serial console\"\n")
             defaults.write("GRUB_SERIAL_COMMAND=\"%s\"\n" % self.serial_command)
@@ -1564,6 +1565,16 @@ class GRUB2(GRUB):
         except (BootLoaderError, OSError, RuntimeError) as e:
             log.error("bootloader password setup failed: %s" % e)
 
+        # make sure the default entry is the OS we are installing
+        entry_title = "%s Linux, with Linux %s" % (productName,
+                                                   self.default.version)
+        rc = iutil.execWithRedirect("grub2-set-default",
+                                    [entry_title],
+                                    root=install_root,
+                                    stdout="/dev/tty5", stderr="/dev/tty5")
+        if rc:
+            log.error("failed to set default menu entry to %s" % productName)
+
         # now tell grub2 to generate the main configuration file
         rc = iutil.execWithRedirect("grub2-mkconfig",
                                     ["-o", self.config_file],
-- 
1.7.3.4


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