grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] core/partmap: Add El Torito boot catalog parsing


From: Andrei Borzenkov
Subject: Re: [PATCH] core/partmap: Add El Torito boot catalog parsing
Date: Sun, 21 Jun 2015 14:28:03 +0300

В Sat, 20 Jun 2015 11:16:47 +0100
Ross Lagerwall <address@hidden> пишет:

> 
> GRUB calculates a boot device based on the device path given by the
> firmware so:

It is not quite true. GRUB will auofill device part if it is not
present, keeping partition.

> With a normal CD, the firmware gives it something like
> /ACPI(a3401d0,0)/PCI(1,1)/ATAPI(0,0,0)/CD,1,899,1838) which points to
> the embedded ESP. GRUB doesn't know how to use that because it doesn't
> know how to read the El Torito catalog so it just uses the root of the
> CD as the boot device, i.e. (cd0), so the prefix becomes
> (cd0)/path/to/grub.
> With a hybrid USB, the firmware gives it something like
> /ACPI(a3401d0,0)/PCI(1,1)/ATA(0)/HD(1,MBR,0x769FCE30,172,63488) which
> GRUB finds and matches with the embedded ESP pointed to by the MBR e.g.
> (hd0,msdos2), so the prefix becomes (hd0,msdos2)/path/to/grub. In other
> words, the image will _not_ look at the same place whichever way it is
> booted.
> 


address@hidden:~> /usr/sbin/fdisk -l /tmp/usb

Disk /tmp/usb: 10 MiB, 10485760 bytes, 20480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: A89483C6-73F0-43C7-B35E-1D62107C7362

Device       Start   End Sectors Size Type
/tmp/usb2  2048 20446   18399   9M Linux filesystem
address@hidden:~> sudo losetup
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0      0         0  0 /tmp/usb
address@hidden:~> sudo mount /dev/loop0p2 /mnt
address@hidden:~> sudo pkgdatadir=$PWD ./grub-install -d grub-core 
--boot-directory=/mnt --efi-directory=/mnt --removable

address@hidden:~/src/grub> virtvm -drive 
file=/tmp/usb,if=virtio,media=disk,readonly -bios 
/usr/share/qemu/ovmf-x86_64.bin -serial stdio
...
                          GNU GRUB  version 2.02~beta2

   Minimal BASH-like line editing is supported. For the first word, TAB   
   lists possible command completions. Anywhere else TAB lists possible   
   device or file completions.                                            


grub> set
cmdpath=(hd0,gpt2)/EFI/BOOT
color_highlight=black/light-gray
color_normal=light-gray/black
feature_200_final=y
feature_all_video_module=y
feature_chainloader_bpb=y
feature_default_font_path=y
feature_menuentry_id=y
feature_menuentry_options=y
feature_nativedisk_cmd=y
feature_ntldr=y
feature_platform_search_hint=y
feature_timeout_style=y
grub_cpu=x86_64
grub_platform=efi
lang=
locale_dir=
pager=
prefix=(hd0,gpt2)/grub
root=hd0,gpt2
secondary_locale_dir=
grub> halt


address@hidden:~> dd if=/dev/loop0p2 of=/tmp/efi.img
address@hidden:~> xorriso -outdev /tmp/efi.iso -as mkisofs -graft-points 
--efi-boot /efi.img -efi-boot-part --efi-boot-image /efi.img=/tmp/efi.img
xorriso 1.3.8 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev '/tmp/efi.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 39.5g free
Added to ISO image: file '/efi.img'='/tmp/efi.img'
xorriso : UPDATE : 1 files added in 1 seconds
xorriso : UPDATE : 1 files added in 1 seconds
ISO image produced: 4800 sectors
Written to medium : 4800 sectors at LBA 0
Writing to '/tmp/efi.iso' completed successfully.

address@hidden:~/src/grub> virtvm -cd /tmp/efi.iso -bios 
/usr/share/qemu/ovmf-x86_64.bin -serial stdio
...
                         GNU GRUB  version 2.02~beta2

   Minimal BASH-like line editing is supported. For the first word, TAB   
   lists possible command completions. Anywhere else TAB lists possible   
   device or file completions.                                            


grub> set
cmdpath=(cd0)/EFI/BOOT
color_highlight=black/light-gray
color_normal=light-gray/black
feature_200_final=y
feature_all_video_module=y
feature_chainloader_bpb=y
feature_default_font_path=y
feature_menuentry_id=y
feature_menuentry_options=y
feature_nativedisk_cmd=y
feature_ntldr=y
feature_platform_search_hint=y
feature_timeout_style=y
grub_cpu=x86_64
grub_platform=efi
lang=
locale_dir=
pager=
prefix=(cd0,gpt2)/grub
root=cd0,gpt2
secondary_locale_dir=
grub> halt



> While Thomas's suggestion [1] does work around the issue, I think
> reading the catalog is a better-engineered solution.

What's wrong with the above? Note that it works using standard commands
and does not even require manual image creation. What is missing here?

BTW using explicit el-torito partition grub-install could not be used.

The reason to use GPT is block size difference. In principle it may be
possible to rewrite BPB when adding it to ISO to adjust for different
sector size.

> 
> [1]:
> "A user once explained me his setup and mentioned
> he runs grub-mkimage with "--config=", "iso9660" and
> and that the "embedded grub.cfg" looks like
> search.fs_label RECOVERY root
> set prefix=($root)/boot/grub"
> 
> Regards

Attachment: pgp96w8913qoO.pgp
Description: OpenPGP digital signature


reply via email to

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