Comment 62 for bug 1899308

Revision history for this message
Thomas Schmitt (scdbackup) wrote :

Hi,

Steve Langasek (vorlon) wrote:
> I've manually run through the steps of casper's persistent partition
> creation [...]
> it also "fixes" the protective MBR, removing the empty bootable partition.

That explains why the machines which demand the boot flag boot exactly
once.

sudodus (nio-wiklund) wrote :
> p-ed-commands.txt

In the cases 4, 7, 11, 12, and 14 the bootable but nearly non-existing
partition has vanished, because its MBR slot became all 0.
This matches what Steve found out.

-----------------------------------------------------------------------

> https://code.launchpad.net/~ubuntu-installer/casper/+git/casper/+merge/392318

> sfdisk --no-reread -q $DEVICE -A 1 -X dos || true

If this attributes the boot flag to the first partion of type EE, then
this is a semi-violation of EFI specs and known to be punished by some
firmwares. UEFI 2.8 says:

  "Table 20. Protective MBR Partition Record protecting the entire disk
   BootIndicator 0 1 Set to 0x00 to indicate a non-bootable partition
                           [...]
                           Must be ignored by UEFI implementations."

It turned out back in 2015 that some EFIs interpret the latter statement
as instruction to ignore the device if BootIndicator is present in the
only existing partition. That's why --mbr-force-bootable was invented to
mark a nearly non-existent partition as bootable.

The changelog description is wrong in these aspects:

> "If our partition table is GPT, we *may* have a protective MBR;"

We *must* have a protective MBR to have a valid GPT.

> "we mark the iso9660 partition as bootable"

The ISO 9660 partition is number 1 in the GPT. Partition 1 in MBR is not
mountable as ISO 9660 because it starts at LBA 1. 0 or 64 would be ok for
mounting, but then it would not mark a valid GPT any more.

-----------------------------------------------------------------------

Casper needs to bring these bytes (decimal) into bytes 462 to 477 of
the ISO image (i.e. the MBR):

  128 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0

With bash i could do this by help of dd if=/dev/zero and echo -n $'\x80'
$'\x01'. But with dash ...

Would a temporary 16-byte binary file by acceptable for Casper ?

Extract it before manipulation of the original GPT of the ISO:

  dd if="$DEVICE" bs=1 skip=462 count=16 of=/tmp/boot_flag_bytes_$$

and instead of the sfdisk -A 1 -X dos, insert the extracted file:

  dd if=/tmp/boot_flag_bytes_$$ conv=notrunc bs=1 seek=462 of="$DEVICE"

-----------------------------------------------------------------------

Have a nice day :)

Thomas