grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grub-mkrescue: Problem with MBR partition table at start of EFI part


From: Thomas Schmitt
Subject: Re: grub-mkrescue: Problem with MBR partition table at start of EFI partition
Date: Thu, 25 Apr 2019 10:18:08 +0200

Hi,

Daniel Kiper wrote:
> How do you create USB stick from ISO image?

By plain copy to the base device, as usual for a grub-mkrescue ISO.
Like

  dd if=image of=usb_stick


> Have you tried latest Guix image?

Florian builds Guix ISOs locally. So i assume that it was newest Guix.
Nevertheless, the problem is clearly not in Guix content but in the
Start LBA 0 of the partition table entry inside the EFI partition image.


> Numbers here and in another email suggest that this is a floppy image.
> And floppy images do not have MBR. They have something called boot
> sector which is a bit different thing.

Yes. It already has been pointed out to me privately that it should
rather be called a "VBR".
But EFI specs talk of "MBR" in the System Partition. So i am in good
company. As mathematician i always agree to "If it walks like a duck ...".

UEFI 2.4, 12.3.1 "System Partition"

  "A System Partition supports backward compatibility with legacy systems
   by reserving the first block (sector) of the partition for compatibility
   code. On legacy systems, the first block (sector) of a partition is
   loaded into memory and execution is transferred to this code.
   EFI firmware does not execute the code in the MBR. The EFI firmware
   contains knowledge about the partition structure of various devices,
   and can understand legacy MBR, GPT, and “El Torito.”"

(The description of BIOS loading partition boot code is wrong. It is a
 class of device MBRs which contain code to chainload partition boot code.
 I guess, GRUB has such an MBR variant in its collection, too.)

The last sentence might mean that EFI shall support extended MBR partitions.
I doubt that it is an invitation to support a tree of partition tables with
arbitrary tree width.
I also doubt that the author had a mental relapse to the MBR of the device,
which is mentioned in the paragraph before the one above.

  "A System Partition is a partition in the conventional sense of a
   partition on a legacy system. For a hard disk, a partition is a
   contiguous grouping of sectors on the disk where the starting sector
   and size are defined by the Master Boot Record (MBR), which resides
   on LBA 0 (i.e., the first sector of the hard disk) (see Section 5.2),
   or the GUID Partition Table (GPT), which resides on logical block 1
   (the second sector of the hard disk) (see Section 5.3.1). For a
   diskette (floppy) drive, a partition is defined to be the entire media.
   A System Partition can reside on any media that is supported by EFI
   Boot Services."


> I have a feeling that simply Macs
> tested by you does not like floppy images. If you create regular HDD
> images then probably everything will work.

It was grub-mkrescue which created that floppy image by mformat
and submits it to xorriso as EFI partition.

My questions were whether the partition entry is necessary (Vladimir
expects that it is not), and whether an MBR signature and the other
fields in block 0 are needed, which mformat creates without option -k
(Vladimir's answer was less firm).

I am now proposing to Guix to use my script-in-the middle

  
https://dev.lovelyhq.com/libburnia/libisoburn/raw/master/frontend/grub-mkrescue-sed.sh

which is submitted to grub-mkrescue by option --xorriso=.

Its main purpose is to achieve other partition layouts with mountable
ISO partition. Meanwhile it learned how to zeroize the partition table
in the EFI partition and, if desired additionally, to zeroize the MBR
signature of the partition.

Be invited to try with a BIOS and EFI enabled GRUB configuration:

  wget 
https://dev.lovelyhq.com/libburnia/libisoburn/raw/master/frontend/grub-mkrescue-sed.sh
  chmod u+x grub-mkrescue-sed.sh

  export MKRESCUE_SED_MODE=mbr_hfs
  export MKRESCUE_SED_IN_EFI_NO_PT=yes

  grub-mkrescue --xorriso=./grub-mkrescue-sed.sh \
                -iso_mbr_part_type 0x83 -partition_offset 16 \
                ...your usual options to grub-mkrescue...

(  export MKRESCUE_SED_DEBUG=yes
 would let the script print input xorriso arguments and the arguments
 which it actually hands over to xorriso.)

The result has this partition layout:

  $ /sbin/fdisk -l output.iso
  ...
  Disklabel type: dos
  ...
  Device      Boot Start   End Sectors  Size Id Type
  output.iso1 *       64 28695   28632   14M 83 Linux
  output.iso2      28696 34455    5760  2.8M ef EFI (FAT-12/16/32)

Advantages in my eyes are:

- No GPT backup which will be misplaced on USB stick after dd.
  (Linux and partition editors complain.)

- Mountable ISO partition with non-zero partition start for pleasing
  partition editors and  being able to claim partition 2 as part of the
  filesystem range of the base device ISO:
     $ expr $(/sbin/isosize /dev/sdc) / 512
     34456
     $ expr $(/sbin/isosize /dev/sdc1) / 512
     28632
  This maintains the property of the original grub-mkrescue GPT layout,
  that an ISO image on a USB stick or DVD+RW still can tell its original
  size for checksumming.

- It is supposed to boot on Florian's Macbook because of no partition table
  in the EFI partition. (I'm not sure whether Florian aready tested it.
  Our test results are from byte hacking experiments on a vanilla Guix ISO.)


Have a nice day :)

Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]