openembedded-core.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wic: Add extra-space argument
@ 2021-09-02 13:19 Kristian Klausen
  2021-09-02 14:03 ` [OE-core] " Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Kristian Klausen @ 2021-09-02 13:19 UTC (permalink / raw)
  To: openembedded-core; +Cc: Kristian Klausen

This allows extra space to be added after the last partition and is
especially useful when free space is needed for ex: adding partitions on
first boot with ex: systemd-repart[1] and the image is tested in QEMU.

[1] https://www.freedesktop.org/software/systemd/man/systemd-repart.html

Signed-off-by: Kristian Klausen <kristian@klausen.dk>
---
 scripts/lib/wic/plugins/imager/direct.py | 7 +++++--
 scripts/wic                              | 2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 96168aadb4..9d10ec01d0 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -77,7 +77,8 @@ class DirectPlugin(ImagerPlugin):
 
         image_path = self._full_path(self.workdir, self.parts[0].disk, "direct")
         self._image = PartitionedImage(image_path, self.ptable_format,
-                                       self.parts, self.native_sysroot)
+                                       self.parts, self.native_sysroot,
+                                       options.extra_space)
 
     def setup_workdir(self, workdir):
         if workdir:
@@ -293,7 +294,7 @@ class PartitionedImage():
     Partitioned image in a file.
     """
 
-    def __init__(self, path, ptable_format, partitions, native_sysroot=None):
+    def __init__(self, path, ptable_format, partitions, native_sysroot=None, extra_space=0):
         self.path = path  # Path to the image file
         self.numpart = 0  # Number of allocated partitions
         self.realpart = 0 # Number of partitions in the partition table
@@ -314,6 +315,7 @@ class PartitionedImage():
         self.sector_size = SECTOR_SIZE
         self.native_sysroot = native_sysroot
         num_real_partitions = len([p for p in self.partitions if not p.no_table])
+        self.extra_space = extra_space
 
         # calculate the real partition number, accounting for partitions not
         # in the partition table and logical partitions
@@ -483,6 +485,7 @@ class PartitionedImage():
             self.min_size += GPT_OVERHEAD
 
         self.min_size *= self.sector_size
+        self.min_size += self.extra_space
 
     def _create_partition(self, device, parttype, fstype, start, size):
         """ Create a partition on an image described by the 'device' object. """
diff --git a/scripts/wic b/scripts/wic
index a741aed364..57197c2048 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -346,6 +346,8 @@ def wic_init_parser_create(subparser):
                       default=False, help="output debug information")
     subparser.add_argument("-i", "--imager", dest="imager",
                       default="direct", help="the wic imager plugin")
+    subparser.add_argument("--extra-space", type=int, dest="extra_space",
+                      default=0, help="additional free disk space to add to the image")
     return
 
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [OE-core] [PATCH] wic: Add extra-space argument
  2021-09-02 13:19 [PATCH] wic: Add extra-space argument Kristian Klausen
@ 2021-09-02 14:03 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2021-09-02 14:03 UTC (permalink / raw)
  To: kristian; +Cc: openembedded-core

On Thu, Sep 02, 2021 at 03:19:21PM +0200, Kristian Klausen via lists.openembedded.org wrote:

> This allows extra space to be added after the last partition and is
> especially useful when free space is needed for ex: adding partitions on
> first boot with ex: systemd-repart[1] and the image is tested in QEMU.
> 
> [1] https://www.freedesktop.org/software/systemd/man/systemd-repart.html

Well that's certainly interesting.

> 
> Signed-off-by: Kristian Klausen <kristian@klausen.dk>
> ---
>  scripts/lib/wic/plugins/imager/direct.py | 7 +++++--
>  scripts/wic                              | 2 ++
>  2 files changed, 7 insertions(+), 2 deletions(-)

Can you add a test case for this?  That'd help also demonstrate how this
would be used over just having a minimal wks file and repart.d conf
files to describe the rest of the system.  Thanks!

-- 
Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-02 14:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 13:19 [PATCH] wic: Add extra-space argument Kristian Klausen
2021-09-02 14:03 ` [OE-core] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).