[syslinux] isohybrid and ISO images whose size is not a multiple of 2048 bytes vs. VirtualBox
Thomas Schmitt
scdbackup at gmx.net
Thu Feb 19 23:20:50 PST 2015
Hi,
my proposal is based on a mathematical proof (see mail
before) and yours is correct too. They cannot but match.
Let's inspect your examples:
Ady wrote:
> ISO size: 1'085'736'960 bytes ( > 1GiB)
This are exactly 132 cylinders of 255x63.
132 is divisible by 4. So there is no padding needed.
> Cylinders (1st attempt)=132
> [...]
> 2120580 / 4 = 530145, so the answer is "yes".
My calculation gets align_factor = 4.
So isohybrid would pad up to quadruple cylinders.
Well, 132 is already such a quadruple.
> When comparing your code with my suggested calculation, I see that your
> conditionals do not account for the ISO image size, but only for
> "Heads" and "Sectors_per_track".
The existing code in isohybrid already handles the size
for padding up to a target granularity. Currently the
target is always a single cylinder.
My new code only decides about the granularity of 1, 2,
or 4 cylinders.
> ISO size: 1'085'736'960 bytes+2048 bytes
> [...]
> 136 * 255 * 63 = 2184840
> 2184840 / 4 = 546210 so the answer is "yes".
My proposal:
Granularity is still 4 cylinders.
Image size is 132.0002489884843 cylinders.
So the target size is the next multiple of 4: 136 cylinders.
Your algorithm is more complicated than mine, because it
tries to do the part of the job which is already
implemented in isohybrid:
cylsize = head * sector * 512;
frac = isostat.st_size % cylsize;
padding = (frac > 0) ? cylsize - frac : 0;
isostat.st_size is the ISO image size in bytes.
cylsize is the current granularity of 1 cylinder.
My proposal has 1, 2, or 4 cylinders instead.
cylsize = head * sector * 512;
align_cylsize = cylsize * align_factor;
frac = isostat.st_size % align_cylsize;
padding = (frac > 0) ? align_cylsize - frac : 0;
Numbers inserted:
cylsize = 255 * 63 * 512 = 8225280
align_cylsize = 8225280 * 4 = 32901120
frac = (1085736960 + 2048) % 32901120 = 2048
padding = 32901120 - 2048 = 32899072
This means that the image will be padded up by nearly 32 MB
to 1085736960 + 2048 + 32899072 = 1118638080 bytes.
This are 1118638080 / 255 / 63 / 512 = 136 cylinders.
Same result as yours.
Have a nice day :)
Thomas
More information about the Syslinux
mailing list