[syslinux] isohybrid and ISO images whose size is not a multiple of 2048 bytes vs. VirtualBox

Thomas Schmitt scdbackup at gmx.net
Fri Feb 20 09:28:31 PST 2015


Hi,

> What about '-h 255 -s 63 , ISO size 1085736960' ?

-h 255 -s 63 , ISO size 1085736960 :
  align_factor= 4 , padding= 0 , image size= 132.000000 cylinders

-----------------------------------------------------------------
Code of isohybrid_test_mockup.c :
-----------------------------------------------------------------

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv)
{
 int cylsize = 0, frac = 0, align_factor, align_cylsize;
 int padding;
 unsigned long img_size;
 int head, sector;

 sscanf(argv[1], "%d", &head);
 sscanf(argv[2], "%d", &sector);
 sscanf(argv[3], "%lu", &img_size);

 /* Begin of isohybrid.c code */

    /* Making sure that the resulting image size is divisible by 2048.
       (Can waste nearly 32 MB. Should be done on user request only.)
    */
    if ((head * sector) % 4 == 0)
        align_factor = 1;
    else if ((head * sector) % 2 == 0)
        align_factor = 2;
    else
        align_factor = 4;

    cylsize = head * sector * 512;
    align_cylsize = cylsize * align_factor;
    frac = img_size % align_cylsize;
    padding = (frac > 0) ? align_cylsize - frac : 0;

 /* End of isohybrid.c code */

 printf("-h %d -s %d , ISO size %lu :\n", head, sector, img_size);
 printf("  align_factor= %d , padding= %d , image size= %f cylinders\n",
        align_factor, padding,
        (double) (img_size + padding) / (double) cylsize);

 exit(0);
}

-----------------------------------------------------------------
End of code
-----------------------------------------------------------------

Compile by

  cc -g -Wall -o isohybrid_test_mockup isohybrid_test_mockup.c

Run as e.g.

  ./isohybrid_test_mockup 255 63 1085736960


> > I expect the average waste to be a bit less than 16 MB.
> Yes, but slightly misleading. For example, the "16MB average" is 
> relevant for 255/63.

We advise two geometries: -h 63 -s 32 and -h 255 -s 63.
isohybrid behavior with the first one will not be changed.
With the second one it would waste 16 MB in average.


> Some user reading the code might not know the whole reasoning for:

This is not yet a proposal for changing isohybrid.c.
It is for testing the consequences of the idea on
real ISOs. If anybody is interested to do so ...


> Note that I also removed the second phrase, "Should be done on user 
> request only", as I disagree.

Whoever decides about committing a final patch will also
decide whether this behavior should be hardcoded, or be
default, or need to be enabled explicitely by the user.

I'd vote for the latter.


> I would not expect distro maintainers to edit 
> isohybrid.c so to make use of the patch;

Of course a final patch would offer an option to enable
the feature. Something like --big-align alias -B.


Have a nice day :)

Thomas



More information about the Syslinux mailing list