Bug 270393 - hybrid ISO images report broken partition table
Summary: hybrid ISO images report broken partition table
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: install, standards
Depends on:
Blocks:
 
Reported: 2023-03-22 01:00 UTC by Ed Maste
Modified: 2023-04-04 06:33 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2023-03-22 01:00:29 UTC
# mdconfig -a -f images/FreeBSD-13.2-RC3-amd64-disc1.iso 
md2
# gpart show md2 iso9660/13_2_RC3_AMD64_CD

=>      3  2100567  md2  GPT  (1.0G) [CORRUPT]
        3       26    1  freebsd-boot  (13K)
       29       51       - free -  (26K)
       80     4096    2  efi  (2.0M)
     4176  2096394       - free -  (1.0G)

=>      3  2100567  iso9660/13_2_RC3_AMD64_CD  GPT  (1.0G) [CORRUPT]
        3       26                          1  freebsd-boot  (13K)
       29       51                             - free -  (26K)
       80     4096                          2  efi  (2.0M)
     4176  2096394                             - free -  (1.0G)
Comment 1 Ed Maste freebsd_committer freebsd_triage 2023-03-22 14:42:38 UTC
They hybrid ISOs are created by copying the first 32K from a GPT image into the output image, overwriting the iso9660 system area:

   113          # Create a GPT image containing the partitions we need for hybrid boot.
   114          hybridfilename=$(mktemp /tmp/hybrid.img.XXXXXX)
   115          if [ "$(uname -s)" = "Linux" ]; then
   116                  imgsize=`stat -c %s "$NAME"`
   117          else
   118                  imgsize=`stat -f %z "$NAME"`
   119          fi
   120          $MKIMG -s gpt \
   121              --capacity $imgsize \
   122              -b "$BASEBITSDIR/boot/pmbr" \
   123              -p freebsd-boot:="$BASEBITSDIR/boot/isoboot" \
   124              $espparam \
   125              -o $hybridfilename
   126
   127          # Drop the PMBR, GPT, and boot code into the System Area of the ISO.
   128          dd if=$hybridfilename of="$NAME" bs=32k count=1 conv=notrunc
   129          rm -f $hybridfilename

This completely ignores the secondary GPT. We need to copy it as well, enlarging the original ISO image if necessary.