Skip to contentSkip to conversation

Does grub-mkrescue support UEFI hybrid USB/DVD images?

DISCUSSION Kris Moore 5 participants 17 messages Jan 22, 2015 – Jan 25, 2015

lore
Share & tools
lore

Kris Moore

author
#0 lore raw

Hey all,

We are trying to create hybrid USB/DVD images, and they work just fine on BIOS. However it doesn't seem to work when creating UEFI.

We are using the following:

# grub-mkrescue -d "/usr/local/lib/grub/x86_64-efi" -o <outfile> <dir>
-- -volid "OURLABEL"

This image does boot UEFI via DVD, but when copied to a USB stick with dd it fails to boot with the following:

error: disk `' not found.
entering rescue mode...

From there we can do a listing and set root / prefix to the correct locations, and load normal just fine. However most users won't want to do that.

Are there some special flags / magic we need to use for mkrescue to do this?

I see in the output that it is loading part_apple modules, but this is built on a FreeBSD system, does that have anything to do with it?

-- Full verbose output of mkrescue follows --

7,314 lines not shown · raw message

Part of this message is not shown here. View the raw message.

#1 lore raw
Quoted 6 lines · Kris Moore

Hey all,

We are trying to create hybrid USB/DVD images, and they work just fine on BIOS. However it doesn't seem to work when creating UEFI.

Try this:

grub-core/disk/efi/efidisk.c +1 -3
index 3b12c34..983afdb 100644
@@ -862,9 +862,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
          if (! ctx.partition_name)
            {
              grub_disk_close (parent);
-             if (is_cdrom)
-               return grub_strdup (device_name);
-             return 0;
+             return grub_strdup (device_name);
            }
 
          dev_name = grub_xasprintf ("%s,%s", parent->name,
#2 lore raw
Quoted 13 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 6 lines · Kris Moore

Hey all,

We are trying to create hybrid USB/DVD images, and they work just fine on BIOS. However it doesn't seem to work when creating UEFI.

Try this:

grub-core/disk/efi/efidisk.c +0 -0
index 3b12c34..983afdb 100644

grub-core/disk/efi/efidisk.c grub_efidisk_get_device_name (grub_efi_handle_t *handle) · line 865

Quoted 7 lines
grub-core/disk/efi/efidisk.c +1 -3
@@ -862,9 +862,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
          if (! ctx.partition_name)
            {
              grub_disk_close (parent);
-             if (is_cdrom)
-               return grub_strdup (device_name);
-             return 0;
+             return grub_strdup (device_name);

How is it possible? So we have EFI device path that refers to partition (or at least to something that does not start on device first block) but grub does not see this partition? In case of CD-ROM this happens because CD-ROM media subtype actually refers to ESP and so points inside CD-ROM. But how it can happen for hard disk?

Kris, could you add output of device path (grub_efi_print_device_path) at the beginning?

Quoted 11 lines
grub-core/disk/efi/efidisk.c +0 -0
            }
 
          dev_name = grub_xasprintf ("%s,%s", parent->name,

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
Quoted 20 lines · Andrei Borzenkov
Quoted 18 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 6 lines · Kris Moore

Hey all,

We are trying to create hybrid USB/DVD images, and they work just fine on BIOS. However it doesn't seem to work when creating UEFI.

Try this:

grub-core/disk/efi/efidisk.c +0 -2
index 3b12c34..983afdb 100644
@@ -862,9 +862,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
          if (! ctx.partition_name)
            {
              grub_disk_close (parent);
-             if (is_cdrom)
-               return grub_strdup (device_name);
Quoted 9 lines

grub-core/disk/efi/efidisk.c grub_efidisk_get_device_name (grub_efi_handle_t *handle) · line 865

Quoted 2 lines
grub-core/disk/efi/efidisk.c +1 -1
-             return 0;
+             return grub_strdup (device_name);

How is it possible? So we have EFI device path that refers to partition (or at least to something that does not start on device first block) but grub does not see this partition? In case of CD-ROM this happens because CD-ROM media subtype actually refers to ESP and so points inside CD-ROM. But how it can happen for hard disk?

I think his EFI uses eltorito even from the stick. In that case we end up in exactly the same scenario as CD-ROM.

Quoted 21 lines

Kris, could you add output of device path (grub_efi_print_device_path) at the beginning?

Quoted 11 lines
grub-core/disk/efi/efidisk.c +0 -0
            }
 
          dev_name = grub_xasprintf ("%s,%s", parent->name,

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw
Quoted 30 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 20 lines · Andrei Borzenkov
Quoted 18 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 6 lines · Kris Moore

Hey all,

We are trying to create hybrid USB/DVD images, and they work just fine on BIOS. However it doesn't seem to work when creating UEFI.

Try this:

grub-core/disk/efi/efidisk.c +0 -2
index 3b12c34..983afdb 100644
@@ -862,9 +862,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
          if (! ctx.partition_name)
            {
              grub_disk_close (parent);
-             if (is_cdrom)
-               return grub_strdup (device_name);
Quoted 9 lines

grub-core/disk/efi/efidisk.c grub_efidisk_get_device_name (grub_efi_handle_t *handle) · line 865

Quoted 2 lines
grub-core/disk/efi/efidisk.c +1 -1
-             return 0;
+             return grub_strdup (device_name);

How is it possible? So we have EFI device path that refers to partition (or at least to something that does not start on device first block) but grub does not see this partition? In case of CD-ROM this happens because CD-ROM media subtype actually refers to ESP and so points inside CD-ROM. But how it can happen for hard disk?

Quoted 2 lines

I think his EFI uses eltorito even from the stick. In that case we end up in exactly the same scenario as CD-ROM.

That's fine but then I expect CD-ROM subtype. I'd love to see full device path.

Quoted 29 lines
Quoted 16 lines

Kris, could you add output of device path (grub_efi_print_device_path) at the beginning?

Quoted 11 lines
grub-core/disk/efi/efidisk.c +0 -0
            }
 
          dev_name = grub_xasprintf ("%s,%s", parent->name,

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#5 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko

Hi,

Quoted 2 lines · Vladimir

I think his EFI uses eltorito even from the stick. In that case we end up in exactly the same scenario as CD-ROM.

This contradicts all my beliefs about El Torito (and several wikis where i published them).

I would like to see this theory verified:

The first experiment would be to remove MBR and GPT. If the theory is right, then it should still boot. Next one should remove the El Torito catalog entry for the EFI boot image and check whether it does not boot any more.
Finally it would be interesting to see whether it boots if the EFI boot image is only represented by MBR+GPT but not by El Torito.

-----------------------------------------------------
To Kris Moore:

If Vladimir's patch does fix the problem, then i would be willing to patch such an improved ISO to the experimental forms mentioned above. Just give me a download URL. I will then determine the necessary dd commands for you to execute. (Small ISO preferred.)

Have a nice day :)

Thomas

author
#6 lore raw
Quoted 31 lines · Thomas Schmitt

Hi,

Quoted 2 lines · Vladimir

I think his EFI uses eltorito even from the stick. In that case we end up in exactly the same scenario as CD-ROM.

This contradicts all my beliefs about El Torito (and several wikis where i published them).

I would like to see this theory verified:

The first experiment would be to remove MBR and GPT. If the theory is right, then it should still boot. Next one should remove the El Torito catalog entry for the EFI boot image and check whether it does not boot any more.
Finally it would be interesting to see whether it boots if the EFI boot image is only represented by MBR+GPT but not by El Torito.

-----------------------------------------------------
To Kris Moore:

If Vladimir's patch does fix the problem, then i would be willing to patch such an improved ISO to the experimental forms mentioned above. Just give me a download URL. I will then determine the necessary dd commands for you to execute. (Small ISO preferred.)

Have a nice day :)

Quoted 7 lines

Thomas

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Vladimir's patch did fix the issue here, thanks!

Thomas,

Here's a very small ISO, no kernel or anything, around 40MB.

www.pcbsd.org/~kris/test-efigrub.iso

Signature · 3 lines
Kris Moore
PC-BSD Software
iXsystems
#7 lore raw

Hi,

i inspect the image by

  xorriso-1.3.8 -indev test-efigrub.iso \
                -report_el_torito plain \
                -report_system_area plain

and get

Boot record : El Torito , MBR protective-msdos-label cyl-align-off GPT APM
...
Volume id : 'PCBSD_INSTALL'
El Torito catalog : 1763 1
El Torito cat path : /boot.catalog

  El Torito images   :   N  Pltf  B   Emul  Ld_seg  Hdpt  Ldsiz         LBA
  El Torito boot img :   1  UEFI  y   none  0x0000  0x00   5760         140
  El Torito img path :   1  /efi.img
  System area options: 0x00000201
  System area summary: MBR protective-msdos-label cyl-align-off GPT APM
  ISO image size/512 : 81552
  Partition offset   : 0
  MBR heads per cyl  : 64
  MBR secs per head  : 32
  MBR partition table:   N Status  Type        Start       Blocks
  MBR partition      :   1   0x00  0xee            1        81551
  GPT                :   N  Info
  GPT disk GUID      :      70e9427b66c1b744b42113c17b268b07
  GPT entry array    :      20  176  separated
  GPT lba range      :      64  81506  81551
  GPT partition name :   1  4700610070003000
  GPT partname local :   1  Gap0
  GPT partition GUID :   1  70e9427b66c1b744b42213c17b268b07
  GPT type GUID      :   1  a2a0d0ebe5b9334487c068b6b72699c7
  GPT partition flags:   1  0x1000000000000001
  GPT start and size :   1  64  496
  GPT partition name :   2  450046004900200062006f006f007400200070006100720074006900740069006f006e00
  GPT partname local :   2  EFI boot partition
  GPT partition GUID :   2  70e9427b66c1b744b42313c17b268b07
  GPT type GUID      :   2  28732ac11ff8d211ba4b00a0c93ec93b
  GPT partition flags:   2  0x1000000000000001
  GPT start and size :   2  560  5760
  GPT partition path :   2  /efi.img
  GPT partition name :   3  4700610070003100
  GPT partname local :   3  Gap1
  GPT partition GUID :   3  70e9427b66c1b744b42013c17b268b07
  GPT type GUID      :   3  a2a0d0ebe5b9334487c068b6b72699c7
  GPT partition flags:   3  0x1000000000000001
  GPT start and size :   3  6320  75184
  APM                :   N  Info
  APM block size     :      2048
  APM gap fillers    :      2
  APM partition name :   1  Gap0
  APM partition type :   1  ISO9660_data
  APM start and size :   1  16  1564
  APM partition name :   2  HFSPLUS_Hybrid
  APM partition type :   2  Apple_HFS
  APM start and size :   2  1580  18646
  APM partition name :   3  Gap1
  APM partition type :   3  ISO9660_data
  APM start and size :   3  20226  162

So we have no entry points for BIOS but only for EFI. Those, nevertheless, are plenty. :))

--------------------------------------------------------------------
Experiment 1: Remove MBR, GPT, APM, and backup GPT. (by zeroizing the whole ISO System Area and the last 512-block)

cp test-efigrub.iso test.iso
dd if=/dev/zero conv=notrunc bs=512 count=64 of=test.iso dd if=/dev/zero conv=notrunc bs=512 seek=81551 count=1 of=test.iso

Inspection shows:

El Torito catalog : 1763 1
El Torito cat path : /boot.catalog

  El Torito images   :   N  Pltf  B   Emul  Ld_seg  Hdpt  Ldsiz         LBA
  El Torito boot img :   1  UEFI  y   none  0x0000  0x00   5760         140
  El Torito img path :   1  /efi.img

xorriso : NOTE : No System Area was loaded

So if this boots, the firmware either really used El Torito, or it recognizes /efi.img as boot image by some naming rule.

--------------------------------------------------------------------
Experiment 2: Remove El Torito too.
(by moving the Volume Descriptor Set Terminator to the position of
the Boot Record)

  # using test.iso as emerged from experiment 1
  dd if=test-efigrub.iso bs=2048 count=1 skip=18 | \
    dd conv=notrunc bs=2048 count=1 seek=17 of=test.iso

Inspection shows:

Volume id : 'PCBSD_INSTALL'
xorriso : NOTE : No El Torito information was loaded xorriso : NOTE : No System Area was loaded

If this still boots, then EFI finds /efi.img by miracle.

--------------------------------------------------------------------
Experiment 3: Remove El Torito but keep MBR, GPT, APM. (by moving the Volume Descriptor Set Terminator to the position of
the Boot Record)

  cp test-efigrub.iso test.iso
  dd if=test-efigrub.iso bs=2048 count=1 skip=18 | \
    dd conv=notrunc bs=2048 count=1 seek=17 of=test.iso

Inspection:

Boot record : (system area only) , MBR protective-msdos-label cyl-align-off GPT APM
...
Volume id : 'PCBSD_INSTALL'
xorriso : NOTE : No El Torito information was loaded
System area options: 0x00000201
System area summary: MBR protective-msdos-label cyl-align-off GPT APM ISO image size/512 : 81552

  Partition offset   : 0
  MBR heads per cyl  : 64
  MBR secs per head  : 32
  MBR partition table:   N Status  Type        Start       Blocks
  MBR partition      :   1   0x00  0xee            1        81551
  GPT                :   N  Info
  GPT disk GUID      :      70e9427b66c1b744b42113c17b268b07
  GPT entry array    :      20  176  separated
  GPT lba range      :      64  81506  81551
  GPT partition name :   1  4700610070003000
  GPT partname local :   1  Gap0
  GPT partition GUID :   1  70e9427b66c1b744b42213c17b268b07
  GPT type GUID      :   1  a2a0d0ebe5b9334487c068b6b72699c7
  GPT partition flags:   1  0x1000000000000001
  GPT start and size :   1  64  496
  GPT partition name :   2  450046004900200062006f006f007400200070006100720074006900740069006f006e00
  GPT partname local :   2  EFI boot partition
  GPT partition GUID :   2  70e9427b66c1b744b42313c17b268b07
  GPT type GUID      :   2  28732ac11ff8d211ba4b00a0c93ec93b
  GPT partition flags:   2  0x1000000000000001
  GPT start and size :   2  560  5760
  GPT partition path :   2  /efi.img
  GPT partition name :   3  4700610070003100
  GPT partname local :   3  Gap1
  GPT partition GUID :   3  70e9427b66c1b744b42013c17b268b07
  GPT type GUID      :   3  a2a0d0ebe5b9334487c068b6b72699c7
  GPT partition flags:   3  0x1000000000000001
  GPT start and size :   3  6320  75184
  APM                :   N  Info
  APM block size     :      2048
  APM gap fillers    :      2
  APM partition name :   1  Gap0
  APM partition type :   1  ISO9660_data
  APM start and size :   1  16  1564
  APM partition name :   2  HFSPLUS_Hybrid
  APM partition type :   2  Apple_HFS
  APM start and size :   2  1580  18646
  APM partition name :   3  Gap1
  APM partition type :   3  ISO9660_data
  APM start and size :   3  20226  162

So if this does not boot, then El Torito is indeed needed even on USB stick.

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

One could also remove APM and/or GPT to lure EFI into GPT or MBR. All in all 16 combinations of El Torito, MBR, GPT, and APM are possible. We'd need to zeroize the System Area more selectively to zapp particular table types.

Have a nice day :)

Thomas

#8 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko

В Fri, 23 Jan 2015 10:45:08 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 30 lines · Andrei Borzenkov
Quoted 20 lines
Quoted 18 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 6 lines · Kris Moore

Hey all,

We are trying to create hybrid USB/DVD images, and they work just fine on BIOS. However it doesn't seem to work when creating UEFI.

Try this:

grub-core/disk/efi/efidisk.c +0 -2
index 3b12c34..983afdb 100644
@@ -862,9 +862,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
          if (! ctx.partition_name)
            {
              grub_disk_close (parent);
-             if (is_cdrom)
-               return grub_strdup (device_name);
Quoted 9 lines

grub-core/disk/efi/efidisk.c grub_efidisk_get_device_name (grub_efi_handle_t *handle) · line 865

Quoted 2 lines
grub-core/disk/efi/efidisk.c +1 -1
-             return 0;
+             return grub_strdup (device_name);

How is it possible? So we have EFI device path that refers to partition (or at least to something that does not start on device first block) but grub does not see this partition? In case of CD-ROM this happens because CD-ROM media subtype actually refers to ESP and so points inside CD-ROM. But how it can happen for hard disk?

Quoted 2 lines

I think his EFI uses eltorito even from the stick. In that case we end up in exactly the same scenario as CD-ROM.

Not eltorito, but normal ESP.

Media paths

Handle 0x2f241518
/ACPI(a0341d0,0)/PCI(0,4)/HD(1,40,8c,8678dcb08dcc6944,2,2)/EndEntire disk
block
device path
Handle 0x2f241298
/ACPI(a0341d0,0)/PCI(0,4)/HD(2,cc,1680,8678dcb08dcc6944,2,2)/EndEntire simple FS
disk
c12a7328-f81f-11d2-ba4b-00a0c93ec93b
block
device path
Handle 0x2f241018
/ACPI(a0341d0,0)/PCI(0,4)/HD(3,174c,3548,8678dcb08dcc6944,2,2)/EndEntire disk
block
device path

All of them match existing partitions. EFI boots from ESP as it should. Boot path grub gets

/ACPI(a0341d0,0)/PCI(0,4)/HD(2,cc,1680,8678dcb08dcc6944,2,2)/EndEntire

which matches ESP. The reason it is not found at startup is missing part_gpt:

grub rescue> ls
(hd0) (hd0,apple4) (hd0,apple3) (hd0,apple2) (hd0,apple1) (fd0) (fd1) (cd0)

After adjusting prefix:

grub> insmod part_gpt
grub> ls
(proc) (hd0) (hd0,apple4) (hd0,apple3) (hd0,apple2) (hd0,apple1) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (fd0) (fd1) (cd0)

But returning (hd0,gpt2) would also be wrong here - ESP on CD image is empty, we need to somehow jump from ESP to full ISO image.

So I guess your patch is the least evil. I will add some comments to grub_efidisk_get_device_name() and grub-mkrescue to explain what happens here after you push it.

#9 lore raw
Quoted 4 lines

But returning (hd0,gpt2) would also be wrong here - ESP on CD image is empty, we need to somehow jump from ESP to full ISO image.

Returning hd0,gpt2 is fine. By convention ()/file refers to parent disk of whatever root partition is (as opposed to /file).
So just including part_gpt in core should be enough. But perhaps we should put my patch as well to increase reliability. Consider scenario of installing on disk with gpt and apt and using apt partitions. GRUB will properly detect that it needs part_apple but part_gpt is not needed to access partition.
Most of the install tools specify partition explicitly, so having partition is non-critical. Having disk on the hand is critical.

@Kris: Please try (after removing the other patch)

util/grub-mkrescue.c +3 -0
index e719839..e02340f 100644
@@ -653,6 +653,9 @@ main (int argc, char *argv[])
       char *efiimgfat;
       grub_install_mkdir_p (efidir_efi_boot);
 
+      grub_install_push_module ("part_gpt");
+      grub_install_push_module ("part_msdos");
+
       imgname = grub_util_path_concat (2, efidir_efi_boot, "bootia64.efi");
       make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_IA64_EFI,
"ia64-efi", imgname);
       free (imgname);
@@ -713,6 +716,8 @@ main (int argc, char *argv[])
       free (efiimgfat);
       free (efidir_efi);
       free (efidir);
+      grub_install_pop_module ();
+      grub_install_pop_module ();
     }
   grub_install_push_module ("part_apple");
#10 lore raw

В Fri, 23 Jan 2015 19:29:07 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 6 lines
Quoted 4 lines

But returning (hd0,gpt2) would also be wrong here - ESP on CD image is empty, we need to somehow jump from ESP to full ISO image.

Returning hd0,gpt2 is fine. By convention ()/file refers to parent disk of whatever root partition is (as opposed to /file).

Not sure I follow. If you include part_gpt, grub will set prefix to (hd0,gpt2)/boot/grub. But /boot/grub does NOT exist there - it exists on (hd0), so correct prefix is (hd0)/boot/grub.

Quoted 35 lines

So just including part_gpt in core should be enough. But perhaps we should put my patch as well to increase reliability. Consider scenario of installing on disk with gpt and apt and using apt partitions. GRUB will properly detect that it needs part_apple but part_gpt is not needed to access partition.
Most of the install tools specify partition explicitly, so having partition is non-critical. Having disk on the hand is critical.

@Kris: Please try (after removing the other patch)

util/grub-mkrescue.c +3 -0
index e719839..e02340f 100644
@@ -653,6 +653,9 @@ main (int argc, char *argv[])
       char *efiimgfat;
       grub_install_mkdir_p (efidir_efi_boot);
 
+      grub_install_push_module ("part_gpt");
+      grub_install_push_module ("part_msdos");
+
       imgname = grub_util_path_concat (2, efidir_efi_boot, "bootia64.efi");
       make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_IA64_EFI,
 "ia64-efi", imgname);
       free (imgname);
util/grub-mkrescue.c +2 -0
@@ -713,6 +716,8 @@ main (int argc, char *argv[])
       free (efiimgfat);
       free (efidir_efi);
       free (efidir);
+      grub_install_pop_module ();
+      grub_install_pop_module ();
     }
 
   grub_install_push_module ("part_apple");
#11 lore raw

В Fri, 23 Jan 2015 21:38:27 +0300
Andrei Borzenkov <[email protected]> пишет:

Quoted 7 lines

В Fri, 23 Jan 2015 19:29:07 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 4 lines
Quoted 4 lines

But returning (hd0,gpt2) would also be wrong here - ESP on CD image is empty, we need to somehow jump from ESP to full ISO image.

Quoted 7 lines
Quoted 2 lines

Returning hd0,gpt2 is fine. By convention ()/file refers to parent disk of whatever root partition is (as opposed to /file).

Not sure I follow. If you include part_gpt, grub will set prefix to (hd0,gpt2)/boot/grub. But /boot/grub does NOT exist there - it exists on (hd0), so correct prefix is (hd0)/boot/grub.

Ah, OK, I see. Sorry.

Quoted 9 lines
Quoted 9 lines

So just including part_gpt in core should be enough. But perhaps we should put my patch as well to increase reliability. Consider scenario of installing on disk with gpt and apt and using apt partitions. GRUB will properly detect that it needs part_apple but part_gpt is not needed to access partition.
Most of the install tools specify partition explicitly, so having partition is non-critical. Having disk on the hand is critical.

@Kris: Please try (after removing the other patch)

Yes, it works.

Quoted 27 lines
Quoted 26 lines
util/grub-mkrescue.c +3 -0
index e719839..e02340f 100644
@@ -653,6 +653,9 @@ main (int argc, char *argv[])
       char *efiimgfat;
       grub_install_mkdir_p (efidir_efi_boot);
 
+      grub_install_push_module ("part_gpt");
+      grub_install_push_module ("part_msdos");
+
       imgname = grub_util_path_concat (2, efidir_efi_boot, "bootia64.efi");
       make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_IA64_EFI,
 "ia64-efi", imgname);
       free (imgname);
util/grub-mkrescue.c +2 -0
@@ -713,6 +716,8 @@ main (int argc, char *argv[])
       free (efiimgfat);
       free (efidir_efi);
       free (efidir);
+      grub_install_pop_module ();
+      grub_install_pop_module ();
     }
 
   grub_install_push_module ("part_apple");
#12 lore raw
In reply to Andrei Borzenkov

Hi,

Quoted 1 line · Andrei Borzenkov

Not eltorito, but normal ESP.

That's somewhat appeasing.

Quoted 2 lines

returning (hd0,gpt2) would also be wrong here - ESP on CD image is empty, we need to somehow jump from ESP to full ISO image.

One could allow nested partitions and put whole-ISO partitions into the various tables. Debian "amd64" ISOs do it that way. They boot on BIOS via ISOLINUX and on EFI via GRUB2.

  MBR partition table:   N Status  Type        Start       Blocks
  MBR partition      :   1   0x80  0x00            0       454656
  MBR partition      :   2   0x00  0xef         3440          896
  MBR partition path :   2  /boot/grub/efi.img
  ...
  GPT partname local :   1  ISOHybrid
  ...
  GPT start and size :   1  0  454600
  ...
  GPT partname local :   2  ISOHybrid1
  ...
  GPT start and size :   2  3440  896
  GPT partition path :   2  /boot/grub/efi.img

MBR partition 1 and GPT partition 1 cover the whole ISO. Partitions 2 mark the ESP.

But Vladimir is clearly opposed to nested or overlapping partitions. And all partition editors seem to join his opinion.

Have a nice day :)

Thomas

#13 lore raw
In reply to Kris Moore
Quoted 6 lines · Kris Moore

Hey all,

We are trying to create hybrid USB/DVD images, and they work just fine on BIOS. However it doesn't seem to work when creating UEFI.

Quoted 7 lines

We are using the following:

# grub-mkrescue -d "/usr/local/lib/grub/x86_64-efi" -o <outfile> <dir>
-- -volid "OURLABEL"

This image does boot UEFI via DVD, but when copied to a USB stick with dd it fails to boot with the following:

Hi,

I'm going to describe what I use for making a USB/CDROM EFI/x86
hybrid image for building SG2D (An improved Grub2 Disk).

But my question (after reading other replies to this question) is why
Grub2 should be patched for what he wants ? Is it a non standard EFI boot maybe?

Thank you.

Debian way
==========

Install these two packages:

grub-efi-amd64-bin
grub-pc-bin

Run:

grub-mkrescue -o ./my_grub.iso

Upstream way (I actually want to ask here if this recipe could be
improved, but that would be probably need another email thread)
============

Make sure no Debian grub package is found in chroot

apt-get remove '.grub.'
Grub2 (efi+pc)) Build and installation

# Make sure we are testing the right revision
mkdir grub_upstream
cd grub_upstream
git clone git://git.savannah.gnu.org/grub.git .
git checkout COMMIT-TO-TEST
# Remove any non git related file - BEGIN
git reset --hard
git clean -f -d
git clean -f -x -d

# Remove any non git related file - END
# Build efi based grub and install it - BEGIN
./autogen.sh && ./configure --enable-grub-mkfont --with-platform=efi && make # Dont forget to delete any rest of previous installation - BEGIN
sudo rm -rf /usr/local/etc/grub.d/ /usr/local/bin/grub-* /usr/local/share/grub/ # Dont forget to delete any rest of previous installation - END
sudo make install
# Build efi based grub and install it - END
make clean # Prepare for next build
./configure --enable-grub-mkfont --with-platform=pc && make # Prepare for a i386 build sudo make install # Install i386 build

TL;DR: Make sure no Grub Debian package is installed, install grub twice, one configured for x86, the other one configured for efi. Then grub-mkrescue detects both modules and adds to the final image which by default is ISO/USB hybrid.

By the way. I was told how to build the image without doing make install (thus not having to remove any Debian Grub package) so I might re-adapt this recipe in the future.

grub-mkrescue -o ./my_grub.iso

adrian15

Signature · 1 line
Support free software. Donate to Super Grub Disk. Apoya el software libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
#14 lore raw
Quoted 20 lines · El 24/01/15 a las 01:12, adrian15 escribió:
Quoted 6 lines · Kris Moore

Hey all,

We are trying to create hybrid USB/DVD images, and they work just fine on BIOS. However it doesn't seem to work when creating UEFI.

Quoted 7 lines

We are using the following:

# grub-mkrescue -d "/usr/local/lib/grub/x86_64-efi" -o <outfile> <dir>
-- -volid "OURLABEL"

This image does boot UEFI via DVD, but when copied to a USB stick with dd it fails to boot with the following:

Hi,

I'm going to describe what I use for making a USB/CDROM EFI/x86
hybrid image for building SG2D (An improved Grub2 Disk).

Quoted 8 lines

But my question (after reading other replies to this question) is why
Grub2 should be patched for what he wants ? Is it a non standard EFI boot maybe?

   Thank you.

   Debian way
   ==========

I just wanted to say that recipe does not produce an image that can be booted from UEFI hard disk.

I had assumed all this time that it worked (I only tested the EFI CDROM boot) because if you read it here:

https://www.gnu.org/software/grub/manual/html_node/Making-a-GRUB-bootable-CD_002dROM.html#Making-a-GRUB-bootable-CD_002dROM

grub-mkrescue -o grub.iso iso
This produces a file named grub.iso, which then can be burned into a CD (or a DVD), or written to a USB mass storage device.

So, if I'm not mistaken that's not true when you boot from EFI (Well, I know that you are fixing it on this thread).

adrian15

Signature · 1 line
Support free software. Donate to Super Grub Disk. Apoya el software libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
#15 lore raw
Quoted 40 lines · El 25/01/15 a las 09:03, adrian15 escribió:
Quoted 20 lines · El 24/01/15 a las 01:12, adrian15 escribió:
Quoted 6 lines · Kris Moore

Hey all,

We are trying to create hybrid USB/DVD images, and they work just fine on BIOS. However it doesn't seem to work when creating UEFI.

Quoted 7 lines

We are using the following:

# grub-mkrescue -d "/usr/local/lib/grub/x86_64-efi" -o <outfile> <dir>
-- -volid "OURLABEL"

This image does boot UEFI via DVD, but when copied to a USB stick with dd it fails to boot with the following:

Hi,

I'm going to describe what I use for making a USB/CDROM EFI/x86
hybrid image for building SG2D (An improved Grub2 Disk).

Quoted 8 lines

But my question (after reading other replies to this question) is why
Grub2 should be patched for what he wants ? Is it a non standard EFI boot maybe?

   Thank you.

   Debian way
   ==========

I just wanted to say that recipe does not produce an image that can be booted from UEFI hard disk.

I had assumed all this time that it worked (I only tested the EFI CDROM boot) because if you read it here:

https://www.gnu.org/software/grub/manual/html_node/Making-a-GRUB-bootable-CD_002dROM.html#Making-a-GRUB-bootable-CD_002dROM

Quoted 8 lines

grub-mkrescue -o grub.iso iso
This produces a file named grub.iso, which then can be burned into a CD (or a DVD), or written to a USB mass storage device.

So, if I'm not mistaken that's not true when you boot from EFI (Well, I know that you are fixing it on this thread).

adrian15

(Hopefully I'm not creating new threads when replying)

I had only tested 2.00 version (Where the hard disk is not detected as an EFI boot at all). My 2.02 version from GIT (old commit bac5d1a64ab4191058a8fd4c05f6b3b339e249e7) gives the same result as the OP:

error: disk `' not found.
Entering rescue mode...
grub rescue>

So I'll try the suggested patch and reply to the email which announced it so that you can get more than one feedback from it.

I guess that in grub 2.02 you made sure that image produced from grub-mkrescue would boot from UEFI hard disk but somehow somewhere a regression was introduced.

In any case anyone is wondering I have made my UEFI boot tests thanks to:
kvm -bios /usr/share/ovmf/OVMF.fd -boot c -hda super_grub2_disk_hybrid_2.02s1-beta1.iso

adrian15

Signature · 1 line
Support free software. Donate to Super Grub Disk. Apoya el software libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
#16 lore raw
Quoted 22 lines · El 25/01/15 a las 09:15, adrian15 escribió:
Quoted 3 lines · El 25/01/15 a las 09:03, adrian15 escribió:
Quoted 2 lines · El 24/01/15 a las 01:12, adrian15 escribió:
Quoted 1 line · Kris Moore

(Hopefully I'm not creating new threads when replying)

I had only tested 2.00 version (Where the hard disk is not detected as an EFI boot at all). My 2.02 version from GIT (old commit bac5d1a64ab4191058a8fd4c05f6b3b339e249e7) gives the same result as the OP:

error: disk `' not found.
Entering rescue mode...
grub rescue>

So I'll try the suggested patch and reply to the email which announced it so that you can get more than one feedback from it.

I guess that in grub 2.02 you made sure that image produced from grub-mkrescue would boot from UEFI hard disk but somehow somewhere a regression was introduced.

Quoted 5 lines

In any case anyone is wondering I have made my UEFI boot tests thanks to:
kvm -bios /usr/share/ovmf/OVMF.fd -boot c -hda super_grub2_disk_hybrid_2.02s1-beta1.iso

adrian15

I confirm you that using current GIT head as a base (commit dd430afbf874f6212742c079d72b4b9e959e0542) my steps for making two-dimensional hybrid disk (Both CDROM / Harddisk and BIOS / EFI) seem to work ok.

So I confirm that you have succesfully fixed the problem about grub rescue not finding grub device which the OP reported.

I paste here my steps here again (I know the steps can be improved).

How do I build and prepare my system
------------------------------------
Make sure no Debian grub package is found in chroot

apt-get remove '.grub.'
Grub2 (efi+pc)) Build and installation

# Make sure we are testing the right revision
mkdir grub_upstream
cd grub_upstream
git clone git://git.savannah.gnu.org/grub.git .
git checkout COMMIT-TO-TEST
# Remove any non git related file - BEGIN
git reset --hard
git clean -f -d
git clean -f -x -d

# Remove any non git related file - END
# Build efi based grub and install it - BEGIN
./autogen.sh && ./configure --enable-grub-mkfont --with-platform=efi && make # Dont forget to delete any rest of previous installation - BEGIN
sudo rm -rf /usr/local/etc/grub.d/ /usr/local/bin/grub-* /usr/local/share/grub/ # Dont forget to delete any rest of previous installation - END
sudo make install
# Build efi based grub and install it - END
make clean # Prepare for next build
./configure --enable-grub-mkfont --with-platform=pc && make # Prepare for a i386 build sudo make install # Install i386 build

Super Grub2 Disk build
----------------------
sudo grub-mkrescue --output=/tmp/test1.iso

Signature · 1 line
Support free software. Donate to Super Grub Disk. Apoya el software libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/