unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Thomas Schmitt" <scdbackup@gmx.net>
To: bug-xorriso@gnu.org
Cc: guix-devel@gnu.org
Subject: Re: ISO installer image: GPT versus MBR partitions
Date: Wed, 17 Apr 2019 17:51:41 +0200	[thread overview]
Message-ID: <25067672293041792707@scdbackup.webframe.org> (raw)
In-Reply-To: <63026723884801035449@scdbackup.webframe.org>

Hi,

here are instructions to repack a Guix ISO with EFI support (via GPT)
to an ISO with MBR-only partition table.

Tested with guixsd-install-0.15.0.i686-linux.iso, because my copy
of 0.16.0 is one of the victims of bug#33639.

It becomes 130 MiB larger than the original, probably because there
were hardlinks in the original disk tree, which share their content in
the original ISO but which the Linux isofs driver cannot expose as
hardlink siblings when the ISO gets mounted.
E.g.
  /gnu/store/0br6mgbnc8b0myvvgpihhry9lfb67pdv-gmp-6.1.2/share/info/gmp.info-1.gz
  /gnu/store/2078rjc6rlj5yran6sx9kd5k4281j0vm-gmp-6.1.2/share/info/gmp.info-1.gz  /gnu/store/v78qymi7sxywv8l6kk5iydvvpdpncrsv-gmp-6.1.2/share/info/gmp.info-1.gz
have all the same LBA in the original ISO. But Linux shows them with
three different inode numbers, which it derives from the byte addresses
of the files' directory records. Shwoops ... 190 KiB more.
A few hundred such duplications would cause 130 MiB of growth.

About 17 MiB of the size difference are due to the second directory
tree which is needed to make partition 1 mountable despite not
beginning at block address 0.
Guix has a generously sized directory tree in its ISO. More than 30,000
data files. But i think a nice partition table is worth even 17 MiB.

=========================================================================

# Some paths which one may choose differently
BASE_ISO=guixsd-install-0.15.0.i686-linux.iso
MOUNT_POINT=/mnt/iso
EXTRACTED_MBR_IMG=extracted_mbr.img
REPACKED_ISO=guix-0.15.0.i686-mbr-only.iso

# (I myself prefer to become real superuser for mounting. But sudo is modern.)
PRIV_CMD=sudo

# Now for the work:

# Extract the MBR x86 code part from the original ISO
dd if="$BASE_ISO" bs=1 count=446 of="$EXTRACTED_MBR_IMG"

# The mounted original ISO will donate all its files to the repacked one
$PRIV_CMD mount -o loop "$BASE_ISO" "$MOUNT_POINT"

# The follow xorriso run builds the repacked ISO by native xorriso commands.
# Other than the mkisofs emulation it would not truncate an existing
# ISO image but rather complain about an unsuitabe multi-session setup.
# So remove an older image, if it exists:
test -e "$REPACKED_ISO" && rm "$REPACKED_ISO"

# Map the ISO data files into the new ISO, but delete /efi.img, which is the
# FAT filesystem image of the EFI partition.
# Install the extracted MBR with GRUB specific adjustments and start of
# partition 1 at byte 32768.
# Append the EFI partition image after the ISO filesystem (that is why the file
# is not needed inside the filesystem and then makes a much nicer partition).
# Set up the first El Torito catalog entry for PC-BIOS.
# Set up the second  El Torito catalog entry for EFI, using the appended
# partition.
xorriso \
   -outdev "$REPACKED_ISO" \
   -volid 'GUIXSD_IMAGE' \
   \
   -map "$MOUNT_POINT" "/" \
   -rm /efi.img -- \
   \
   -boot_image grub grub2_mbr="$EXTRACTED_MBR_IMG" \
   -boot_image any mbr_force_bootable=on \
   -boot_image any partition_table=on \
   -boot_image any iso_mbr_part_type=0x83 \
   -boot_image any partition_offset=16 \
   \
   -append_partition 2 0xef "$MOUNT_POINT"/efi.img \
   \
   -boot_image any cat_path='/boot.catalog' \
   \
   -boot_image grub bin_path='/boot/grub/i386-pc/eltorito.img' \
   -boot_image grub grub2_boot_info=on \
   -boot_image any emul_type=no_emulation \
   -boot_image any load_size=2048 \
   -boot_image any boot_info_table=on \
   \
   -boot_image any next \
   \
   -boot_image any efi_path='--interval:appended_partition_2:all::' \
   -boot_image any emul_type=no_emulation

=========================================================================

The result may be inspected by

  xorriso \
     -indev "$REPACKED_ISO" \
     -report_system_area plain \
     -report_el_torito plain

which should say

  ...
  Volume id    : 'GUIXSD_IMAGE'
  System area options: 0x00004a00
  System area summary: MBR grub2-mbr cyl-align-off
  ISO image size/512 : 2071064
  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  0x83           64      2065240
  MBR partition      :   2   0x00  0xef      2065304         5760
  El Torito catalog  : 17333  1
  El Torito cat path : /boot.catalog
  El Torito images   :   N  Pltf  B   Emul  Ld_seg  Hdpt  Ldsiz         LBA
  El Torito boot img :   1  BIOS  y   none  0x0000  0x00      4       17334
  El Torito boot img :   2  UEFI  y   none  0x0000  0x00   5760      516326
  El Torito img path :   1  /boot/grub/i386-pc/eltorito.img
  El Torito img opts :   1  boot-info-table grub2-boot-info
  El Torito img blks :   2  1440

=========================================================================

For eyes which are not accustomed to xorriso's native command set, here is
the same with mkisofs emulation options (without trying to exclude
/mnt/iso/efi.img from the filesystem):

xorriso -as mkisofs \
   -o "$REPACKED_ISO" \
   -V 'GUIXSD_IMAGE' \
   \
   --grub2-mbr "$EXTRACTED_MBR_IMG" \
   --mbr-force-bootable \
   -iso_mbr_part_type 0x83 \
   -partition_offset 16 \
   \
   -append_partition 2 0xef "$MOUNT_POINT"/efi.img \
   \
   -c '/boot.catalog' \
   \
   -b '/boot/grub/i386-pc/eltorito.img' \
   --grub2-boot-info \
   -boot-info-table \
   -no-emul-boot \
   -boot-load-size 4 \
   \
   -eltorito-alt-boot \
   \
   -e '--interval:appended_partition_2:all::' \
   -no-emul-boot \
   \
   "$MOUNT_POINT"

Most users, including grub-mkrescue, prefer the mkisofs emulation because
they can recycle old knowledge from El-Torito-BIOS-only times.
The appeal of the native command set mostly shows up when the ISO content
is not shaped in a tree on hard disk but collected and arranged from
various files and trees.

Main difference is that sequence does strictly matter with the native set.
E.g. i cannot set boot attributes to files which are not mapped in yet.
The mkisofs emulation sets up a production job and only then assesses
the input file objects. (Imagine a shell which takes a dozen commands
from you and re-arranges them before executing them. Ewww ...)


Have a nice day :)

Thomas

  parent reply	other threads:[~2019-04-17 15:49 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190415165451.dpzngealeisbibc7@pelzflorian.localdomain>
     [not found] ` <1582867226375139246@scdbackup.webframe.org>
2019-04-16  9:57   ` bug#33639: ISO installer image is broken on i686 Gábor Boskovits
2019-04-16 13:40     ` ISO installer image: GPT versus MBR partitions (was bug#33639) Thomas Schmitt
2019-04-16 16:32       ` pelzflorian (Florian Pelz)
2019-04-16 17:57         ` ISO installer image: GPT versus MBR partitions Thomas Schmitt
2019-04-16 19:55           ` pelzflorian (Florian Pelz)
2019-04-16 20:31             ` pelzflorian (Florian Pelz)
2019-04-16 21:15               ` Thomas Schmitt
2019-04-17  8:59                 ` pelzflorian (Florian Pelz)
2019-04-17 10:23                   ` Thomas Schmitt
2019-04-17 10:30                     ` pelzflorian (Florian Pelz)
2019-04-17 15:51                     ` Thomas Schmitt [this message]
2019-04-17 22:35                       ` pelzflorian (Florian Pelz)
2019-04-18  6:32                         ` Thomas Schmitt
2019-04-18  7:00                           ` Thomas Schmitt
2019-04-18  7:07                             ` pelzflorian (Florian Pelz)
2019-04-18  8:13                               ` Thomas Schmitt
2019-04-18 12:19                                 ` pelzflorian (Florian Pelz)
2019-04-18 13:50                                   ` Thomas Schmitt
2019-04-18 21:28                                     ` Thomas Schmitt
2019-04-19  7:29                                       ` pelzflorian (Florian Pelz)
2019-04-19  8:03                                     ` pelzflorian (Florian Pelz)
2019-04-19  9:01                                       ` Thomas Schmitt
2019-04-19  9:39                                         ` pelzflorian (Florian Pelz)
2019-04-19 10:58                                           ` Thomas Schmitt
2019-04-19 14:57                                             ` pelzflorian (Florian Pelz)
2019-04-19 11:30                                         ` pelzflorian (Florian Pelz)
2019-04-19 18:33                                           ` pelzflorian (Florian Pelz)
2019-04-19 19:23                                             ` Thomas Schmitt
2019-04-20 10:26                                               ` pelzflorian (Florian Pelz)
2019-04-20 10:50                                                 ` Thomas Schmitt
2019-04-20 11:16                                                   ` Thomas Schmitt
2019-04-20 11:29                                                     ` Thomas Schmitt
2019-04-20 14:23                                                       ` Thomas Schmitt
2019-04-20 14:54                                                         ` pelzflorian (Florian Pelz)
2019-04-20 15:17                                                           ` pelzflorian (Florian Pelz)
2019-04-20 15:33                                                           ` pelzflorian (Florian Pelz)
2019-04-20 16:32                                                             ` Thomas Schmitt
2019-04-21  7:58                                                               ` pelzflorian (Florian Pelz)
2019-04-21  9:35                                                                 ` Thomas Schmitt
2019-04-21 11:10                                                                   ` pelzflorian (Florian Pelz)
2019-04-21 11:16                                                                 ` Thomas Schmitt
2019-04-21 11:56                                                                   ` pelzflorian (Florian Pelz)
2019-04-21 12:27                                                                     ` Thomas Schmitt
2019-04-21 14:11                                                                       ` pelzflorian (Florian Pelz)
2019-04-21 14:36                                                                         ` Thomas Schmitt
2019-04-22 13:11                                                                           ` Thomas Schmitt
2019-04-23 16:40                                                                       ` pelzflorian (Florian Pelz)
2019-04-23 17:23                                                                         ` Thomas Schmitt
2019-04-17 12:24               ` Ludovic Courtès
2019-04-17 13:42                 ` pelzflorian (Florian Pelz)
2019-04-23 18:14       ` Thomas Schmitt
2019-04-23 19:50         ` pelzflorian (Florian Pelz)
2019-04-23 20:18           ` Thomas Schmitt
2019-04-23 21:43             ` pelzflorian (Florian Pelz)
2019-04-24  6:56               ` Thomas Schmitt
2019-04-24  9:13                 ` pelzflorian (Florian Pelz)
2019-04-24 10:34                   ` Thomas Schmitt
2019-04-24 22:13                     ` Danny Milosavljevic
2019-04-25  7:07                       ` Thomas Schmitt
2019-04-25  9:45                       ` pelzflorian (Florian Pelz)
2019-04-25 13:44                         ` Thomas Schmitt
2019-04-25 14:59                           ` Danny Milosavljevic
2019-04-25 16:22                             ` Thomas Schmitt
2019-04-25 17:55                               ` Danny Milosavljevic
2019-04-25 18:46                                 ` Thomas Schmitt
2019-04-25 19:01                                   ` Danny Milosavljevic
2019-04-25 16:34                         ` Ludovic Courtès
2019-04-26 11:34                           ` pelzflorian (Florian Pelz)
2019-04-26 14:41                             ` Ludovic Courtès
2019-04-26 15:30                               ` pelzflorian (Florian Pelz)
2019-04-26 13:57                           ` Thomas Schmitt
2019-04-27 13:20                             ` Ludovic Courtès
2019-04-27 16:24                               ` Thomas Schmitt
2019-04-28 12:53                                 ` Ludovic Courtès
2019-04-25 11:49                   ` pelzflorian (Florian Pelz)
2019-04-25 15:09                     ` Thomas Schmitt
2019-04-25 15:58                       ` pelzflorian (Florian Pelz)
2019-04-25 16:40                         ` Thomas Schmitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=25067672293041792707@scdbackup.webframe.org \
    --to=scdbackup@gmx.net \
    --cc=bug-xorriso@gnu.org \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).