diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2016-10-06 13:33:37 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-10-07 16:43:58 +0100 |
commit | 12ea11e4f8d300e7a64703f07fe60df70c676517 (patch) | |
tree | 54ddd830f6cb847fb4add613f0650f6ac6d40f02 /scripts/lib/wic | |
parent | 5763d8f9cddc593cbcfba78a06071cfd01b3b244 (diff) | |
download | poky-12ea11e4f8d300e7a64703f07fe60df70c676517.tar.gz |
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>
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r-- | scripts/lib/wic/imager/direct.py | 2 | ||||
-rw-r--r-- | 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 123a07817b..edf5e5d221 100644 --- a/scripts/lib/wic/imager/direct.py +++ b/scripts/lib/wic/imager/direct.py | |||
@@ -315,7 +315,7 @@ class DirectImageCreator(BaseImageCreator): | |||
315 | % (disk_name, full_path, disk['min_size'])) | 315 | % (disk_name, full_path, disk['min_size'])) |
316 | disk_obj = DiskImage(full_path, disk['min_size']) | 316 | disk_obj = DiskImage(full_path, disk['min_size']) |
317 | self.__disks[disk_name] = disk_obj | 317 | self.__disks[disk_name] = disk_obj |
318 | self.__image.add_disk(disk_name, disk_obj) | 318 | self.__image.add_disk(disk_name, disk_obj, disk_ids.get(disk_name)) |
319 | 319 | ||
320 | self.__image.create() | 320 | self.__image.create() |
321 | 321 | ||
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py index 8d93a68e3a..cb03009fc7 100644 --- a/scripts/lib/wic/utils/partitionedfs.py +++ b/scripts/lib/wic/utils/partitionedfs.py | |||
@@ -68,15 +68,17 @@ class Image(): | |||
68 | 'offset': 0, # Offset of next partition (in sectors) | 68 | 'offset': 0, # Offset of next partition (in sectors) |
69 | # Minimum required disk size to fit all partitions (in bytes) | 69 | # Minimum required disk size to fit all partitions (in bytes) |
70 | 'min_size': 0, | 70 | 'min_size': 0, |
71 | 'ptable_format': "msdos"} # Partition table format | 71 | 'ptable_format': "msdos", # Partition table format |
72 | 'identifier': None} # Disk system identifier | ||
72 | 73 | ||
73 | def add_disk(self, disk_name, disk_obj): | 74 | def add_disk(self, disk_name, disk_obj, identifier): |
74 | """ Add a disk object which have to be partitioned. More than one disk | 75 | """ Add a disk object which have to be partitioned. More than one disk |
75 | can be added. In case of multiple disks, disk partitions have to be | 76 | can be added. In case of multiple disks, disk partitions have to be |
76 | added for each disk separately with 'add_partition()". """ | 77 | added for each disk separately with 'add_partition()". """ |
77 | 78 | ||
78 | self.__add_disk(disk_name) | 79 | self.__add_disk(disk_name) |
79 | self.disks[disk_name]['disk'] = disk_obj | 80 | self.disks[disk_name]['disk'] = disk_obj |
81 | self.disks[disk_name]['identifier'] = identifier | ||
80 | 82 | ||
81 | def __add_partition(self, part): | 83 | def __add_partition(self, part): |
82 | """ This is a helper function for 'add_partition()' which adds a | 84 | """ This is a helper function for 'add_partition()' which adds a |
@@ -245,6 +247,12 @@ class Image(): | |||
245 | (disk['disk'].device, disk['ptable_format']), | 247 | (disk['disk'].device, disk['ptable_format']), |
246 | self.native_sysroot) | 248 | self.native_sysroot) |
247 | 249 | ||
250 | if disk['identifier']: | ||
251 | msger.debug("Set disk identifier %x" % disk['identifier']) | ||
252 | with open(disk['disk'].device, 'r+b') as img: | ||
253 | img.seek(0x1B8) | ||
254 | img.write(disk['identifier'].to_bytes(4, 'little')) | ||
255 | |||
248 | msger.debug("Creating partitions") | 256 | msger.debug("Creating partitions") |
249 | 257 | ||
250 | for part in self.partitions: | 258 | for part in self.partitions: |