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

Torben Hohn torben.hohn at linutronix.de
Wed Jul 15 10:27:05 CEST 2020


On Tue, Jul 14, 2020 at 05:13:14PM +0200, Kurt Kanzenbach wrote:
> 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

please use hd.text("first_partition_offset", default="2048")

Also i am not happy with the name. first_partition_offset implies
size_to_int, thats ok.

But this is sectors.

Either you devide by the sector size. (And of course adjust the default)
Or we rename it to first_partition_sector.


> +
>      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
> 

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner


More information about the elbe-devel mailing list