@@ -196,6 +196,7 @@ class KickStart():
bootloader.add_argument('--configfile')
bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'),
default='msdos')
+ bootloader.add_argument('--diskid', type=lambda x: int(x, 0))
bootloader.add_argument('--timeout', type=int)
bootloader.add_argument('--source')
@@ -76,7 +76,7 @@ class DirectPlugin(ImagerPlugin):
break
image_path = self._full_path(self.workdir, self.parts[0].disk, "direct")
- self._image = PartitionedImage(image_path, self.ptable_format,
+ self._image = PartitionedImage(image_path, self.ptable_format, self.ks.bootloader.diskid,
self.parts, self.native_sysroot,
options.extra_space)
@@ -302,7 +302,7 @@ class PartitionedImage():
Partitioned image in a file.
"""
- def __init__(self, path, ptable_format, partitions, native_sysroot=None, extra_space=0):
+ def __init__(self, path, ptable_format, disk_id, 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
@@ -315,7 +315,9 @@ class PartitionedImage():
# all partitions (in bytes)
self.ptable_format = ptable_format # Partition table format
# Disk system identifier
- if os.getenv('SOURCE_DATE_EPOCH'):
+ if disk_id:
+ self.identifier = disk_id
+ elif os.getenv('SOURCE_DATE_EPOCH'):
self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff)
else:
self.identifier = random.SystemRandom().randint(1, 0xffffffff)
This adds a feature to specify the disk ID when creating a disk with the wic tool. This is useful when using the DOS partition scheme and booting with root=PARTUUID=<partuuid>. In DOS partitions, the partition ID is <diskid>-<partition-number>, so it makes sense to let the user define the disk ID. You can specify it in the kickstart file using the --diskid argument to the bootloader command. The value can be given in decimal or hexadecimal format (e.g. 3735928559 or 0xdeadbeef). If omitted, the previous behaviour does not change. Signed-off-by: Steffen Greber <sgreber@lilafast.org> --- scripts/lib/wic/ksparser.py | 1 + scripts/lib/wic/plugins/imager/direct.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-)