[elbe-devel] [PATCH] hdimg: Add support for specifying the first partition offset

Kurt Kanzenbach kurt at linutronix.de
Tue Jul 14 17:13:14 CEST 2020


The starting sector for the first partition in an msdos or gpt image is hard
coded to 2048. Depending on the image layout (bootloader, redundant bootloaders,
...) it makes sense to move that offset around. Introduce a new property to
allow that.

Suggested-by: Holger Dengler <dengler at linutronix.de>
Signed-off-by: Kurt Kanzenbach <kurt at linutronix.de>
---
 elbepack/hdimg.py |  6 +++++-
 schema/dbsfed.xsd | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index 63410ee05d89..0ca1ea5a234b 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -432,7 +432,11 @@ def do_image_hd(hd, fslabel, target, grub_version, grub_fw_type=None):
     else:
         grub = grubinstaller_base()
 
-    current_sector = 2048
+    if hd.has("first_partition_offset"):
+        current_sector = size_to_int(hd.text("first_partition_offset"))
+    else:
+        current_sector = 2048
+
     for part in hd:
 
         if part.tag == "partition":
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index c7bae9be549c..eb102dc8b36d 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -1168,6 +1168,13 @@
           </documentation>
         </annotation>
       </element>
+      <element name="first_partition_offset" type="rfs:part_size" minOccurs="0" maxOccurs="1">
+        <annotation>
+          <documentation>
+            Starting offset for the first partition in sectors
+          </documentation>
+        </annotation>
+      </element>
       <element name="grub-install" type="rfs:string" minOccurs="0" maxOccurs="1">
         <annotation>
           <documentation>
@@ -1235,6 +1242,13 @@
           </documentation>
         </annotation>
       </element>
+      <element name="first_partition_offset" type="rfs:part_size" minOccurs="0" maxOccurs="1">
+        <annotation>
+          <documentation>
+            Starting offset for the first partition in sectors
+          </documentation>
+        </annotation>
+      </element>
       <element name="grub-install" type="rfs:string" minOccurs="0" maxOccurs="1">
         <annotation>
           <documentation>
-- 
2.20.1



More information about the elbe-devel mailing list