From owner-freebsd-current@FreeBSD.ORG Sun Aug 24 22:37:58 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 BA6C296F for ; Sun, 24 Aug 2014 22:37:58 +0000 (UTC) Received: from mail-la0-x22f.google.com (mail-la0-x22f.google.com [IPv6:2a00:1450:4010:c03::22f]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3EB1D3BF0 for ; Sun, 24 Aug 2014 22:37:58 +0000 (UTC) Received: by mail-la0-f47.google.com with SMTP id mc6so11788598lab.6 for ; Sun, 24 Aug 2014 15:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=R+KxdUqh69NoM+fAVX7Q11XGfkP96OUAsopBdwjap4o=; b=YqdapJW3lFNPJzWDRXV7YvEVA2mRrpRyGjhfHCVT6Gv3Wc5CMSkPJ7U8wzloVvWqj2 L8axeSNvCLQSuak8AZgWsiK6koL4/sizz4OXFIB0MIW4zlYPI8PEZ0BbS4Dinel5+Sj5 3oBC9L4o1Ww90U7Aqj/50IEH2jgcaxIwVX8/wb+nug/OkDptLRAoFW0E4OaQGWHbNC1q mVd75564umg03DUwp6Ik80Axz/O4Q1RAc0QeyvDAgR/gaAaJw45MxpPmd1FzLLsaj6yF IG3kKKY52Wi+jLXoGY3vt7t7NmQ0Lwo8m9LRvGw8hNXos7YrAI7SMjxsyeLVoUN1dkz2 akvQ== MIME-Version: 1.0 X-Received: by 10.112.184.161 with SMTP id ev1mr4043523lbc.82.1408919875925; Sun, 24 Aug 2014 15:37:55 -0700 (PDT) Sender: crodr001@gmail.com Received: by 10.112.197.107 with HTTP; Sun, 24 Aug 2014 15:37:55 -0700 (PDT) In-Reply-To: <82000B55-10E5-4348-9F35-38962965A63C@xcllnt.net> References: <853B0396-2C19-49DF-A8E8-8EB43D107597@xcllnt.net> <7CE168C1-6AF3-4AD2-80DB-192AEC49FD2B@xcllnt.net> <53F9AC50.1000000@yandex.ru> <82000B55-10E5-4348-9F35-38962965A63C@xcllnt.net> Date: Sun, 24 Aug 2014 15:37:55 -0700 X-Google-Sender-Auth: gd-4TOY0Dr-oro6rIP7Y4SgmOZ0 Message-ID: Subject: Re: mkimg used to create gpt image, problem booting From: Craig Rodrigues To: Marcel Moolenaar Content-Type: text/plain; charset=ISO-8859-1 Cc: "Andrey V. Elsukov" , 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 22:37:58 -0000 On Sun, Aug 24, 2014 at 12:05 PM, Marcel Moolenaar wrote: > > On Aug 24, 2014, at 9:59 AM, Craig Rodrigues wrote: > >> On Sun, Aug 24, 2014 at 2:11 AM, Andrey V. Elsukov wrote: >>> >>> Yes, the problem is in the ptable_gptread() function. I'll commit the fix. >> > >> Should mkimg be changed to create a partition table with 128 entries >> by default, to match older versions of FreeBSD which do not have this fix? > > Maybe. 128 is the suggested default. It's not a hard lower > limit. Technically speaking, it's perfectly fine to create > just enough entries to fill a single sector. Then again, > code makes all kinds of assumptions or has all kinds of > bugs -- just like the logic in the loader apparently. > > By having mkimg create a large table, even if it's knows > up front that it doesn't have to may prevent broken code > from tripping over, bit it surely bloats the image for > no reason. I see what you are saying. If you have a new device and do "gpart create -s GPT", then this value in sys/geom/part/g_part_gpt.c: .gps_minent = 128, causes the logic in the g_part_ctl_create() function in sys/geom/part/g_part.c to set the number of partitions to 128, and then it calls g_part_ctl_create() which creates the partition table with 128 empty entries. "gpart create" doesn't know how many partitions you want, so it needs to allocate some space up front for the partition table, and then you can do "gpart add" to add the partitions later. With mkimg, you know exactly how many partitions you are creating , so you don't need to specify 128 as the number of partitions. Since only gpart was available for creating GPT partitions, the side-effect of always having 128 partitions hid the bug in the loader. Hopefully Andrey's fix can be backported to at least stable/9, because the loader bug seems to have been there since at least 2012. -- Craig