mirror of
https://git.yoctoproject.org/poky
synced 2026-04-08 17:02:22 +02:00
wic: add --extra-partition-space option to set unused space
By default, the content of the partition is filled by the filesystem
without leaving any unused free space. The --extra-space flag adds
extra space to the filesystem size, not to the partition.
Unused free space after the filesystem can be useful for some cases,
such as encrypting a partition at runtime.
With --extra-partition-space 32M, we ensure that the last 32M of the
partition is unused: this space does not contain filesystem data and
can store the LUKS2 header.
The implementation sets a difference between the partition and
filesystem size:
- With --fixed-size, the extra part space is removed from the
filesystem size.
- Otherwise (with or without --size flag), the extra part space is
added to the partition size.
(From OE-Core rev: 22fd1702aedf40257aa53963b62b5ef1bbd2818a)
Signed-off-by: Pierre-Loup GOSSE <pierre-loup.gosse@smile.fr>
CC: Alexander Kanavin <alex.kanavin@gmail.com>
CC: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
857bb50a35
commit
21d98bd960
@@ -1020,6 +1020,14 @@ DESCRIPTION
|
||||
By default, 10MB. This option cannot be used
|
||||
with --fixed-size option.
|
||||
|
||||
--extra-partition-space: This option is specific to wic. It adds extra
|
||||
empty space after the space filled by the
|
||||
filesystem. With --fixed-size, the extra
|
||||
partition space is removed from the filesystem
|
||||
size. Otherwise (with or without --size flag),
|
||||
the extra partition space is added to the final
|
||||
paritition size. The default value is 0MB.
|
||||
|
||||
--overhead-factor: This option is specific to wic. The
|
||||
size of the partition is multiplied by
|
||||
this factor. It has to be greater than or
|
||||
|
||||
@@ -154,6 +154,7 @@ class KickStart():
|
||||
part.add_argument('--include-path', nargs='+', action='append')
|
||||
part.add_argument('--change-directory')
|
||||
part.add_argument("--extra-space", type=sizetype("M"))
|
||||
part.add_argument('--extra-partition-space', type=sizetype("M"))
|
||||
part.add_argument('--fsoptions', dest='fsopts')
|
||||
part.add_argument('--fspassno', dest='fspassno')
|
||||
part.add_argument('--fstype', default='vfat',
|
||||
@@ -259,6 +260,8 @@ class KickStart():
|
||||
err = "%s:%d: Must set the label with --label" \
|
||||
% (confpath, lineno)
|
||||
raise KickStartError(err)
|
||||
if not parsed.extra_partition_space:
|
||||
parsed.extra_partition_space = 0
|
||||
# using ArgumentParser one cannot easily tell if option
|
||||
# was passed as argument, if said option has a default
|
||||
# value; --overhead-factor/--extra-space cannot be used
|
||||
|
||||
@@ -29,6 +29,7 @@ class Partition():
|
||||
self.disk = args.disk
|
||||
self.device = None
|
||||
self.extra_space = args.extra_space
|
||||
self.extra_partition_space = args.extra_partition_space
|
||||
self.exclude_path = args.exclude_path
|
||||
self.include_path = args.include_path
|
||||
self.change_directory = args.change_directory
|
||||
@@ -91,13 +92,12 @@ class Partition():
|
||||
def get_rootfs_size(self, actual_rootfs_size=0):
|
||||
"""
|
||||
Calculate the required size of rootfs taking into consideration
|
||||
--size/--fixed-size flags as well as overhead and extra space, as
|
||||
specified in kickstart file. Raises an error if the
|
||||
`actual_rootfs_size` is larger than fixed-size rootfs.
|
||||
|
||||
--size/--fixed-size and --extra-partition-space flags as well as overhead
|
||||
and extra space, as specified in kickstart file. Raises an error
|
||||
if the `actual_rootfs_size` is larger than fixed-size rootfs.
|
||||
"""
|
||||
if self.fixed_size:
|
||||
rootfs_size = self.fixed_size
|
||||
rootfs_size = self.fixed_size - self.extra_partition_space
|
||||
if actual_rootfs_size > rootfs_size:
|
||||
raise WicError("Actual rootfs size (%d kB) is larger than "
|
||||
"allowed size %d kB" %
|
||||
@@ -119,10 +119,18 @@ class Partition():
|
||||
def disk_size(self):
|
||||
"""
|
||||
Obtain on-disk size of partition taking into consideration
|
||||
--size/--fixed-size options.
|
||||
--size/--fixed-size and --extra-partition-space options.
|
||||
|
||||
"""
|
||||
return self.fixed_size if self.fixed_size else self.size
|
||||
return self.fixed_size if self.fixed_size else self.size + self.extra_partition_space
|
||||
|
||||
@property
|
||||
def fs_size(self):
|
||||
"""
|
||||
Obtain on-disk size of filesystem inside the partition taking into
|
||||
consideration --size/--fixed-size and --extra-partition-space options.
|
||||
"""
|
||||
return self.fixed_size - self.extra_partition_space if self.fixed_size else self.size
|
||||
|
||||
def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir,
|
||||
bootimg_dir, kernel_dir, native_sysroot, updated_fstab_path):
|
||||
@@ -202,10 +210,10 @@ class Partition():
|
||||
"This a bug in source plugin %s and needs to be fixed." %
|
||||
(self.mountpoint, self.source))
|
||||
|
||||
if self.fixed_size and self.size > self.fixed_size:
|
||||
if self.fixed_size and self.size + self.extra_partition_space > 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))
|
||||
"larger (%d kB + %d kB extra part space) than its allowed size %d kB" %
|
||||
(self.mountpoint, self.size, self.extra_partition_space, self.fixed_size))
|
||||
|
||||
def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir,
|
||||
native_sysroot, real_rootfs = True, pseudo_dir = None):
|
||||
@@ -440,7 +448,7 @@ class Partition():
|
||||
"""
|
||||
Prepare an empty ext2/3/4 partition.
|
||||
"""
|
||||
size = self.disk_size
|
||||
size = self.fs_size
|
||||
with open(rootfs, 'w') as sparse:
|
||||
os.ftruncate(sparse.fileno(), size * 1024)
|
||||
|
||||
@@ -464,7 +472,7 @@ class Partition():
|
||||
"""
|
||||
Prepare an empty btrfs partition.
|
||||
"""
|
||||
size = self.disk_size
|
||||
size = self.fs_size
|
||||
with open(rootfs, 'w') as sparse:
|
||||
os.ftruncate(sparse.fileno(), size * 1024)
|
||||
|
||||
@@ -482,7 +490,7 @@ class Partition():
|
||||
"""
|
||||
Prepare an empty vfat partition.
|
||||
"""
|
||||
blocks = self.disk_size
|
||||
blocks = self.fs_size
|
||||
|
||||
label_str = "-n boot"
|
||||
if self.label:
|
||||
|
||||
Reference in New Issue
Block a user