Commit 3eac3da
committed
ptgen: don't insert CHS gap head in MBR partition tables
When ptgen is aligning partitions on a specific kB boundary (-l option;
OpenWrt uses 256kB for x86, but other, larger values for some other
architectures) and creating an MBR-type partition table (-g option
absent), it was inserting an extra head's worth of gap between
partitions.
For example, in the x86 case, where OpenWrt builds an image using -h 16
-s 63, consisting of 16MB and 104MB partitions by default, and 256kB
alignment, ptgen produced:
Device Boot Start End Sectors Size Id Type
img1 * 512 33279 32768 16M 83 Linux
img2 33792 246783 212992 104M 83 Linux
Notice the 512-sector gap between the end of the first partition and the
start of the second, despite the fact that sector 33280 (which
immediately follows the first partition) would have been 256kB-aligned.
This occurred because ptgen inserted a gap equal to one CHS head before
256kB-aligning the second partition. In this 63 sector/head geometry
requested when OpenWrt builds an image, this gap results in 32,256 bytes
of waste, which after kB-aligning, becomes 256kB of waste.
The expected layout, which is produced after this patch:
Device Boot Start End Sectors Size Id Type
img1 * 512 33279 32768 16M 83 Linux
img2 33280 246271 212992 104M 83 Linux
This gapless layout more closely resembles the layout when ptgen is used
in GPT (-g) mode.
The 1-head gap between partitions in head-aligning mode (no -l) also
appears to be unnecessary. The sole function of this gap seems to be to
force the first partition to begin at the first sector of the second
head rather than the first head, which would have resulted in a
collision because the MBR partition table resides there. With this
change, a different approach is taken, in which the first partition's
position is set more directly to the start of the first head, without
affecting subsequent partitions. This eliminates the 32,256-byte gap
between partitions in this mode. Note that when head-aligning, each
partition's size is padded as needed so as to consume an entire head, so
any subsequent partition will still be head-aligned. In OpenWrt, only
gemini/dlink_dns-313 and layerscape sdcard images use ptgen to produce a
non-kB-aligned MBR partition table, and it doesn't appear that either
will be negatively impacted by this change.
Signed-off-by: Mark Mentovai <mark@mentovai.com>1 parent 9e2de85 commit 3eac3da
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| |||
0 commit comments