[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-xorriso] PMBR sizing with appended_part_as=gpt
From: |
Paul Robins |
Subject: |
[Bug-xorriso] PMBR sizing with appended_part_as=gpt |
Date: |
Mon, 07 Jan 2019 23:34:19 +0000 |
Thomas et al,
I am attempting to duplicate the work done by grub-mkrescue, but
using xorriso directly and without its emulation mode. The purpose of
this is to attach a self-contained grub install to an appended
partition. I have encountered issues when adding appended_part_as=gpt
and believe I have isolated the cause of the problem. I also have a
couple of questions relating to an additional feature. I've managed to
get very close to my goal very quickly though thanks to your hard work.
The command I am using at the moment (tested on 1.5.0, 1.5.1 / HEAD):
xorriso -report_about ALL \
-compliance no_emul_toc \
-padding included \
-hfsplus on \
-outdev stdio:new.iso \
-map $PREFIX/ / \
-boot_image grub grub2_mbr=/usr/lib/grub/i386-pc/boot_hybrid.img \
-boot_image grub bin_path=/boot/grub/i386-pc/eltorito.img \
-boot_image grub grub2_boot_info=on \
-boot_image any next \
-boot_image grub apm_block_size=2048 \
-boot_image grub efi_path=/efi.img \
-boot_image grub efi_boot_part=--efi-boot-image \
-boot_image any appended_part_as=gpt \
-boot_image any appended_part_as=apm \
-append_partition 2 Linux tmpfs/partition
(I'm aware there are missing bless commands for apm, but for now I'm
just focusing on i386-pc, x86_64-efi and El Torito booting)
This seems to work correctly excepting for the addition of
appended_part_as=gpt. Whereas before the PMBR contained the appended
partition and thereby covered the entirety of the space the GPT did,
now the PMBR doesn't contain the appended partition, and the protective
partition entry is not extended to the end of the ISO.
Expected result:
MBR partition table: N Status Type Start Blocks
MBR partition : 1 0x00 0xee 1 10515971
Actual result:
MBR partition table: N Status Type Start Blocks
MBR partition : 1 0x00 0xee 1 2127363
There is code to do this in libisofs in a couple of places:
1. For isohybrid:
https://dev.lovelyhq.com/libburnia/libisofs/blob/master/libisofs/system_area.c#L2004-2009
2. When no requested MBR partitions:
https://dev.lovelyhq.com/libburnia/libisofs/blob/master/libisofs/system_area.c#L2054-2064
In this instance, the first will not fire as the bootloader is only
grub. The second instance appears as if it should fire, but due to a
code path called earlier, mbr_req is not actually empty, but already
includes a prototype PMBR that is set to the length of the ISO data,
not including the appended partition.
This mbr_req is created through the
partprepend_writer_compute_data_blocks call with the following stack
trace (running a bit of a hacked up version so apologies for the line
numbers):
#0 iso_quick_mbr_entry (req_array=0x5555555cb6c8,
mbr_req_count=0x5555555cb6e8, start_block=1, block_count=0,
type_byte=238 '\356', status_byte=0 '\000', desired_slot=0) at
libisofs/system_area.c:1094
#1 0x00007ffff7e3f2bd in partprepend_writer_compute_data_blocks
(writer=0x555555584d50) at libisofs/system_area.c:3065
#2 0x00007ffff7e1e63d in ecma119_image_new (src=0x55555556c2c0,
in_opts=0x5555555c9b60, img=0x7fffffffddc8) at libisofs/ecma119.c:3039
#3 0x00007ffff7e1f39d in iso_image_create_burn_source
(image=0x55555556c2c0, opts=0x5555555c9b60, burn_src=0x7fffffffde40) at
libisofs/ecma119.c:3449
#4 0x00007ffff7e97a88 in isoburn_prepare_disc_aux
(in_d=0x7ffff7d45660, out_d=0x7ffff7d45660, disc=0x7fffffffdf48,
opts=0x5555555e4c10, flag=0) at libisoburn/isoburn.c:652
#5 0x00007ffff7e97db2 in isoburn_prepare_disc (d=0x7ffff7d45660,
disc=0x7fffffffdf48, opts=0x5555555e4c10) at libisoburn/isoburn.c:716
#6 0x00007ffff7f3f671 in Xorriso_write_session
(xorriso=0x7ffff7f9a010, flag=0) at xorriso/write_run.c:1359
#7 0x00007ffff7ee977c in Xorriso_option_commit
(xorriso=0x7ffff7f9a010, flag=1) at xorriso/opts_a_c.c:2151
#8 0x00007ffff7eed531 in Xorriso_option_end (xorriso=0x7ffff7f9a010,
flag=2) at xorriso/opts_d_h.c:427
#9 0x000055555555562a in main (argc=41, argv=0x55555555a630) at
xorriso/xorriso_main.c:280
I have hoisted the conditional I highlighted in #2 above out of the
enclosing if statement and confirmed that it does produce an ISO with
the PMBR extended to the end of the appended partition which appears to
be UEFI compliant. I don't have a thorough enough knowledge of libisofs
to know whether that is an appropriate solution. I'd appreciate advice
on whether the mbr_req behaviour is as intended, or whether the data
block calculation side-effect is causing this failure.
In addition, I'd like to ask about a couple of features I'm interested
in adding. Specifically, I need the ability to align the appended
partition to a particular start position in order to ensure there is
some free space for the contents of the ISO, EFI etc... partitions to
grow. The intention behind this is to write the ISO to a USB stick and
at a later date (after a grub update for example) overwrite only the
portions of the USB at issue. Ultimately I need to have a unified image
which can be partially overwritten with updated versions.
As an add-on nicety to the above, it would be useful to be able to use
more than 4 GPT partitions, and set the type ID so I can implement the
Discoverable Partitions Specification (
https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
)
Hopefully you'd be amenable to these changes, and if you have
preferences on how they should be implemented, please let me know. I
hope the bug report above is correctly diagnosed, and if I can provide
any more info please let me know.
Thanks again!
- [Bug-xorriso] PMBR sizing with appended_part_as=gpt,
Paul Robins <=