From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Z6FpU-0000IL-M5 for mharc-grub-devel@gnu.org; Sat, 20 Jun 2015 06:16:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6FpR-0000IF-RL for grub-devel@gnu.org; Sat, 20 Jun 2015 06:16:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z6FpO-0007j9-Ja for grub-devel@gnu.org; Sat, 20 Jun 2015 06:16:49 -0400 Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]:34233) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6FpO-0007iv-85 for grub-devel@gnu.org; Sat, 20 Jun 2015 06:16:46 -0400 Received: by wicnd19 with SMTP id nd19so38212173wic.1 for ; Sat, 20 Jun 2015 03:16:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=CFGebgWyFtb7MQGFMrR8m0Y+NG1QjS5ZmNP3a9HOC3Q=; b=c89TQx73sTqn25ElTpGRLBTFRJgZh3kgvRLwXY/AyClW1dSfGzNOaLaE+IqW9fMChk jbvPXNB/pVld3hjcIruq0UsJl9pXR38xSC0NK1168o0/bAKQfbj6DfmXSl+0FxB8HHkL xilEq6rYtPikvPdk49QMOcIn49XKSfONSPN2VkRjhGhEp6oof5qSbba0u8zBai+novv1 M5tYSyN7Gt/k3iiooQUpVSgpbCup0GyQvtNG+xdqfWCmTSSuLLJ53eqq7StZ+909hiVC BqyIezcJtbrWyF2TlYlEqmAyWi1Oba0oUP1d81WOtIAsSi8NRsYz8RE+5QNInDNHdDIM 918w== X-Received: by 10.180.13.171 with SMTP id i11mr14274457wic.5.1434795405380; Sat, 20 Jun 2015 03:16:45 -0700 (PDT) Received: from hobo (208.24.189.80.dyn.plus.net. [80.189.24.208]) by mx.google.com with ESMTPSA id fo13sm7535197wic.0.2015.06.20.03.16.43 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 20 Jun 2015 03:16:44 -0700 (PDT) Date: Sat, 20 Jun 2015 11:16:47 +0100 From: Ross Lagerwall To: Andrei Borzenkov Subject: Re: [PATCH] core/partmap: Add El Torito boot catalog parsing Message-ID: <20150620101647.GA5671@hobo.lan> References: <1433672686-774-1-git-send-email-rosslagerwall@gmail.com> <20150608195144.69ed708c@opensuse.site> <20150608173106.GA9456@hobo.lan> <20150608205048.6f36750a@opensuse.site> <20150608182512.GA10375@hobo.lan> <20150608220117.5d8ce61e@opensuse.site> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WIyZ46R2i8wDzkSu" Content-Disposition: inline In-Reply-To: <20150608220117.5d8ce61e@opensuse.site> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22a Cc: grub-devel@gnu.org X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jun 2015 10:16:51 -0000 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 08, 2015 at 10:01:17PM +0300, Andrei Borzenkov wrote: > =D0=92 Mon, 8 Jun 2015 19:25:12 +0100 > Ross Lagerwall =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >=20 > > On Mon, Jun 08, 2015 at 08:50:48PM +0300, Andrei Borzenkov wrote: > > > =D0=92 Mon, 8 Jun 2015 18:31:06 +0100 > > > Ross Lagerwall =D0=BF=D0=B8=D1=88=D0=B5=D1= =82: > > >=20 > > > > On Mon, Jun 08, 2015 at 07:51:44PM +0300, Andrei Borzenkov wrote: > > > > > =D0=92 Sun, 7 Jun 2015 11:24:46 +0100 > > > > > Ross Lagerwall =D0=BF=D0=B8=D1=88=D0=B5= =D1=82: > > > > >=20 > > > > > > 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 t= he UEFI > > > > > > reference implementation. > > > > > >=20 > > > > > > This is useful when booting CDs in UEFI mode. Before, GRUB woul= d 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 cou= ld 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. > > > > >=20 > > > > > You can already access ESP on hybrid image using e.g. (cd0,msdos1= ); why > > > > > is it not enough? > > > >=20 > > > > This is about booting a CD in UEFI mode; it may not be a hybrid dis= c in > > > > which case it doesn't have an MBR. > > > >=20 > > >=20 > > > 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. > > >=20 > > > > 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. > > > >=20 > > >=20 > > > It may depend on how you create partition table. Neither openSUSE DVD > > > nor images created by grub-mkrescue have problems. Did you actually t= ry > > > it? > > >=20 > > > As example > > >=20 > > > 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. > > >=20 > > > 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>=20 > > >=20 > > > You may consider using xorriso to create image, it does quite good job > > > with hybrid images. > >=20 > > Yes I have tried, and I made a video of it :-) > > https://rossl.org/junk/grub.webm > >=20 > > See that GRUB is not able to access (cd0,msdos2), which is the embedded > > FAT partition. > >=20 >=20 > OK. What about using GPT? it definitely works, just tested. >=20 > > >=20 > > > > For these reasons, I think it is useful to parse the El Torito boot > > > > catalog. > > > >=20 > > >=20 > > > I'm not entirely opposed to it, I just do not see compelling reasons = to > > > do it :) > > >=20 > > > I actually think that viewing ESP as opaque binary executable and usi= ng > > > 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. > > >=20 > >=20 > > 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. > >=20 > > 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. > >=20 >=20 > 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=3D", "iso9660" and and that the "embedded grub.cfg" looks like search.fs_label RECOVERY root set prefix=3D($root)/boot/grub" Regards --=20 Ross Lagerwall --WIyZ46R2i8wDzkSu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iF4EAREIAAYFAlWFPYsACgkQMRWWudUHn2QmewEA6JSsIzw5tPyFaY7tr3rgGOd2 B8ysM038dN+GHWFr2EIA/0iMipAu+Gttfw+zbdktphINKq2JhyMEZnZIUCLdvDgo =gQn9 -----END PGP SIGNATURE----- --WIyZ46R2i8wDzkSu--