From owner-freebsd-current@FreeBSD.ORG Sun Aug 24 09:12:59 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 73E41435; Sun, 24 Aug 2014 09:12:59 +0000 (UTC) Received: from forward3l.mail.yandex.net (forward3l.mail.yandex.net [IPv6:2a02:6b8:0:1819::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "forwards.mail.yandex.net", Issuer "Certum Level IV CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1CB6E38B7; Sun, 24 Aug 2014 09:12:59 +0000 (UTC) Received: from smtp19.mail.yandex.net (smtp19.mail.yandex.net [95.108.252.19]) by forward3l.mail.yandex.net (Yandex) with ESMTP id 642261500CAA; Sun, 24 Aug 2014 13:12:47 +0400 (MSK) Received: from smtp19.mail.yandex.net (localhost [127.0.0.1]) by smtp19.mail.yandex.net (Yandex) with ESMTP id D632CBE0021; Sun, 24 Aug 2014 13:12:46 +0400 (MSK) Received: from 84.201.167.70-vpn.dhcp.yndx.net (84.201.167.70-vpn.dhcp.yndx.net [84.201.167.70]) by smtp19.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Qy2iT03wqv-CkROTsss; Sun, 24 Aug 2014 13:12:46 +0400 (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client certificate not present) X-Yandex-Uniq: 51b45e1d-c12e-42b5-b556-a3f0de073605 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1408871566; bh=KRT/oTy7tWb2c4Q9xEYyZwEpq0RlimMRURqz0ul6hmI=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:X-Enigmail-Version:Content-Type; b=SJeh2uCNVDe/EaSfFyAbjPiE3Sk6j0FwcjlMPuG2HkSqjfRdL/oz+ejUFN5YpeNpH U2/Lq976GHi1D8ocVADOPwzoP1lPmLad/9+tCAVPI0zDXhgjx7T77obJ8mF4sx7/Qa kl7LIIaq69Pe2bzAgzhJZLxvF/b4W72eZXapTr2Y= Authentication-Results: smtp19.mail.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: <53F9AC50.1000000@yandex.ru> Date: Sun, 24 Aug 2014 13:11:44 +0400 From: "Andrey V. Elsukov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Craig Rodrigues , Marcel Moolenaar Subject: Re: mkimg used to create gpt image, problem booting References: <853B0396-2C19-49DF-A8E8-8EB43D107597@xcllnt.net> <7CE168C1-6AF3-4AD2-80DB-192AEC49FD2B@xcllnt.net> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3CjR4WAJlF1aep8D2WqV7Xk1mehf7P342" Cc: freebsd-current Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Aug 2014 09:12:59 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --3CjR4WAJlF1aep8D2WqV7Xk1mehf7P342 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 24.08.2014 06:14, Craig Rodrigues wrote: > Hi, >=20 > I did some more experiments, and found that after /boot/loader runs, > if I break into the loader prompt and type "lsdev", I would get this: >=20 > (1) GPT Disk image which boots under QEMU, made by bsdinstall > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D > View from loader > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > OK lsdev > cd devices: > disk devices: > disk0: BIOS drive A: > disk1: BIOS drive C: > disk1p1: FreeBSD boot > disk1p2: FreeBSD UFS > disk1p3: FreeBSD swap > pxe devices: >=20 >=20 > View from gpart, after we mdconfig the disk image > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D> 34 10485693 md0 GPT (5.0G) > 34 128 1 freebsd-boot (64K) > 162 9959296 2 freebsd-ufs (4.7G) > 9959458 524288 3 freebsd-swap (256M) > 10483746 1981 - free - (991K) >=20 >=20 > (2) GPT Disk image which fails to boot under QEMU, made by mkimg > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D > View from loader > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > OK lsdev > cd devices: > disk devices: > disk0: BIOS drive A: > disk1: BIOS drive C: > pxe devices: >=20 > View from gpart, after we mdconfig the disk image > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > =3D> 3 1784944 md1 GPT (872M) > 3 32 1 freebsd-boot (16K) > 35 1784912 2 freebsd-ufs (872M) >=20 >=20 >=20 > This leads me to believe that there is logic in /boot/loader, > which is not in GEOM, that fails to parse the GPT produced by mkimg. >=20 >=20 > I did some further debugging inside the loader by doing the following. > -> I added "CFLAGS +=3D -DPART_DEBUG" to sys/boot/common/Makefile.inc= > -> I added DEBUG() statements all over sys/boot/common/part.c >=20 > I observed that in sys/boot/common/part.c in the ptbl_gptread() functio= n, > that in this section: >=20 > 305 ent =3D (struct gpt_ent *)tbl; > 306 size =3D MIN(hdr.hdr_entries * hdr.hdr_entsz, > 307 MAXTBLSZ * table->sectorsize); > 308 for (i =3D 0; i < size / hdr.hdr_entsz; i++, ent++) { > 309 if (uuid_equal(&ent->ent_type, &gpt_uuid_unused= , NULL)) > 310 continue; >=20 > ent->ent_type is all 0's, which matches gpt_uuid_unused, so it bails > out of the loop and never adds the gpt partitions to the list of partit= ions > that the loader can access. >=20 > I'm not familiar with the GPT format, nor am I familiar with the > gpt code inside the loader, and how it differs from GEOM. >=20 > Do you have any further ideas of where to hunt for the root cause of > the problem? Yes, the problem is in the ptable_gptread() function. I'll commit the fix= =2E --=20 WBR, Andrey V. Elsukov --3CjR4WAJlF1aep8D2WqV7Xk1mehf7P342 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQEcBAEBAgAGBQJT+axWAAoJEAHF6gQQyKF6n7YH/A2govCmT58wOKPHY41fWLSQ H+QG+CwrPZjYk+kSHwvtER3I6LMjID59XBc6NsKRQ3fYwmtRgZHiRSs0lelFpv60 5/7WZURmLvLIAdihc8v1TjIm5xdxNZSYVC5AkZwzjbHmp0KoU5MfN8up98OqsnoY TkuXGCVaGtqqT2ybCyggUyBEyyua6Wi58/sLF2ArzTMU8bwQIqSwjD+P/P61FurV ZzHxnYHjD8vkhhj8EFfzkt4mxAssyEihaARsjaLQ+F1GuTLWEW4XGf2oonfcJ4XS XsHWbCFGmi4aEgF1BEo3zoiRIzJpTgQZyTSIT6kVEPo+vPHXL2n+gSu2P5Hjl14= =+zgW -----END PGP SIGNATURE----- --3CjR4WAJlF1aep8D2WqV7Xk1mehf7P342--