grub-install revamp and grub-mkrescue adjustments
I was looking into Szymon Janc's patch to compress GRUB modules and found out that adding decompression modules makes it grow bigger than the embed zone. So I propose the following change: make boot sector point to eltotito.img and use diskboot.img at this location. This has given good results with using a very crude patch to xorriso (attached for illustration purposes). I've seen that isohybrid image make similar changes, what is the exact behaviour for isohybrid? PErhaps we can unify it with ours? Offsets aren't written in stone and I wanted to change boot.img for isos a bit first to allow it botting as a floppy even on broken BIOSes (we need few routines for those which are overwritten by partition table, I'll move them to the space reserved for BBP, it's no big deal since there is no BBP on iso9660).
This also allows to use other embed sectors to create alternative filesystems. As for the roadmap for creating an iso bootable everywhere as both USB stick and CDROM we'll need following adjustments
- i386-pc: detailed above.
- *-efi: we currently support only CD-ROMs. Supporting USB sticks needs just to create a partition of type 0xEF pointing to EFI eltorito image.
- Macs would need an APM and HFS(+) filesystem. No need to have HFS span over whole disk. It can just point to a small image. To have an APM we need to have bytes
4552 0200 (512 sectors). Rest of table goes to sectors 1-n (n is the number of partitions)
- IBM PPC require PreP (msdos with type=42) partition.
- ARC would require 0b e5 a9 41 at the beginning and so it's skipped
- Put i386-ieee1275 images to the same 0xef partition as EFI images.
- Have an ext2 partition for mipsel-loongson and i386-multiboot
- Sun would use most of sector 0, so it's skipped.
So the layout is:
4552 0200 <grub code> <partition map: 0xef, 0x42, logical, empty> 55 aa <APM entry covering partmap itself><APM protective entry 1><APM HFS><APM protective entry 2><usual iso9660, right after prep file, an EBR>
Adjustments to xorriso:
- patch address in boot sector to eltorito.img. Patch 2nd sector of eltorito.img to point to itself.
- set addresses to partitions to point to efi.img, prep.img and to an EBR right after max (prep.img, efi.img, 4 x 512). Make EBR describe a logical partition spanning the rest of iso9660. efi.img or prep.img may be missing
- generate APM to point to the hfs.img
For supporting Sun (only, without any other one using sector 0):
-generate sun disklabel and patch an address and size to boot image in sector 1. For supporting ARC (only, without any other one using sector 0):
-generate DVH and set it to point to address of arc.img.
What do you think about this how reasonable is it?
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
=== modified file 'ChangeLog'
ChangeLog +10 -0
@@ -1,8 +1,18 @@ +<<<<<<< TREE 2012-01-30 Vladimir Serbinenko <[email protected]> * grub-core/io/lzopio.c (uncompress_block): Fix use of incorrect variable. +======= +2012-01-29 Szymon Janc <[email protected]> + + Put grub-mkrescue generated image on diet (modules compression and + xorriso options). + + * util/grub-mkrescue.in: New option --compress. + +>>>>>>> MERGE-SOURCE 2012-01-29 Vladimir Serbinenko <[email protected]> * grub-core/lib/posix_wrap/string.h (memchr): New function.
=== modified file 'grub-core/boot/i386/pc/diskboot.S'
boot/i386/pc/diskboot.S +1 -1
@@ -83,7 +83,7 @@ /* the maximum is limited to 0x7f because of Phoenix EDD */ xorl %eax, %eax - movb $0x7f, %al + movb $0x1, %al /* how many do we really want to read? */ cmpw %ax, 8(%di) /* compare against total number of sectors */
=== modified file 'util/grub-mkrescue.in'
grub-mkrescue.in +62 -28
156 lines not on this page · raw message
libisofs/eltorito.c +10 -0
@@ -1113,6 +1113,16 @@ ret =make_boot_info_table (buf, t->ms_block + (uint32_t )16 , t->bootsrc[idx]->sections[0 ].block, (uint32_t ) imgsize); +if (1 ) { +uint64_t blk; +if (imgsize <1024 ) +return iso_msg_submit (t->image->id,ISO_ISOLINUX_CANT_PATCH ,0 , +"Isolinux image too small. We won't patch it." ); + + blk = ((uint64_t ) t->bootsrc[idx]->sections[0 ].block) *4 +2 ; +iso_lsb ((buf +1024 -12 ), blk &0xffffffff ,4 ); +iso_lsb ((buf +1024 -8 ), blk >>32 ,4 ); + }return ret; }
libisofs/system_area.c +10 -3
@@ -182,7 +182,7 @@*/ static int make_grub_msdos_label (uint32_t img_blocks,int sph,int hpc, -uint8_t *buf,int flag) +uint8_t *buf,int flag,uint64_t blk) {uint8_t *wpt;uint32_t end_lba, end_sec, end_head, end_cyl;
@@ -191,6 +191,11 @@iso_compute_cyl_head_sec (&img_blocks, hpc, sph, &end_lba, &end_sec, &end_head, &end_cyl,0 ); + blk = blk *4 +1 ; + + wpt = buf +0x5c ; +for (i =0 ; i <8 ; i++) + wpt[i] = blk >> (i *8 );/* 1) Zero-fill 446-510 */ wpt = buf +446 ;memset (wpt,0 ,64 );
@@ -739,7 +744,8 @@if (sa_type ==0 && (t->system_area_options &1 )) {/* Write GRUB protective msdos label, i.e. a simple partition table */ ret =make_grub_msdos_label (img_blocks, t->partition_secs_per_head, - t->partition_heads_per_cyl, buf,0 ); + t->partition_heads_per_cyl, buf,0 , + t->bootsrc[0 ]->sections[0 ].block);if (ret !=ISO_SUCCESS )/* error should never happen */ return ISO_ASSERT_FAILURE ; }else if (sa_type ==0 && (t->system_area_options &2 )) {
@@ -766,7 +772,8 @@ }else if ((t->partition_offset >0 || will_append) && sa_type ==0 ) {/* Write a simple partition table. */ ret =make_grub_msdos_label (img_blocks, t->partition_secs_per_head, - t->partition_heads_per_cyl, buf,2 ); + t->partition_heads_per_cyl, buf,2 , + t->bootsrc[0 ]->sections[0 ].block);if (ret !=ISO_SUCCESS )/* error should never happen */ return ISO_ASSERT_FAILURE ;if (t->partition_offset ==0 ) {
xorriso/emulators.c +8 -0
@@ -1895,6 +1895,14 @@ goto problem_handler_boot;if (strcmp (argpt,"-isohybrid-mbr" )==0 ) xorriso->system_area_options= (xorriso->system_area_options & ~3 ) |2 ; + }else if (strcmp (argpt,"--grub-boot" )==0 ) { +if (i+1 >=argc) + goto not_enough_args; + i++; + ret=Xorriso_set_system_area_path (xorriso, argv[i],0 ); +if (ret <=0 ) + goto problem_handler_boot; + xorriso->patch_isolinux_image=1 |4 ; }else if (strcmp (argpt,"--protective-msdos-label" )==0 ) { xorriso->system_area_options= (xorriso->system_area_options & ~3 ) |1 ; }else if (strcmp (argpt,"--boot-catalog-hide" )==0 ) {