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

2015-01-23 Thread Andrei Borzenkov
On Fri, Jan 23, 2015 at 1:15 AM, Vladimir 'φ-coder/phcoder' Serbinenko
 wrote:
> On 22.01.2015 22:25, Kris Moore wrote:
>>
>> 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:
> diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
> index 3b12c34..983afdb 100644
> --- a/grub-core/disk/efi/efidisk.c
> +++ b/grub-core/disk/efi/efidisk.c
> @@ -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?


> }
>
>   dev_name = grub_xasprintf ("%s,%s", parent->name,
>
>
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread Vladimir 'φ-coder/phcoder' Serbinenko
On 23.01.2015 10:40, Andrei Borzenkov wrote:
> On Fri, Jan 23, 2015 at 1:15 AM, Vladimir 'φ-coder/phcoder' Serbinenko
>  wrote:
>> On 22.01.2015 22:25, Kris Moore wrote:
>>>
>>> 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:
>> diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
>> index 3b12c34..983afdb 100644
>> --- a/grub-core/disk/efi/efidisk.c
>> +++ b/grub-core/disk/efi/efidisk.c
>> @@ -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?
> 
I think his EFI uses eltorito even from the stick. In that case we end
up in exactly the same scenario as CD-ROM.
> Kris, could you add output of device path (grub_efi_print_device_path)
> at the beginning?
> 
> 
>> }
>>
>>   dev_name = grub_xasprintf ("%s,%s", parent->name,
>>
>>
>>
>> ___
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>
> 
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 




signature.asc
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread Andrei Borzenkov
On Fri, Jan 23, 2015 at 12:45 PM, Vladimir 'φ-coder/phcoder'
Serbinenko  wrote:
> On 23.01.2015 10:40, Andrei Borzenkov wrote:
>> On Fri, Jan 23, 2015 at 1:15 AM, Vladimir 'φ-coder/phcoder' Serbinenko
>>  wrote:
>>> On 22.01.2015 22:25, Kris Moore wrote:

 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:
>>> diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
>>> index 3b12c34..983afdb 100644
>>> --- a/grub-core/disk/efi/efidisk.c
>>> +++ b/grub-core/disk/efi/efidisk.c
>>> @@ -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?
>>
> 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.

>> Kris, could you add output of device path (grub_efi_print_device_path)
>> at the beginning?
>>
>>
>>> }
>>>
>>>   dev_name = grub_xasprintf ("%s,%s", parent->name,
>>>
>>>
>>>
>>> ___
>>> Grub-devel mailing list
>>> Grub-devel@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>>
>>
>> ___
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>
>
>
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread Thomas Schmitt
Hi,

Vladimir wrote:
> 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


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread Kris Moore
On 01/23/2015 05:14, Thomas Schmitt wrote:
> Hi,
>
> Vladimir wrote:
>> 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
>
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> 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

-- 
Kris Moore
PC-BSD Software
iXsystems


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread Thomas Schmitt
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  0x  0x00   5760 140
  El Torito img path :   1  /efi.img
  System area options: 0x0201
  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  TypeStart   Blocks
  MBR partition  :   1   0x00  0xee181551
  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  0x1001
  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  0x1001
  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  0x1001
  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  0x  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: 0x0201
  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  TypeStart   Blocks
  MBR partition  :   1   0x00  0xee181551
  GPT:   N  Info
  GPT disk GUID  :  70e9427b66c1b744b42113c17b268b07
  GPT entry array:  20  176  separated
  GPT lba range  :  64  81506  81551
  GPT 

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

2015-01-23 Thread Andrei Borzenkov
В Fri, 23 Jan 2015 10:45:08 +0100
Vladimir 'φ-coder/phcoder' Serbinenko  пишет:

> On 23.01.2015 10:40, Andrei Borzenkov wrote:
> > On Fri, Jan 23, 2015 at 1:15 AM, Vladimir 'φ-coder/phcoder' Serbinenko
> >  wrote:
> >> On 22.01.2015 22:25, Kris Moore wrote:
> >>>
> >>> 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:
> >> diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
> >> index 3b12c34..983afdb 100644
> >> --- a/grub-core/disk/efi/efidisk.c
> >> +++ b/grub-core/disk/efi/efidisk.c
> >> @@ -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?
> > 
> 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.


pgp6eamYbMEqd.pgp
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread Vladimir 'φ-coder/phcoder' Serbinenko

> 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)
diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c
index e719839..e02340f 100644
--- a/util/grub-mkrescue.c
+++ b/util/grub-mkrescue.c
@@ -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");




signature.asc
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread Thomas Schmitt
Hi,

Andrei Borzenkov wrote:
> Not eltorito, but normal ESP.

That's somewhat appeasing.


> 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  TypeStart   Blocks
  MBR partition  :   1   0x80  0x000   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


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread Andrei Borzenkov
В Fri, 23 Jan 2015 19:29:07 +0100
Vladimir 'φ-coder/phcoder' Serbinenko  пишет:

> 
> > 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.

> 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)
> diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c
> index e719839..e02340f 100644
> --- a/util/grub-mkrescue.c
> +++ b/util/grub-mkrescue.c
> @@ -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");
> 
> 



pgpHmbWCO22Qe.pgp
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: gnulib update policy

2015-01-23 Thread Andrei Borzenkov
В Sun, 7 Dec 2014 20:34:57 +0300
Andrei Borzenkov  пишет:

> I have two pending patches for gnulib; each one is included upstream.
> What is the policy in this case - update individual files, add patches
> to be applied at autogen step or update from upstream (latter I'd
> rather avoid at this stage)?

ping?

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread Andrei Borzenkov
В Fri, 23 Jan 2015 21:38:27 +0300
Andrei Borzenkov  пишет:

> В Fri, 23 Jan 2015 19:29:07 +0100
> Vladimir 'φ-coder/phcoder' Serbinenko  пишет:
> 
> > 
> > > 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.
> 

Ah, OK, I see. Sorry.

> > 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.

> > diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c
> > index e719839..e02340f 100644
> > --- a/util/grub-mkrescue.c
> > +++ b/util/grub-mkrescue.c
> > @@ -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");
> > 
> > 
> 



pgpGAexama8cY.pgp
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


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

2015-01-23 Thread adrian15

El 22/01/15 a las 22:25, Kris Moore escribió:


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  
-- -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
--
Support free software. Donate to Super Grub Disk. Apoya el software 
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: pvgrub2 and old grub menu.lst

2015-01-23 Thread Andrei Borzenkov
В Thu, 3 Apr 2014 14:50:02 +0800
Michael Chang  пишет:

> On Wed, Apr 02, 2014 at 08:13:14PM +0400, Andrey Borzenkov wrote:
> > В Wed, 2 Apr 2014 14:29:50 +0400
> > Andrey Borzenkov  пишет:
> > 
> > > On Wed, Apr 2, 2014 at 12:43 PM, Michael Chang  wrote:
> > > > On Tue, Apr 01, 2014 at 08:06:44PM +0400, Andrey Borzenkov wrote:
> > > >> В Tue, 1 Apr 2014 15:46:22 +0800
> > > >> Michael Chang  пишет:
> > > >>
> > > >> > While trying to boot xen pv guest with old grub config (menu.lst),
> > > >> > the pvgrub2 loads it's menu successfully, but when you attemp to boot
> > > >> > the kernel it failed with the following message.
> > > >> >
> > > >> >   error: couldn't load file /boot/vmlinuz-3.0.76-0.11-xen.
> > > >> >   error: you need to load the kernel first.
> > > >> >
> > > >> >   Press any key to continue..."
> > > >> >
> > > >> > The kernel is there and boots fine with pygrub.
> > > >> >
> > > >> > After some investigation, it boils down to the menu.lst has 
> > > >> > explicitly
> > > >> > set it's root device to (hd0,1) and therefore the root device is not
> > > >> > recognized by pvgrub2.
> > > >> >
> > > >> > title Xen -- SUSE Linux Enterprise Server 11 SP3 - 3.0.76-0.11
> > > >> >   root (hd0,1)
> > > >> >   kernel /boot/vmlinuz-3.0.76-0.11-xen root=/dev/xvda2 
> > > >> > resume=/dev/xvda1
> > > >> > splash=silent showopts initrd /boot/initrd-3.0.76-0.11.xen
> > > >> >
> > > >> > I'd like to know whether old grub configuration is considered or 
> > > >> > planned
> > > >> > to work with pvgrub2 ? And is it a viable suggestion to have (hdX,Y) 
> > > >> > a
> > > >> > valid xen disk name because it's quite common in some existing 
> > > >> > configs ?
> > > >> >
> > > >>
> > > >> I believe this technically should work; but this needs someone who
> > > >> knows how Xen disks is mapped to hd number in legacy grub.
> > > >>
> > > >> It would be something like (completely untested)
> > > >
> > > > Thank you for the patch. I applied it and tried to test it. The
> > > > virtdisks[i].handle never matched with num as it's id of the disk (on
> > > > my system it is 51712).
> > > >
> > > 
> > > As I said, completely untested :)
> > > 
> > > > Please pardon my ignorant, can num be the index to the virtdisks array
> > > > to get the mapped xen disk ?
> > > >
> > > 
> > > pv-grub additionally sorts by handle:
> > > http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=stubdom/grub/mini-os.c;h=9d4bcc76d5f3e9907889948ee0dcea32e19c185b;hb=HEAD#l73
> > > 
> > > So to actually map pv-grub hdX we need to do the same.
> > 
> > Could you test patch below (compile-tested)?
> 
> This patch works very well for me. It can boot into system using legacy
> menu.lst.
> 
> I also setup two disks for testing, and set root=hdX,Y to list the
> file in repective disk correct. Then swapping the disk order in xen
> config and again the result is correct.
> 
> FWIW here my acknowledge for my positive test result.
> 
> Tested-By: Michael Chang .
> 
> Feel free to let me know anything I can help in this topic, and really
> appreciate for your work and time on this.
> 

Finally pushed.

> Thanks,
> Michael
> 
> > 
> > From: Andrey Borzenkov 
> > Subject: [PATCH] accept also hdX as alias to native Xen disk name
> > 
> > To assign correct disk numbers, sort disks by increasing order of handle
> > value.  This allows reusing legacy pv-grub menu.lst which is using hdX 
> > names.
> > 
> > Suggested-By: Michael Chang 
> > 
> > ---
> >  grub-core/disk/xen/xendisk.c | 45 
> > +++-
> >  1 file changed, 36 insertions(+), 9 deletions(-)
> > 
> > diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c
> > index 2b11c2a..b18a923 100644
> > --- a/grub-core/disk/xen/xendisk.c
> > +++ b/grub-core/disk/xen/xendisk.c
> > @@ -40,6 +40,7 @@ struct virtdisk
> >grub_xen_evtchn_t evtchn;
> >void *dma_page;
> >grub_xen_grant_t dma_grant;
> > +  struct virtdisk *compat_next;
> >  };
> >  
> >  #define xen_wmb() mb()
> > @@ -47,6 +48,7 @@ struct virtdisk
> >  
> >  static struct virtdisk *virtdisks;
> >  static grub_size_t vdiskcnt;
> > +struct virtdisk *compat_head;
> >  
> >  static int
> >  grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
> > @@ -66,20 +68,32 @@ grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t 
> > hook, void *hook_data,
> >  static grub_err_t
> >  grub_virtdisk_open (const char *name, grub_disk_t disk)
> >  {
> > -  grub_size_t i;
> > +  int i;
> >grub_uint32_t secsize;
> >char fdir[200];
> >char *buf;
> > +  int num = -1;
> > +  struct virtdisk *vd;
> >  
> > -  for (i = 0; i < vdiskcnt; i++)
> > -if (grub_strcmp (name, virtdisks[i].fullname) == 0)
> > +  /* For compatibility with pv-grub legacy menu.lst accept hdX as disk 
> > name */
> > +  if (name[0] == 'h' && name[1] == 'd' && name[2])
> > +{
> > +  num = grub_strtoul (name + 2, 0, 10);
> > +  if (grub_errno)
> > +   {
> > + grub_errno = 0;
> > + num = -1;
> > +