Hi,

Claude Heiland-Allen wrote:
> Can this be done by patching the ISO file in place (if so, how?  maybe some
> dd invocation with same-size bootloader config file with different content?)

Not judging whether this is a good idea: Yes it can be done.

Find out the position and size of a file:

  file=/boot/grub/grub.cfg
  iso=debian-live-13.1.0-amd64-standard.iso
  xorriso -indev "$iso" -find "$file" -exec report_lba --

This will report on stdout:

  Report layout: xt , Startlba ,   Blocks , Filesize , ISO image path
  File data lba:  0 ,     3285 ,        1 ,     1709 , '/boot/grub/grub.cfg'

which tells you that your replacement file must have exactly 1709
bytes and has to be written to 2048-byte block 3285.

This dd run should then do the trick:

  dd if=my_grub_cfg of="$iso" conv=notrunc bs=2048 seek=3285 count=1

(Not actually tested. Just toggled in. Make a backup of the ISO
first.)

The option count=1 is just a safety net to prevent damage in other
files. If my_grub_cfg would be too small, then debris from the
original file remains visible. If it would be too large, then only the
first 1709 bytes are visible.


Size changes or file additions could be done by repacking the ISO
like in
  
https://wiki.debian.org/RepackBootableISO#In_xorriso_load_ISO_tree_and_write_modified_new_ISO

In the simple case of replacing /boot/grub/grub.cfg :

  new_iso=my_modified.iso
  xorriso \
    -indev "$iso" \
    -outdev "$new_iso" \
    \
    -map my_grub_cfg /boot/grub/grub.cfg \
    \
    -boot_image any replay \
    -compliance no_emul_toc \
    -padding included


Have a nice day :)

Thomas

Reply via email to