Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xorriso: respect efiparttable and gpt_hybrid_mbr #2695

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

AdamWill
Copy link
Contributor

This should make the xorriso-based ISO build path respect the 'efiparttable' and 'gpt_hybrid_mbr' settings when building a UEFI-compatible image, making it write a GPT disk label by default instead of an MBR (msdos) one. If it's building an image that is not UEFI-compatible it will always write an MBR label, regardless of this setting.

If 'gpt_hybrid_mbr' is set, xorriso will write an Ubuntu-style MBR/GPT hybrid partition table, where the MBR partition table includes a partition with type 00 and the bootable flag, as well as the partition with type ee required by the UEFI spec. This mildly violates the UEFI spec but may make the image bootable on native BIOS or CSM firmwares which refuse to boot from a disk with no partition marked 'bootable' in the MBR. If 'gpt_hybrid_mbr' is not set, xorriso will write a strictly UEFI-spec compliant label, with just the 'protective MBR' required by the UEFI spec (no bootable partition) and the correct GPT partition table. Note this is somewhat different from what gpt_hybrid_mbr does for disk images.

Also, we now pass -compliance no_emul_toc when building ISOs, as recommended by upstream in
https://lists.gnu.org/archive/html/bug-xorriso/2024-11/msg00012.html This tool is generally always going to be building ISOs intended for write-once use, not multi-session use (and which are rarely, these days, written to physical discs at all anyway).

Fixes #2685 .

@AdamWill
Copy link
Contributor Author

AdamWill commented Dec 12, 2024

Compare with @schaefi 's #2693 . I need to update the docs for gpt_hybrid_mbr but I wanted to get this submitted so you can look at it. Note @schaefi also added '-boot_image', 'grub', 'partition_table=on' and '-boot_image', 'any', 'partition_cyl_align=off', but I'm not clear on why, and his commit message doesn't say, and I can't see anywhere Thomas recommended them in the bug or the mailing list. If there's a good reason to add these, I can go ahead and add them.

I did adapt the report_call bit from @schaefi 's PR and adapted the test changes from it too, thanks for those.

@Conan-Kudo
Copy link
Member

@AdamWill do you have a sample image build using this change to test with?

@AdamWill
Copy link
Contributor Author

no, I didn't get to that yet. Going to do it soon.

@AdamWill AdamWill force-pushed the live-gpt-test branch 2 times, most recently from 7c23d88 to c2abdf9 Compare December 13, 2024 01:27
@AdamWill
Copy link
Contributor Author

AdamWill commented Dec 13, 2024

https://openqa.stg.fedoraproject.org/tests/4524655/asset/iso/04524655-Fedora-KDE-Live-x86_64-126774230.iso , I'll upload it to my FP space in a minute as it'll get garbage collected. That's built with the GPT and hybrid options set.

edit: here it is - https://adamwill.fedorapeople.org/04524655-Fedora-KDE-Live-x86_64-126774230.iso

@AdamWill
Copy link
Contributor Author

Here's the relevant log bit:

[ DEBUG   ]: 21:46:00 | EXEC: [/usr/bin/xorriso -application_id KDE-Desktop-Live-126774230 -publisher Fedora Project -preparer_id KIWI - https://github.com/OSInside/kiwi -volid KIWI-126774230 -joliet on -padding 0 -compliance no_emul_toc -outdev /builddir/result/image/Fedora.x86_64-Rawhide.iso -map /builddir/result/image/live-media.b80yanuy / -chmod 0755 / -- -boot_image grub bin_path=boot/x86_64/loader/eltorito.img -boot_image grub grub2_mbr=/builddir/result/image/live-media.b80yanuy/boot/x86_64/loader/boot_hybrid.img -boot_image grub grub2_boot_info=on -boot_image any partition_offset=16 -boot_image any cat_path=boot/x86_64/boot.catalog -boot_image any cat_hidden=on -boot_image any boot_info_table=on -boot_image any platform_id=0x00 -boot_image any emul_type=no_emulation -boot_image any load_size=2048 -boot_image any appended_part_as=gpt -boot_image any mbr_force_bootable=on -append_partition 2 0xef /builddir/result/image/efi-loader.skcf_7kg -boot_image any next -boot_image any efi_path=--interval:appended_partition_2:all:: -boot_image any platform_id=0xef -boot_image any emul_type=no_emulation]
[ DEBUG   ]: 21:46:12 | Looking for xorriso in /usr/bin:/bin:/usr/sbin:/sbin
[ DEBUG   ]: 21:46:12 | EXEC: [/usr/bin/xorriso -indev /builddir/result/image/Fedora.x86_64-Rawhide.iso -report_system_area plain]
[ DEBUG   ]: 21:46:12 | System area options: 0x00004201
System area summary: MBR protective-msdos-label grub2-mbr cyl-align-off GPT
ISO image size/512 : 5613184
Partition offset   : 16
MBR heads per cyl  : 0
MBR secs per head  : 0
MBR partition table:   N Status  Type        Start       Blocks
MBR partition      :   1   0x00  0xee            1      5613183
MBR partition      :   2   0x80  0x00            0            1
GPT                :   N  Info
GPT disk GUID      :      88f0d44d807ab24b945351d60c3b0b6f
GPT entry array    :      2  248  separated
GPT lba range      :      64  5613120  5613183
GPT partition name :   1  490053004f003900360036003000
GPT partname local :   1  ISO9660
GPT partition GUID :   1  88f0d44d807ab24b945251d60c3b0b6f
GPT type GUID      :   1  a2a0d0ebe5b9334487c068b6b72699c7
GPT partition flags:   1  0x1000000000000001
GPT start and size :   1  64  5551616
GPT partition name :   2  41007000700065006e006400650064003200
GPT partname local :   2  Appended2
GPT partition GUID :   2  88f0d44d807ab24b945151d60c3b0b6f
GPT type GUID      :   2  28732ac11ff8d211ba4b00a0c93ec93b
GPT partition flags:   2  0x0000000000000000
GPT start and size :   2  5551680  61440

@schaefi schaefi self-requested a review December 13, 2024 09:56
Copy link
Collaborator

@schaefi schaefi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks much, looks good to me and I can see all relevant changes from #2693 to be part of this PR 👍

@schaefi
Copy link
Collaborator

schaefi commented Dec 13, 2024

@AdamWill

Note @schaefi also added '-boot_image', 'grub', 'partition_table=on' and '-boot_image', 'any', 'partition_cyl_align=off', but I'm not clear on why,

I added those because in my mail conversation with Thomas he used them too. But frankly speaking I cannot give a good answer to the why

@AdamWill
Copy link
Contributor Author

@AdamWill

Note @schaefi also added '-boot_image', 'grub', 'partition_table=on' and '-boot_image', 'any', 'partition_cyl_align=off', but I'm not clear on why,

I added those because in my mail conversation with Thomas he used them too. But frankly speaking I cannot give a good answer to the why

Let's ask him! I'll ask over in the rh bug.

Copy link
Member

@Conan-Kudo Conan-Kudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor documentation fixes and then I think this is good to go.

This should make the xorriso-based ISO build path respect the
'efiparttable' and 'gpt_hybrid_mbr' settings when building a
UEFI-compatible image, making it write a GPT disk label by default
instead of an MBR (msdos) one. If it's building an image that is not
UEFI-compatible it will always write an MBR label, regardless of
this setting.

If 'gpt_hybrid_mbr' is set, xorriso will write an Ubuntu-style
MBR/GPT hybrid partition table, where the MBR partition table
includes a partition with type 00 and the bootable flag, as well
as the partition with type ee required by the UEFI spec. This
mildly violates the UEFI spec but may make the image bootable on
native BIOS or CSM firmwares which refuse to boot from a disk with
no partition marked 'bootable' in the MBR. If 'gpt_hybrid_mbr' is
not set, xorriso will write a strictly UEFI-spec compliant label,
with just the 'protective MBR' required by the UEFI spec (no
bootable partition) and the correct GPT partition table. Note
this is somewhat different from what gpt_hybrid_mbr does for
disk images.

Also, we now pass -compliance no_emul_toc when building ISOs, as
recommended by upstream in
https://lists.gnu.org/archive/html/bug-xorriso/2024-11/msg00012.html
This tool is generally always going to be building ISOs intended
for write-once use, not multi-session use (and which are rarely,
these days, written to physical discs at all anyway).

Signed-off-by: Adam Williamson <[email protected]>
@Conan-Kudo Conan-Kudo merged commit 8b14c13 into OSInside:main Dec 13, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for building GPT-labelled ISOs with xorriso
3 participants