summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorMaciej Borzecki <maciej.borzecki@open-rnd.pl>2015-01-09 14:24:02 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-08 08:00:24 +0000
commit6b19a93f3814185c46c42bcceb3a9d80e7506f16 (patch)
tree7c592f0a5a48fb954517186aacc6d6d91aa43720 /scripts/lib
parenteca277b0af9e0e29022f81f54c17bf24aec02232 (diff)
downloadpoky-6b19a93f3814185c46c42bcceb3a9d80e7506f16.tar.gz
wic: fix extended/logical partition layout
The patch fixes an issue in laying out extended and logical partitions by wic. The original code produced disk images in which the size 3rd partition as described in MBR was incorrect. Depending on the type of file system used for that partition and size of the partition, it would be impossible to mount the partition correctly. For instance, kickstart file in which the 3rd partition had size of 1GB and used ext4 fs, would result in an image with an umountable partition. The root cause is reservation of sectors for EBR through stealing of last sector from the last primary partition. (From OE-Core rev: a8b85f7878726503dbfa2e9ea86bd6fd961bf03b) Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl> Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/wic/utils/partitionedfs.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index fb95cc790e..9df93dca2f 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -156,6 +156,13 @@ class Image:
156 # Skip one sector required for the partitioning scheme overhead 156 # Skip one sector required for the partitioning scheme overhead
157 d['offset'] += overhead 157 d['offset'] += overhead
158 158
159 elif d['numpart'] > 3:
160 # Reserve a sector for EBR for every logical partition
161 # before alignment is performed.
162 if ptable_format == "msdos":
163 d['offset'] += 1
164
165
159 if p['align']: 166 if p['align']:
160 # If not first partition and we do have alignment set we need 167 # If not first partition and we do have alignment set we need
161 # to align the partition. 168 # to align the partition.
@@ -185,14 +192,6 @@ class Image:
185 p['num'] = d['numpart'] 192 p['num'] = d['numpart']
186 193
187 if d['ptable_format'] == "msdos": 194 if d['ptable_format'] == "msdos":
188 if d['numpart'] > 2:
189 # Every logical partition requires an additional sector for
190 # the EBR, so steal the last sector from the end of each
191 # partition starting from the 3rd one for the EBR. This
192 # will make sure the logical partitions are aligned
193 # correctly.
194 p['size'] -= 1
195
196 if d['numpart'] > 3: 195 if d['numpart'] > 3:
197 p['type'] = 'logical' 196 p['type'] = 'logical'
198 p['num'] = d['numpart'] + 1 197 p['num'] = d['numpart'] + 1
@@ -259,13 +258,20 @@ class Image:
259 for p in self.partitions: 258 for p in self.partitions:
260 d = self.disks[p['disk_name']] 259 d = self.disks[p['disk_name']]
261 if d['ptable_format'] == "msdos" and p['num'] == 5: 260 if d['ptable_format'] == "msdos" and p['num'] == 5:
262 # The last sector of the 3rd partition was reserved for the EBR 261 # Create an extended partition (note: extended
263 # of the first _logical_ partition. This is why the extended 262 # partition is described in MBR and contains all
264 # partition should start one sector before the first logical 263 # logical partitions). The logical partitions save a
265 # partition. 264 # sector for an EBR just before the start of a
265 # partition. The extended partition must start one
266 # sector before the start of the first logical
267 # partition. This way the first EBR is inside of the
268 # extended partition. Since the extended partitions
269 # starts a sector before the first logical partition,
270 # add a sector at the back, so that there is enough
271 # room for all logical partitions.
266 self.__create_partition(d['disk'].device, "extended", 272 self.__create_partition(d['disk'].device, "extended",
267 None, p['start'] - 1, 273 None, p['start'] - 1,
268 d['offset'] - p['start']) 274 d['offset'] - p['start'] + 1)
269 275
270 if p['fstype'] == "swap": 276 if p['fstype'] == "swap":
271 parted_fs_type = "linux-swap" 277 parted_fs_type = "linux-swap"
@@ -338,14 +344,6 @@ class Image:
338 344
339 for p in self.partitions: 345 for p in self.partitions:
340 d = self.disks[p['disk_name']] 346 d = self.disks[p['disk_name']]
341 if d['ptable_format'] == "msdos" and p['num'] == 5:
342 # The last sector of the 3rd partition was reserved for the EBR
343 # of the first _logical_ partition. This is why the extended
344 # partition should start one sector before the first logical
345 # partition.
346 self.__write_partition(p['num'], p['source_file'],
347 p['start'] - 1,
348 d['offset'] - p['start'])
349 347
350 self.__write_partition(p['num'], p['source_file'], 348 self.__write_partition(p['num'], p['source_file'],
351 p['start'], p['size']) 349 p['start'], p['size'])