[gnome-continuous-yocto/gnomeostree-3.28-rocko: 2916/8267] wic: rewrite MBR disk identifier
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 2916/8267] wic: rewrite MBR disk identifier
- Date: Sat, 16 Dec 2017 23:54:04 +0000 (UTC)
commit 12ea11e4f8d300e7a64703f07fe60df70c676517
Author: Ed Bartosh <ed bartosh linux intel com>
Date: Thu Oct 6 13:33:37 2016 +0300
wic: rewrite MBR disk identifier
Disk identifier created by parted doesn't match the one we generated
and used in bootloader config. We need to rewrite it to make our image
bootable.
Modified involved API and data structures to access previously
generated disk identifiers after MBR is initialized. Written disk
identifiers to MBR.
(From OE-Core rev: 221d3bdd6e0ab8a4d25e2c96bd976cbec4e76681)
Signed-off-by: Ed Bartosh <ed bartosh linux intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
scripts/lib/wic/imager/direct.py | 2 +-
scripts/lib/wic/utils/partitionedfs.py | 12 ++++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index 123a078..edf5e5d 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -315,7 +315,7 @@ class DirectImageCreator(BaseImageCreator):
% (disk_name, full_path, disk['min_size']))
disk_obj = DiskImage(full_path, disk['min_size'])
self.__disks[disk_name] = disk_obj
- self.__image.add_disk(disk_name, disk_obj)
+ self.__image.add_disk(disk_name, disk_obj, disk_ids.get(disk_name))
self.__image.create()
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index 8d93a68..cb03009 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -68,15 +68,17 @@ class Image():
'offset': 0, # Offset of next partition (in sectors)
# Minimum required disk size to fit all partitions (in bytes)
'min_size': 0,
- 'ptable_format': "msdos"} # Partition table format
+ 'ptable_format': "msdos", # Partition table format
+ 'identifier': None} # Disk system identifier
- def add_disk(self, disk_name, disk_obj):
+ def add_disk(self, disk_name, disk_obj, identifier):
""" Add a disk object which have to be partitioned. More than one disk
can be added. In case of multiple disks, disk partitions have to be
added for each disk separately with 'add_partition()". """
self.__add_disk(disk_name)
self.disks[disk_name]['disk'] = disk_obj
+ self.disks[disk_name]['identifier'] = identifier
def __add_partition(self, part):
""" This is a helper function for 'add_partition()' which adds a
@@ -245,6 +247,12 @@ class Image():
(disk['disk'].device, disk['ptable_format']),
self.native_sysroot)
+ if disk['identifier']:
+ msger.debug("Set disk identifier %x" % disk['identifier'])
+ with open(disk['disk'].device, 'r+b') as img:
+ img.seek(0x1B8)
+ img.write(disk['identifier'].to_bytes(4, 'little'))
+
msger.debug("Creating partitions")
for part in self.partitions:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]