[elbe-devel] [PATCH v2 4/4] Add support for hybrid images (UEFI+Bios)

Martin Kaistra martin.kaistra at linutronix.de
Wed Mar 28 14:16:56 CEST 2018


This patch adds the possibility to create images which
can boot from UEFI as well as Bios.

How to use:
You need to add the packages grub-efi-amd64-bin and grub-pc
and a small (1MiB should be enough) partition with <biosgrub> in
addition to a standard UEFI image.

Signed-off-by: Martin Kaistra <martin.kaistra at linutronix.de>
---
 elbepack/elbeproject.py | 6 +++++-
 elbepack/hdimg.py       | 9 ++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index 047020bc..1cb22ef5 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -466,7 +466,11 @@ class ElbeProject (object):
         # jessie and wheezy grubs are 2.0 but differ in behaviour
         #
         # We might also want support for legacy grub
-        if self.get_rpcaptcache().is_installed('grub-pc'):
+        if (self.get_rpcaptcache().is_installed('grub-pc') and
+                self.get_rpcaptcache().is_installed('grub-efi-amd64-bin')):
+            grub_version = 202
+            grub_fw_type = "hybrid"
+        elif self.get_rpcaptcache().is_installed('grub-pc'):
             if self.codename == "wheezy":
                 grub_version = 199
             else:
diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index 2fc042d9..e0aab938 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -186,7 +186,7 @@ def size_to_int(size):
 
 
 class grubinstaller_base(object):
-    def __init__(self, outf, fw_type="bios"):
+    def __init__(self, outf, fw_type=None):
         self.outf = outf
         self.root = None
         self.boot = None
@@ -260,12 +260,13 @@ class grubinstaller202(grubinstaller_base):
             self.outf.do("chroot %s  update-initramfs -u -k all" % imagemnt)
             self.outf.do("chroot %s  update-grub2" % imagemnt)
 
-            if self.fw_type == "efi":
+            if self.fw_type == "efi" or self.fw_type == "hybrid":
                 self.outf.do(
                     "chroot %s grub-install --target=x86_64-efi --removable "
                     "--no-floppy /dev/poop0" %
                     (imagemnt))
-            else:
+            if self.fw_type == "hybrid" or self.fw_type is None:
+                # when we are in hybrid mode, install grub also into MBR
                 self.outf.do(
                     "chroot %s grub-install --no-floppy /dev/poop0" %
                     (imagemnt))
@@ -526,6 +527,8 @@ def do_image_hd(outf, hd, fslabel, target, grub_version, grub_fw_type):
         grub = grubinstaller199(outf)
     elif grub_version == 202 and grub_fw_type == "efi":
         grub = grubinstaller202(outf, "efi")
+    elif grub_version == 202 and grub_fw_type == "hybrid":
+        grub = grubinstaller202(outf, "hybrid")
     elif grub_version == 202:
         grub = grubinstaller202(outf)
     else:
-- 
2.11.0




More information about the elbe-devel mailing list