core/partmap: Add El Torito boot catalog parsing
PATCH 1/1 core/partmap: Add El Torito boot catalog parsing
Add a module, part_eltorito, to allow parsing of the El Torito boot catalog into partitions. This follows the El Torito Bootable CD-ROM Format Specification Version 1.0 and the UEFI Specification 2.5. In cases where the specification is unclear, the code follows the UEFI reference implementation.
This is useful when booting CDs in UEFI mode. Before, GRUB would not be able to use the embedded ESP from which it was executed, so it would have a root and prefix set to the top level of the CD. This could result in subtle configuration bugs, because the same ISO booted from a USB disk (using isohybrid) would have its root and prefix set to the embedded ESP because it can find it through the MBR.
With this change, GRUB is able to access the embedded ESP and set its root and prefix correctly when booting a CD in UEFI mode. It also allows GRUB to access embedded floppy and HDD images.
Tested with OVMF and a couple of real machines.
--- grub-core/Makefile.core.def | 5 ++ grub-core/partmap/eltorito.c | 199 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 grub-core/partmap/eltorito.c
grub-core/Makefile.core.def +5 -0
@@ -1785,6 +1785,11 @@ module = { }; module = { + name = part_eltorito; + common = partmap/eltorito.c; +}; + +module = { name = part_msdos; common = partmap/msdos.c; };
grub-core/partmap/eltorito.c new file +199 -0
199 lines not on this page · raw message
Signature · 1 line
2.4.2
В Sun, 7 Jun 2015 11:24:46 +0100
Ross Lagerwall <[email protected]> пишет:
Quoted 6 lines
Add a module,
part_eltorito, to allow parsing of the El Torito boot catalog into partitions. This follows the El Torito Bootable CD-ROM Format Specification Version 1.0 and the UEFI Specification 2.5. In cases where the specification is unclear, the code follows the UEFI reference implementation.
Quoted 6 lines
This is useful when booting CDs in UEFI mode. Before, GRUB would not be able to use the embedded ESP from which it was executed, so it would have a root and prefix set to the top level of the CD. This could result in subtle configuration bugs, because the same ISO booted from a USB disk (using isohybrid) would have its root and prefix set to the embedded ESP because it can find it through the MBR.
You can already access ESP on hybrid image using e.g. (cd0,msdos1); why is it not enough?
Quoted 4 lines
With this change, GRUB is able to access the embedded ESP and set its root and prefix correctly when booting a CD in UEFI mode. It also allows GRUB to access embedded floppy and HDD images.
Quoted 16 lines · Andrei Borzenkov
В Sun, 7 Jun 2015 11:24:46 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 6 lines
Add a module,
part_eltorito, to allow parsing of the El Torito boot catalog into partitions. This follows the El Torito Bootable CD-ROM Format Specification Version 1.0 and the UEFI Specification 2.5. In cases where the specification is unclear, the code follows the UEFI reference implementation.Quoted 6 lines
This is useful when booting CDs in UEFI mode. Before, GRUB would not be able to use the embedded ESP from which it was executed, so it would have a root and prefix set to the top level of the CD. This could result in subtle configuration bugs, because the same ISO booted from a USB disk (using isohybrid) would have its root and prefix set to the embedded ESP because it can find it through the MBR.
Quoted 2 lines
You can already access ESP on hybrid image using e.g. (cd0,msdos1); why is it not enough?
This is about booting a CD in UEFI mode; it may not be a hybrid disc in which case it doesn't have an MBR.
Also, in the case of a hybrid image booted using a CD, the mismatch between the 2048 byte sectors of the CD and the 512 byte sector values used in the MBR means that GRUB is not able to access the correctly ESP anyway.
For these reasons, I think it is useful to parse the El Torito boot catalog.
Regards,
Signature · 1 line
Ross Lagerwall
В Mon, 8 Jun 2015 18:31:06 +0100
Ross Lagerwall <[email protected]> пишет:
Quoted 17 lines · Andrei Borzenkov
Quoted 16 lines
В Sun, 7 Jun 2015 11:24:46 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 12 lines
Add a module,
part_eltorito, to allow parsing of the El Torito boot catalog into partitions. This follows the El Torito Bootable CD-ROM Format Specification Version 1.0 and the UEFI Specification 2.5. In cases where the specification is unclear, the code follows the UEFI reference implementation.This is useful when booting CDs in UEFI mode. Before, GRUB would not be able to use the embedded ESP from which it was executed, so it would have a root and prefix set to the top level of the CD. This could result in subtle configuration bugs, because the same ISO booted from a USB disk (using isohybrid) would have its root and prefix set to the embedded ESP because it can find it through the MBR.
Quoted 6 lines
Quoted 2 lines
You can already access ESP on hybrid image using e.g. (cd0,msdos1); why is it not enough?
This is about booting a CD in UEFI mode; it may not be a hybrid disc in which case it doesn't have an MBR.
So you need to either add partition label or add additional driver to grub.efi. The former works already and does not require any new code.
Quoted 4 lines
Also, in the case of a hybrid image booted using a CD, the mismatch between the 2048 byte sectors of the CD and the 512 byte sector values used in the MBR means that GRUB is not able to access the correctly ESP anyway.
It may depend on how you create partition table. Neither openSUSE DVD nor images created by grub-mkrescue have problems. Did you actually try it?
As example
bor@opensuse:~/src/grub> xorriso --indev /datastore/iso/openSUSE-13.2-DVD-x86_64.iso --report-el-torito plain --report-system-area plain xorriso 1.3.8 : RockRidge filesystem manipulator, libburnia project.
xorriso : NOTE : Loading ISO image tree from LBA 0 xorriso : UPDATE : 6102 nodes read in 1 seconds xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded Drive current: -indev '/datastore/iso/openSUSE-13.2-DVD-x86_64.iso' Media current: stdio file, overwriteable Media status : is written , is appendable Boot record : El Torito , MBR isohybrid cyl-align-off Media summary: 1 session, 2284287 data blocks, 4461m data, 31.5g free Volume id : 'openSUSE-13.2-DVD-x86_640051' El Torito catalog : 20 1 El Torito images : N Pltf B Emul Ld_seg Hdpt Ldsiz LBA El Torito boot img : 1 BIOS y none 0x0000 0x00 4 5826 El Torito boot img : 2 UEFI y none 0x0000 0x00 1 896 El Torito img path : 1 /boot/x86_64/loader/isolinux.bin El Torito img opts : 1 boot-info-table isohybrid-suitable El Torito img path : 2 /boot/x86_64/efi System area options: 0x00000202 System area summary: MBR isohybrid cyl-align-off ISO image size/512 : 9137148 Partition offset : 0 MBR heads per cyl : 0 MBR secs per head : 0 MBR partition table: N Status Type Start Blocks MBR partition : 1 0x00 0xef 3584 8064 MBR partition : 2 0x80 0x17 11648 9126528 MBR partition path : 1 /boot/x86_64/efi
bor@opensuse:~/src/grub>
You may consider using xorriso to create image, it does quite good job with hybrid images.
Quoted 3 lines
For these reasons, I think it is useful to parse the El Torito boot catalog.
I'm not entirely opposed to it, I just do not see compelling reasons to do it :)
I actually think that viewing ESP as opaque binary executable and using ISO as primary data location is more generic and useful. This way you can have any amount of different platform binaries all sharing common /boot/grub on ISO with common configuration. Also information in El Torito boot image (as grub.cfg) is not as easily accessible as information on ISO. Making it hard to understand what image actually does.
Quoted 70 lines · Andrei Borzenkov
В Mon, 8 Jun 2015 18:31:06 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 17 lines · Andrei Borzenkov
Quoted 16 lines
В Sun, 7 Jun 2015 11:24:46 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 12 lines
Add a module,
part_eltorito, to allow parsing of the El Torito boot catalog into partitions. This follows the El Torito Bootable CD-ROM Format Specification Version 1.0 and the UEFI Specification 2.5. In cases where the specification is unclear, the code follows the UEFI reference implementation.This is useful when booting CDs in UEFI mode. Before, GRUB would not be able to use the embedded ESP from which it was executed, so it would have a root and prefix set to the top level of the CD. This could result in subtle configuration bugs, because the same ISO booted from a USB disk (using isohybrid) would have its root and prefix set to the embedded ESP because it can find it through the MBR.
Quoted 6 lines
Quoted 2 lines
You can already access ESP on hybrid image using e.g. (cd0,msdos1); why is it not enough?
This is about booting a CD in UEFI mode; it may not be a hybrid disc in which case it doesn't have an MBR.
So you need to either add partition label or add additional driver to grub.efi. The former works already and does not require any new code.
Quoted 4 lines
Also, in the case of a hybrid image booted using a CD, the mismatch between the 2048 byte sectors of the CD and the 512 byte sector values used in the MBR means that GRUB is not able to access the correctly ESP anyway.
It may depend on how you create partition table. Neither openSUSE DVD nor images created by grub-mkrescue have problems. Did you actually try it?
As example
bor@opensuse:~/src/grub> xorriso --indev /datastore/iso/openSUSE-13.2-DVD-x86_64.iso --report-el-torito plain --report-system-area plain xorriso 1.3.8 : RockRidge filesystem manipulator, libburnia project.
xorriso : NOTE : Loading ISO image tree from LBA 0 xorriso : UPDATE : 6102 nodes read in 1 seconds xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded Drive current: -indev '/datastore/iso/openSUSE-13.2-DVD-x86_64.iso' Media current: stdio file, overwriteable Media status : is written , is appendable Boot record : El Torito , MBR isohybrid cyl-align-off Media summary: 1 session, 2284287 data blocks, 4461m data, 31.5g free Volume id : 'openSUSE-13.2-DVD-x86_640051' El Torito catalog : 20 1 El Torito images : N Pltf B Emul Ld_seg Hdpt Ldsiz LBA El Torito boot img : 1 BIOS y none 0x0000 0x00 4 5826 El Torito boot img : 2 UEFI y none 0x0000 0x00 1 896 El Torito img path : 1 /boot/x86_64/loader/isolinux.bin El Torito img opts : 1 boot-info-table isohybrid-suitable El Torito img path : 2 /boot/x86_64/efi System area options: 0x00000202 System area summary: MBR isohybrid cyl-align-off ISO image size/512 : 9137148 Partition offset : 0 MBR heads per cyl : 0 MBR secs per head : 0 MBR partition table: N Status Type Start Blocks MBR partition : 1 0x00 0xef 3584 8064 MBR partition : 2 0x80 0x17 11648 9126528 MBR partition path : 1 /boot/x86_64/efi
Quoted 4 lines
bor@opensuse:~/src/grub>
You may consider using xorriso to create image, it does quite good job with hybrid images.
Yes I have tried, and I made a video of it :-)
https://rossl.org/junk/grub.webm
See that GRUB is not able to access (cd0,msdos2), which is the embedded FAT partition.
Quoted 8 lines
Quoted 4 lines
For these reasons, I think it is useful to parse the El Torito boot catalog.
I'm not entirely opposed to it, I just do not see compelling reasons to do it :)
Quoted 8 lines
I actually think that viewing ESP as opaque binary executable and using ISO as primary data location is more generic and useful. This way you can have any amount of different platform binaries all sharing common
/boot/grubon ISO with common configuration. Also information in El Torito boot image (as grub.cfg) is not as easily accessible as information on ISO. Making it hard to understand what image actually does.
Except that the ESP isn't a binary executable, the firmware presents it as a file system and gives it to GRUB as the boot location.
As it currently stands, the configurations are not shared, because currently when booting the image using a CD it will look for the cfg at (cd0)/..., and when booting the same image off a USB, it will look at the FAT partition (hd0,msdos2)/... because it knows how to find it.
Cheers,
Signature · 1 line
Ross Lagerwall
В Mon, 8 Jun 2015 19:25:12 +0100
Ross Lagerwall <[email protected]> пишет:
Quoted 73 lines · Andrei Borzenkov
Quoted 72 lines
В Mon, 8 Jun 2015 18:31:06 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 17 lines · Andrei Borzenkov
Quoted 16 lines
В Sun, 7 Jun 2015 11:24:46 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 12 lines
Add a module,
part_eltorito, to allow parsing of the El Torito boot catalog into partitions. This follows the El Torito Bootable CD-ROM Format Specification Version 1.0 and the UEFI Specification 2.5. In cases where the specification is unclear, the code follows the UEFI reference implementation.This is useful when booting CDs in UEFI mode. Before, GRUB would not be able to use the embedded ESP from which it was executed, so it would have a root and prefix set to the top level of the CD. This could result in subtle configuration bugs, because the same ISO booted from a USB disk (using isohybrid) would have its root and prefix set to the embedded ESP because it can find it through the MBR.
Quoted 6 lines
Quoted 2 lines
You can already access ESP on hybrid image using e.g. (cd0,msdos1); why is it not enough?
This is about booting a CD in UEFI mode; it may not be a hybrid disc in which case it doesn't have an MBR.
So you need to either add partition label or add additional driver to grub.efi. The former works already and does not require any new code.
Quoted 4 lines
Also, in the case of a hybrid image booted using a CD, the mismatch between the 2048 byte sectors of the CD and the 512 byte sector values used in the MBR means that GRUB is not able to access the correctly ESP anyway.
It may depend on how you create partition table. Neither openSUSE DVD nor images created by grub-mkrescue have problems. Did you actually try it?
As example
bor@opensuse:~/src/grub> xorriso --indev /datastore/iso/openSUSE-13.2-DVD-x86_64.iso --report-el-torito plain --report-system-area plain xorriso 1.3.8 : RockRidge filesystem manipulator, libburnia project.
xorriso : NOTE : Loading ISO image tree from LBA 0 xorriso : UPDATE : 6102 nodes read in 1 seconds xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded Drive current: -indev '/datastore/iso/openSUSE-13.2-DVD-x86_64.iso' Media current: stdio file, overwriteable Media status : is written , is appendable Boot record : El Torito , MBR isohybrid cyl-align-off Media summary: 1 session, 2284287 data blocks, 4461m data, 31.5g free Volume id : 'openSUSE-13.2-DVD-x86_640051' El Torito catalog : 20 1 El Torito images : N Pltf B Emul Ld_seg Hdpt Ldsiz LBA El Torito boot img : 1 BIOS y none 0x0000 0x00 4 5826 El Torito boot img : 2 UEFI y none 0x0000 0x00 1 896 El Torito img path : 1 /boot/x86_64/loader/isolinux.bin El Torito img opts : 1 boot-info-table isohybrid-suitable El Torito img path : 2 /boot/x86_64/efi System area options: 0x00000202 System area summary: MBR isohybrid cyl-align-off ISO image size/512 : 9137148 Partition offset : 0 MBR heads per cyl : 0 MBR secs per head : 0 MBR partition table: N Status Type Start Blocks MBR partition : 1 0x00 0xef 3584 8064 MBR partition : 2 0x80 0x17 11648 9126528 MBR partition path : 1 /boot/x86_64/efibor@opensuse:~/src/grub>
Quoted 9 lines
Quoted 2 lines
You may consider using xorriso to create image, it does quite good job with hybrid images.
Yes I have tried, and I made a video of it :-)
https://rossl.org/junk/grub.webmSee that GRUB is not able to access (cd0,msdos2), which is the embedded FAT partition.
OK. What about using GPT? it definitely works, just tested.
Quoted 17 lines
Quoted 8 lines
Quoted 4 lines
For these reasons, I think it is useful to parse the El Torito boot catalog.
I'm not entirely opposed to it, I just do not see compelling reasons to do it :)
Quoted 8 lines
I actually think that viewing ESP as opaque binary executable and using ISO as primary data location is more generic and useful. This way you can have any amount of different platform binaries all sharing common
/boot/grubon ISO with common configuration. Also information in El Torito boot image (as grub.cfg) is not as easily accessible as information on ISO. Making it hard to understand what image actually does.
Quoted 8 lines
Except that the ESP isn't a binary executable, the firmware presents it as a file system and gives it to GRUB as the boot location.
As it currently stands, the configurations are not shared, because currently when booting the image using a CD it will look for the cfg at (cd0)/..., and when booting the same image off a USB, it will look at the FAT partition (hd0,msdos2)/... because it knows how to find it.
Image created by grub-mkrescue looks at the same place whatever way it is booted. You need to set prefix to ()/path/to/grub then it will be auto-filled with correct boot device name.
Hi,
Quoted 4 lines · Andrei Borzenkov
Quoted 4 lines
Drive current: -indev '/datastore/iso/openSUSE-13.2-DVD-x86_64.iso' [...]
You may consider using xorriso to create image, it does quite good job with hybrid images.
Thanks for the compliment. (The openSUSE ISOs are not made by xorriso, though, but rather by genisoimage, isohybrid, and a head transplantation to make MBR partition 2 mountable, if i remember correctly my curious research about openSUSE-13.1-NET-x86_64.iso.)
Quoted 3 lines · Ross Lagerwall
Yes I have tried, and I made a video of it :-)
See that GRUB is not able to access (cd0,msdos2), which is the embedded FAT partition.
The trick of the others could be to let the GRUB2 software from ESP look up and use the GRUB2 stuff in a directory of the ISO.
So GRUB2 booted via UEFI from CD does not need to access the ESP by own means.
A user once explained me his setup and mentioned that he runs grub-mkimage with "--config=", "iso9660" and "search", and that the "embedded grub.cfg" looks like
search.fs_label RECOVERY root
set prefix=($root)/boot/grub
Have a nice day :)
Thomas
Quoted 114 lines · Andrei Borzenkov
В Mon, 8 Jun 2015 19:25:12 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 73 lines · Andrei Borzenkov
Quoted 72 lines
В Mon, 8 Jun 2015 18:31:06 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 17 lines · Andrei Borzenkov
Quoted 16 lines
В Sun, 7 Jun 2015 11:24:46 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 12 lines
Add a module,
part_eltorito, to allow parsing of the El Torito boot catalog into partitions. This follows the El Torito Bootable CD-ROM Format Specification Version 1.0 and the UEFI Specification 2.5. In cases where the specification is unclear, the code follows the UEFI reference implementation.This is useful when booting CDs in UEFI mode. Before, GRUB would not be able to use the embedded ESP from which it was executed, so it would have a root and prefix set to the top level of the CD. This could result in subtle configuration bugs, because the same ISO booted from a USB disk (using isohybrid) would have its root and prefix set to the embedded ESP because it can find it through the MBR.
Quoted 6 lines
Quoted 2 lines
You can already access ESP on hybrid image using e.g. (cd0,msdos1); why is it not enough?
This is about booting a CD in UEFI mode; it may not be a hybrid disc in which case it doesn't have an MBR.
So you need to either add partition label or add additional driver to grub.efi. The former works already and does not require any new code.
Quoted 4 lines
Also, in the case of a hybrid image booted using a CD, the mismatch between the 2048 byte sectors of the CD and the 512 byte sector values used in the MBR means that GRUB is not able to access the correctly ESP anyway.
It may depend on how you create partition table. Neither openSUSE DVD nor images created by grub-mkrescue have problems. Did you actually try it?
As example
bor@opensuse:~/src/grub> xorriso --indev /datastore/iso/openSUSE-13.2-DVD-x86_64.iso --report-el-torito plain --report-system-area plain xorriso 1.3.8 : RockRidge filesystem manipulator, libburnia project.
xorriso : NOTE : Loading ISO image tree from LBA 0 xorriso : UPDATE : 6102 nodes read in 1 seconds xorriso : NOTE : Detected El-Torito boot information which currently is set to be discarded Drive current: -indev '/datastore/iso/openSUSE-13.2-DVD-x86_64.iso' Media current: stdio file, overwriteable Media status : is written , is appendable Boot record : El Torito , MBR isohybrid cyl-align-off Media summary: 1 session, 2284287 data blocks, 4461m data, 31.5g free Volume id : 'openSUSE-13.2-DVD-x86_640051' El Torito catalog : 20 1 El Torito images : N Pltf B Emul Ld_seg Hdpt Ldsiz LBA El Torito boot img : 1 BIOS y none 0x0000 0x00 4 5826 El Torito boot img : 2 UEFI y none 0x0000 0x00 1 896 El Torito img path : 1 /boot/x86_64/loader/isolinux.bin El Torito img opts : 1 boot-info-table isohybrid-suitable El Torito img path : 2 /boot/x86_64/efi System area options: 0x00000202 System area summary: MBR isohybrid cyl-align-off ISO image size/512 : 9137148 Partition offset : 0 MBR heads per cyl : 0 MBR secs per head : 0 MBR partition table: N Status Type Start Blocks MBR partition : 1 0x00 0xef 3584 8064 MBR partition : 2 0x80 0x17 11648 9126528 MBR partition path : 1 /boot/x86_64/efibor@opensuse:~/src/grub>
Quoted 9 lines
Quoted 2 lines
You may consider using xorriso to create image, it does quite good job with hybrid images.
Yes I have tried, and I made a video of it :-)
https://rossl.org/junk/grub.webmSee that GRUB is not able to access (cd0,msdos2), which is the embedded FAT partition.
OK. What about using GPT? it definitely works, just tested.
Quoted 17 lines
Quoted 8 lines
Quoted 4 lines
For these reasons, I think it is useful to parse the El Torito boot catalog.
I'm not entirely opposed to it, I just do not see compelling reasons to do it :)
Quoted 8 lines
I actually think that viewing ESP as opaque binary executable and using ISO as primary data location is more generic and useful. This way you can have any amount of different platform binaries all sharing common
/boot/grubon ISO with common configuration. Also information in El Torito boot image (as grub.cfg) is not as easily accessible as information on ISO. Making it hard to understand what image actually does.Quoted 8 lines
Except that the ESP isn't a binary executable, the firmware presents it as a file system and gives it to GRUB as the boot location.
As it currently stands, the configurations are not shared, because currently when booting the image using a CD it will look for the cfg at (cd0)/..., and when booting the same image off a USB, it will look at the FAT partition (hd0,msdos2)/... because it knows how to find it.
Quoted 3 lines
Image created by grub-mkrescue looks at the same place whatever way it is booted. You need to set prefix to ()/path/to/grub then it will be auto-filled with correct boot device name.
GRUB calculates a boot device based on the device path given by the firmware so:
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.
While Thomas's suggestion [1] does work around the issue, I think reading the catalog is a better-engineered solution.
[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
Signature · 1 line
Ross Lagerwall
I agree with Andrei. El torito catalog contains bootable binaries. The fact that this binary follows FAT format is purely tangential and we should not put additional files there or access it either
Quoted 177 lines · Ross Lagerwall
Quoted 12 lines · Andrei Borzenkov
В Mon, 8 Jun 2015 19:25:12 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 9 lines · Andrei Borzenkov
Quoted 8 lines
В Mon, 8 Jun 2015 18:31:06 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 5 lines · Andrei Borzenkov
Quoted 4 lines
В Sun, 7 Jun 2015 11:24:46 +0100
Ross Lagerwall <[email protected]> пишет:Quoted 1 line
Add a module,
part_eltorito, to allow parsing of the El Toritoboot
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
catalog into partitions. This follows the El Torito Bootable
CD-ROM
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Format Specification Version 1.0 and the UEFI Specification
2.5.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
In cases where the specification is unclear, the code follows
the UEFI
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
reference implementation.
This is useful when booting CDs in UEFI mode. Before, GRUB
would not be
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
able to use the embedded ESP from which it was executed, so it
would
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
have a root and prefix set to the top level of the CD. This
could result
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
in subtle configuration bugs, because the same ISO booted from
a USB
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
disk (using isohybrid) would have its root and prefix set to
the
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
embedded ESP because it can find it through the MBR.
You can already access ESP on hybrid image using e.g.
(cd0,msdos1); why
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
is it not enough?
This is about booting a CD in UEFI mode; it may not be a hybrid
disc in
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
which case it doesn't have an MBR.
So you need to either add partition label or add additional driver to grub.efi. The former works already and does not require any new code.
Quoted 1 line
Also, in the case of a hybrid image booted using a CD, the
mismatch between
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
the 2048 byte sectors of the CD and the 512 byte sector values
used in the
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
MBR means that GRUB is not able to access the correctly ESP anyway.
It may depend on how you create partition table. Neither openSUSE DVD nor images created by grub-mkrescue have problems. Did you actually
try
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
it?
As example
bor@opensuse:~/src/grub> xorriso --indev
/datastore/iso/openSUSE-13.2-DVD-x86_64.iso --report-el-torito plain --report-system-area plain
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
xorriso 1.3.8 : RockRidge filesystem manipulator, libburnia project.
xorriso : NOTE : Loading ISO image tree from LBA 0 xorriso : UPDATE : 6102 nodes read in 1 seconds
xorriso : NOTE : Detected El-Torito boot information which currentlyis set to be discarded
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Drive current: -indev '/datastore/iso/openSUSE-13.2-DVD-x86_64.iso' Media current: stdio file, overwriteable
Media status : is written , is appendable
Boot record : El Torito , MBR isohybrid cyl-align-off Media summary: 1 session, 2284287 data blocks, 4461m data, 31.5g free
Volume id : 'openSUSE-13.2-DVD-x86_640051'
El Torito catalog : 20 1
El Torito images : N Pltf B EmulLd_segHdpt LdsizLBA
Quoted 1 line
Quoted 1 line
Quoted 1 line
El Torito boot img : 1 BIOS y none
0x00000x0045826
Quoted 1 line
Quoted 1 line
Quoted 1 line
El Torito boot img : 2 UEFI y none
0x00000x001896
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
El Torito img path : 1 /boot/x86_64/loader/isolinux.bin El Torito img opts : 1 boot-info-table isohybrid-suitable El Torito img path : 2 /boot/x86_64/efi System area options: 0x00000202 System area summary: MBR isohybrid cyl-align-off ISO image size/512 : 9137148 Partition offset : 0 MBR heads per cyl : 0 MBR secs per head : 0 MBR partition table: N Status Type Start Blocks MBR partition : 1 0x00 0xef 3584 8064 MBR partition : 2 0x80 0x17 11648 9126528 MBR partition path : 1 /boot/x86_64/efibor@opensuse:~/src/grub>
Quoted 1 line
Quoted 1 line
Quoted 1 line
You may consider using xorriso to create image, it does quite good
job
Quoted 17 lines
Quoted 8 lines
Quoted 1 line
with hybrid images.
Yes I have tried, and I made a video of it :-)
https://rossl.org/junk/grub.webmSee that GRUB is not able to access (cd0,msdos2), which is the embedded FAT partition.
OK. What about using GPT? it definitely works, just tested.
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
For these reasons, I think it is useful to parse the El Torito boot catalog.
I'm not entirely opposed to it, I just do not see compelling reasons
to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
do it :)
I actually think that viewing ESP as opaque binary executable and
using
Quoted 17 lines
Quoted 8 lines
Quoted 7 lines
ISO as primary data location is more generic and useful. This way you can have any amount of different platform binaries all sharing common
/boot/grubon ISO with common configuration. Also information in El Torito boot image (as grub.cfg) is not as easily accessible as information on ISO. Making it hard to understand what image actually does.Quoted 8 lines
Except that the ESP isn't a binary executable, the firmware presents it as a file system and gives it to GRUB as the boot location.
As it currently stands, the configurations are not shared, because currently when booting the image using a CD it will look for the cfg at (cd0)/..., and when booting the same image off a USB, it will look at the FAT partition (hd0,msdos2)/... because it knows how to find it.
Quoted 3 lines
Image created by grub-mkrescue looks at the same place whatever way it is booted. You need to set prefix to ()/path/to/grub then it will be auto-filled with correct boot device name.
GRUB calculates a boot device based on the device path given by the firmware so:
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.While Thomas's suggestion [1] does work around the issue, I think reading the catalog is a better-engineered solution.
[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
--
Ross Lagerwall_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Hi,
not that i would want to interfere with GRUB2 development decisions. Nevertheless, i have some comments from the view of the specs.
Quoted 1 line · Vladimir Serbinenko
El torito catalog contains bootable binaries.
UEFI 2.4 9.3.6.2 "CD-ROM Media Device Path"
"The CD-ROM Media Device Path is used to define a system partition
that exists on a CD-ROM. The CD-ROM is assumed to contain an ISO-9660 file system and follow the CD-ROM “El Torito� format. [...] In EFI the bootable entity is an EFI System Partition that is pointed to by the Boot Entry."
According to El Torito 1.0 the boot images may be emulated disk-like devices or executable binaries for the given platform:
2.0 "ISO-9660 and the Booting Catalog"
"The image may be virtualized into INT 13 drive number 00 or 80
for bootable disk emulation, or [... some BIOS shortcut ...]. The image may also simply be some code which will be loaded at boot time (no emulation)."
UEFI pierces a little hole into the theory of running on an emulated disk by prescribing the "no emulation" mark in the boot catalog which for BIOS means: load and execute binary.
12.3.2.1 "ISO-9660 and El Torito"
"[...] To boot from a CD-ROM or DVD-ROM in the boot services
environment, an EFI System partition is stored in a “no emulation� mode as defined by the “El Torito� specification. [...] EFI differs from “El Torito� “no emulation� mode in that it does not load the “no emulation� image into memory and jump to it. EFI interprets the “no emulation� image as an EFI system partition."
------------------------------------------------------------------
So i think the general role of an El Torito boot image is not a strong reason to reject its view as full flegded EFI system partition.
But i see other reasons to restrict its role to an opaque launcher for software in a directory of the ISO:
The El Torito catalog format implies size restriction to 32 MB. EFI allows open end by size 0, but that's really not very neat.
I assume the higher boot stages of BIOS and EFI can share a lot of GRUB2 software. The GRUB2 software needed for BIOS traditionally resides in ISO 9660 directories.
So it is easier and less error prone to re-use it there rather than changing the BIOS boot procedure to finding the ESP and using its software.
Have a nice day :)
Thomas
В Sat, 20 Jun 2015 11:16:47 +0100
Ross Lagerwall <[email protected]> пишет:
Quoted 3 lines
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.
Quoted 4 lines
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
Quoted 9 lines
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.
bor@opensuse:~> /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
bor@opensuse:~> sudo losetup
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE/dev/loop0 0 0 0 0 /tmp/usb
bor@opensuse:~> sudo mount /dev/loop0p2 /mnt
bor@opensuse:~> sudo pkgdatadir=$PWD ./grub-install -d grub-core --boot-directory=/mnt --efi-directory=/mnt --removable
bor@opensuse:~/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
bor@opensuse:~> dd if=/dev/loop0p2 of=/tmp/efi.img
bor@opensuse:~> 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.
bor@opensuse:~/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
Quoted 2 lines
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.
Quoted 9 lines
[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
Quoted 2 lines · Ross Lagerwall
GRUB calculates a boot device based on the device path given by the firmware so:
Please reread what Andrei said. GRUB combines stored prefix and information from firmware. Syntax ()/boot/grub will always use the full disk