From nobody@FreeBSD.org  Thu Feb  6 17:43:48 2014
Return-Path: <nobody@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 DF6527C2
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  6 Feb 2014 17:43:48 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id C64A21158
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  6 Feb 2014 17:43:48 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id s16HhmBP044389
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 6 Feb 2014 17:43:48 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id s16Hhm58044388;
	Thu, 6 Feb 2014 17:43:48 GMT
	(envelope-from nobody)
Message-Id: <201402061743.s16Hhm58044388@oldred.freebsd.org>
Date: Thu, 6 Feb 2014 17:43:48 GMT
From: "Yeong.Hun, Jo" <jyhpsycho@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Doesn't boot with GPT when # of entries over than 128.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         186515
>Category:       kern
>Synopsis:       [gptboot] Doesn't boot with GPT when # of entries over than 128.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-fs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 06 17:50:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Sat Feb  8 00:10:00 UTC 2014
>Originator:     Yeong Hun, Jo
>Release:        FreeBSD 10.0-RELEASE
>Organization:
-
>Environment:
FreeBSD localhost 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 1 22:34:59 UTC 2014     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
I tried to making USB memory stick using GPT partition table scheme. I usually use 152 entries to aligning 4KB boundary for data disk(start location) and use 156 entries to aligning 4KB boundary for system disk(end location, misalignment of start location is used for boot code and make 4KB aligned root partition). I don't like that some "free" sectors on disk :-)

But, it failed to boot when partition entry count is adjusted to more than 128.

* WORKS : 128 entries GPT(1st usable sector = 34) with freebsd-boot partition at sector 34, 40.

* DOESN'T WORK : 152 entries GPT(1st usable sector = 40) with freebsd-boot partition at sector 40, 156 entries GPT(1st usable sector = 41) with freebsd-boot partition at sector 41.



Yes, There's no problem with default size GPT partition table. "128 entires" - minimum entry count by spec. - seems to be sufficient at most cases. But, that can be arbitrary size and should be supported even that cases. I think there's some issue on gpart or early-stage boot loader(/boot/pmbr).

>How-To-Repeat:
* For example, USB disk is da0 here.

# gpart create -s gpt -n 152 da0
# gpart add -t freebsd-boot -b 40 -s 32 -i 1 da0
# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0

and try to boot USB. It should be show "clockwise" loading screen even no freebsd-ufs partition on USB, but it doesn't show anything and reboot immediately. It(doesn't say anything and reboot) occurs with /boot populated freebsd-ufs partition, too.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-amd64->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Feb 6 17:54:43 UTC 2014 
Responsible-Changed-Why:  
reclassify. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=186515 

From: John Baldwin <jhb@freebsd.org>
To: freebsd-amd64@freebsd.org
Cc: Yeong.Hun@freebsd.org,
 Jo <jyhpsycho@gmail.com>,
 freebsd-gnats-submit@freebsd.org
Subject: Re: amd64/186515: Doesn't boot with GPT when # of entries over than 128.
Date: Thu, 6 Feb 2014 13:41:04 -0500

 Using more entries to pad out the table isn't the normal way to handle 4k 
 alignment.  You can just leave a gap before the start of freebsd-boot.  Having 
 the sectors "free" vs having them contain zero'd GPT entries doesn't really 
 make a difference.  One question is when does the boot break?  Does it make it 
 into the loader and break trying to boot the kernel?  Does it make it into 
 gptboot and break trying to load the loader?
 
 -- 
 John Baldwin

From: =?UTF-8?B?7KGw7JiB7ZuI?= <jyhpsycho@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: amd64/186515: Doesn't boot with GPT when # of entries over than 128.
Date: Sat, 8 Feb 2014 09:07:43 +0900

 --001a11c109c445bcfd04f1d9e525
 Content-Type: text/plain; charset=UTF-8
 
 That's right. Actually there's no any differences - between "free" sectors
 to "empty entries". In most cases 128 entries will be sufficient I said
 before. And I know that's not preferred way to align partitions. But, GRUB2
 works even that cases. Of course that isn't GNU extension. Because of
 there's no any differences except total entry count, I think it should be
 work.
 
 I think there's some problem loading freebsd-boot partition. When I
 selected USB stick at boot menu, I can't see anything except black screen
 and it reboots immediately. If it boots correctly, it should display
 loading screen - rotating animation - and (if freebsd-ufs partition exists
 and /boot populated) Greeting message such as "BTX Loader 1.00 BTX Version
 is 1.02", then "Welcome to FreeBSD". I checked that behavior with work
 cases(128 entries, different boot partition's start location), and I found
 that it should display "rotating animation" even there's not exist
 later-step bootloader files in /boot; In that case, it automatically
 reboots after shows that animation because there's no freebsd-ufs partition.
 
 
 
 * I'm first use of FreeBSD's bug reporting system and it causes some
 confusion to me. I replied same mail to John, but not bug-followup system
 and I guess it is what my reply doesn't seen on bug tracking system. I hope
 that send reply mail to this address is right...
 
 --001a11c109c445bcfd04f1d9e525
 Content-Type: text/html; charset=UTF-8
 Content-Transfer-Encoding: quoted-printable
 
 <div dir=3D"ltr"><div><div>That&#39;s right. Actually there&#39;s no any di=
 fferences - between &quot;free&quot;=20
 sectors to &quot;empty entries&quot;. In most cases 128 entries will be suf=
 ficient
  I said before. And I know that&#39;s not preferred way to align partitions=
 .
  But, GRUB2 works even that cases. Of course that isn&#39;t GNU extension.=
 =20
 Because of there&#39;s no any differences except total entry count, I think=
 =20
 it should be work.<br>
 <br></div>I think there&#39;s some problem loading freebsd-boot=20
 partition. When I selected USB stick at boot menu, I can&#39;t see anything=
 =20
 except black screen and it reboots immediately. If it boots correctly,=20
 it should display loading screen - rotating animation - and (if=20
 freebsd-ufs partition exists and /boot populated) Greeting message such=20
 as &quot;BTX Loader 1.00 BTX Version is 1.02&quot;, then &quot;Welcome to F=
 reeBSD&quot;. I=20
 checked that behavior with work cases(128 entries, different boot=20
 partition&#39;s start location), and I found that it should display=20
 &quot;rotating animation&quot; even there&#39;s not exist later-step bootlo=
 ader files=20
 in /boot; In that case, it automatically reboots after shows that=20
 animation because there&#39;s no freebsd-ufs partition.<br><br><br><br></di=
 v>* I&#39;m first use of FreeBSD&#39;s bug reporting system and it causes s=
 ome confusion to me. I replied same mail to John, but not bug-followup syst=
 em and I guess it is what my reply doesn&#39;t seen on bug tracking system.=
  I hope that send reply mail to this address is right...<br>
 </div>
 
 --001a11c109c445bcfd04f1d9e525--
>Unformatted:
