summaryrefslogtreecommitdiff
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-07 13:30:56 +0000
commita8b85f7878726503dbfa2e9ea86bd6fd961bf03b (patch)
treeffe86095e73b1860f1499544d8ec9d2cce84af28 /scripts/lib
parentab126dcca85d6a335212b07a1ca37d5e045a59cf (diff)
downloadopenembedded-core-a8b85f7878726503dbfa2e9ea86bd6fd961bf03b.tar.gz
openembedded-core-a8b85f7878726503dbfa2e9ea86bd6fd961bf03b.tar.bz2
openembedded-core-a8b85f7878726503dbfa2e9ea86bd6fd961bf03b.zip
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. 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>
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:
# Skip one sector required for the partitioning scheme overhead
d['offset'] += overhead
+ elif d['numpart'] > 3:
+ # Reserve a sector for EBR for every logical partition
+ # before alignment is performed.
+ if ptable_format == "msdos":
+ d['offset'] += 1
+
+
if p['align']:
# If not first partition and we do have alignment set we need
# to align the partition.
@@ -185,14 +192,6 @@ class Image:
p['num'] = d['numpart']
if d['ptable_format'] == "msdos":
- if d['numpart'] > 2:
- # Every logical partition requires an additional sector for
- # the EBR, so steal the last sector from the end of each
- # partition starting from the 3rd one for the EBR. This
- # will make sure the logical partitions are aligned
- # correctly.
- p['size'] -= 1
-
if d['numpart'] > 3:
p['type'] = 'logical'
p['num'] = d['numpart'] + 1
@@ -259,13 +258,20 @@ class Image:
for p in self.partitions:
d = self.disks[p['disk_name']]
if d['ptable_format'] == "msdos" and p['num'] == 5:
- # The last sector of the 3rd partition was reserved for the EBR
- # of the first _logical_ partition. This is why the extended
- # partition should start one sector before the first logical
- # partition.
+ # Create an extended partition (note: extended
+ # partition is described in MBR and contains all
+ # logical partitions). The logical partitions save a
+ # sector for an EBR just before the start of a
+ # partition. The extended partition must start one
+ # sector before the start of the first logical
+ # partition. This way the first EBR is inside of the
+ # extended partition. Since the extended partitions
+ # starts a sector before the first logical partition,
+ # add a sector at the back, so that there is enough
+ # room for all logical partitions.
self.__create_partition(d['disk'].device, "extended",
None, p['start'] - 1,
- d['offset'] - p['start'])
+ d['offset'] - p['start'] + 1)
if p['fstype'] == "swap":
parted_fs_type = "linux-swap"
@@ -338,14 +344,6 @@ class Image:
for p in self.partitions:
d = self.disks[p['disk_name']]
- if d['ptable_format'] == "msdos" and p['num'] == 5:
- # The last sector of the 3rd partition was reserved for the EBR
- # of the first _logical_ partition. This is why the extended
- # partition should start one sector before the first logical
- # partition.
- self.__write_partition(p['num'], p['source_file'],
- p['start'] - 1,
- d['offset'] - p['start'])
self.__write_partition(p['num'], p['source_file'],
p['start'], p['size'])