bug-xorriso
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-xorriso] Mountable ISO and GRUB2


From: Thomas Schmitt
Subject: Re: [Bug-xorriso] Mountable ISO and GRUB2
Date: Fri, 23 Dec 2016 15:11:06 +0100

Hi,

> We want now to create a bootable ISO for the distro, but we have a few
> constrains:
> 1) moving to ISOLINUX is not the preferred option

There is no need to do so. It's just an old habit of distros to stick
to ISOLINUX because they know it works for BIOS.
All Linux distros which can boot from ISO via EFI do this by GRUB.


> Right now we are generating the GRUB2 eltorito.img with something like:
> ...
> This is basically what grub-mkrescue is doing behind the curtain with
> some customization we need for our setup.
> ...
> The problem we have is that the generated ISO doesn't have a mountable
> ISO partition. In both MBR and GPT the first partition is starting at
> 512-block 64 instead that 512-block 0.

That's Vladimir Serbinko's preferred layout: GPT with standards compliant
"Protective MBR".

I myself would prefer the MBR based variant. There is a wrapper script
  
https://dev.lovelyhq.com/libburnia/libisoburn/blob/master/frontend/grub-mkrescue-sed.sh
which given to grub-mkrescue modifies the xorriso arguments so that my
preferred layout emerges. With installed Debian packages
  grub-pc-bin, grub-efi-ia32-bin, grub-efi-amd64-bin
i do:

  # Obtain xorriso-1.4.4 or 1.4.6
  # If not installed in $PATH, you may give its path by
  # export MKRESCUE_SED_XORRISO=.../xorriso

  export MKRESCUE_SED_MODE=mbr_only
  export MKRESCUE_SED_PROTECTIVE=no
  export MKRESCUE_SED_DEBUG=yes

  grub-mkrescue -o output.iso minimal_directory \
               --xorriso=/home/thomas/.../frontend/grub-mkrescue-sed.sh

It produces this partition table

  $ xorriso -indev output.iso -report_system_area plain
  ...
  System area summary: MBR grub2-mbr cyl-align-off
  ISO image size/512 : 23852
  Partition offset   : 0
  MBR heads per cyl  : 64
  MBR secs per head  : 32
  MBR partition table:   N Status  Type        Start       Blocks
  MBR partition      :   1   0x80  0x83            0        23852
  MBR partition      :   2   0x00  0xef        23852         5760

Other than mjg's layout, this is fully compliant to UEFI 2.4 specs.
It uses the newer legacy path of UEFI specs (the older is BIOS emulation).

Actually Vladimir Serbineko's use of the modern path with GPT is not
well suitable for media image files. GPT demands the existence of the
backup partition table at the end of the _device_.
When the image file gets produced, the size of the device is still unknown,
by which it will be presentend to EFI firmware.

Because of MKRESCUE_SED_DEBUG, above grub-mkrescue run told the effective
xorriso arguments.
With a few line breaks and educational argument grouping:

    -as mkisofs
    -o output.iso
    -r -graft-points -no-pad
    --sort-weight 0 / 
    --sort-weight 1 /boot

    --modification-date=2016122313325700

    --grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img
    -append_partition 2 0xef /tmp/grub-mkrescue-sed-efi-img.26767

    -b boot/grub/i386-pc/eltorito.img
       -no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info

    -eltorito-alt-boot

    -e --interval:appended_partition_2:all:: 
       -no-emul-boot

    /tmp/grub.Yd2Kea minimal

where /tmp/grub.Yd2Kea is the directory with grub-mkrescue's prepared stuff.
"minimal" is my dummy payload directory.

The file /tmp/grub-mkrescue-sed-efi-img.26767 is the EFI system partition
image, which grub-mkrescue prepared for xorrisofs option --efi-boot.

The argument "--interval:appended_partition_2:all::" points to the appended
partition and is the reason why you need xorriso >= 1.4.4.
With older xorriso, you'd have to bring /tmp/grub-mkrescue-sed-efi-img.26767
as data file into the ISO and then point to it by option -e. Then you have
it in the image twice.


Note that the EFI System partition is not covered by the ISO filesystem size.
This means that some copy and verification reciepes for mjg and Vladimir
layouts may not work correctly with this ISO. (E.g. truncating to output of
program "isosize" would be bad.)


If a few hundred KB do not matter, one could consider option

    -partition_offset 16

to let the first partition start at block 16 which will be mountable
by a second ISO 9660 superblock and directory tree:

  System area summary: MBR grub2-mbr cyl-align-off
  ISO image size/512 : 24172
  Partition offset   : 16
  MBR heads per cyl  : 64
  MBR secs per head  : 32
  MBR partition table:   N Status  Type        Start       Blocks
  MBR partition      :   1   0x80  0xcd           64        24108
  MBR partition      :   2   0x00  0xef        24172         5760

Several partition editors prefer this over 


Have a nice day :)

Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]