BOOTDD_EXTRA_SPACE. What is it for?

33 views
Skip to first unread message

Marco Braga

unread,
Jul 1, 2022, 8:17:57 AM7/1/22
to EFI Boot Guard
Hi,
while reading the code of the wic plugin, I stumbled upon BOOTDD_EXTRA_SPACE. I really don't understand what is it for. It seems that if the content of the partition uses space X, BOOTDD_EXTRA_SPACE will add more space and make the partition grow so that there is always at least BOOTDD_EXTRA_SPACE. Why isn't the partitltion simply fixed in size?
Thanks!

Jan Kiszka

unread,
Jul 1, 2022, 9:41:50 AM7/1/22
to Marco Braga, EFI Boot Guard
BOOTDD_EXTRA_SPACE looks like an undocumented interface of OE wic to
request, well, extra space on the boot partition. meta-efibootguard
tries to implement this, just like
https://git.openembedded.org/openembedded-core/tree/scripts/lib/wic/plugins/source/bootimg-efi.py.
You may also specify a fixed size for your partition in the wks file, of
course.

Jan

--
Siemens AG, Technology
Competence Center Embedded Linux

Marco Braga

unread,
Jul 2, 2022, 10:24:56 AM7/2/22
to EFI Boot Guard
Jia,
thanks for the answer.

It seems to do the same thing as the wic's part --extra-space option (which is not well documented too, it is not clear if it leaves space inside the filesystem that will be written to the partition, or just leave empty space in the partition outside of it).

Regarding --fixed-space, I don't think it is actually working. Reading through the source code of EFI boot guard plugins, they just consider part.size and ignore part.fixed_size. If you try to use option --fixed-size in the wic part command, you'll get an error.

VOLKER VOGELHUBER

unread,
Sep 15, 2022, 8:55:14 AM9/15/22
to EFI Boot Guard
We just stumbled over this problem as well, and I agree with Marco, that the current implementation does not make sense. In case one has a fixed-size of 20MB specified , the actual content size is below BOOTDD_EXTRA_SPACE the BOOTDD_EXTRA_SPACE will be added even if it results in a partition size that is larger than fixed-size.
I would suggest to just remove

  if extra_blocks < BOOTDD_EXTRA_SPACE:
            extra_blocks = BOOTDD_EXTRA_SPACE

Marco Braga

unread,
Sep 15, 2022, 11:15:00 AM9/15/22
to VOLKER VOGELHUBER, EFI Boot Guard
Hi VOLKER,
I still think that a partition size can't grow simply because the content has grown. Most of the time generated wic files are used to update existing devices and changing partition size can cause disasters on statically mapped storages. We've worked around this problem by reimplementing our customized wic plugins.

--
You received this message because you are subscribed to a topic in the Google Groups "EFI Boot Guard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/efibootguard-dev/KozyIjb5gnk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to efibootguard-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/2cc7b79f-a6bc-4472-8cba-93c346484241n%40googlegroups.com.

VOLKER VOGELHUBER

unread,
Sep 15, 2022, 11:29:25 AM9/15/22
to EFI Boot Guard
I agree, but for ensuring partition sizes are not changing you have the fixed_size option which is checked in partition.py already

if self.fixed_size and self.size > self.fixed_size:
            raise WicError("File system image of partition %s is "
                           "larger (%d kB) than its allowed size %d kB" %
                           (self.mountpoint, self.size, self.fixed_size))

So there are currently two issues in Kirkstone:

First: The extra_blocks < BOOTDD_EXTRA_SPACE statement
Second: The get_extra_blocks_count method not taking fixed_size into account.

The following patches should solve the issues (currently not yet tested):

diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 89a76a7..568e3eb 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -418,8 +418,8 @@ class BootimgEFIPlugin(SourcePlugin):
 
         extra_blocks = part.get_extra_block_count(blocks)
 
-        if extra_blocks < BOOTDD_EXTRA_SPACE:
-            extra_blocks = BOOTDD_EXTRA_SPACE
+        #if extra_blocks < BOOTDD_EXTRA_SPACE:
+        #    extra_blocks = BOOTDD_EXTRA_SPACE
 
         blocks += extra_blocks
 

diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 61fd810..4ae416b 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -79,10 +79,10 @@ class Partition():
         logger.debug("Requested partition size for %s: %d",
                      self.mountpoint, self.size)
 
-        if not self.size:
-            return 0
+        requested_blocks = self.disk_size
 
-        requested_blocks = self.size
+        if not requested_blocks:
+            return 0
 
         logger.debug("Requested blocks %d, current_blocks %d",
                      requested_blocks, current_blocks)
Reply all
Reply to author
Forward
0 new messages