From owner-freebsd-embedded@FreeBSD.ORG Wed Jan 15 19:50:37 2014 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 356FC679; Wed, 15 Jan 2014 19:50:37 +0000 (UTC) Received: from wonkity.com (wonkity.com [67.158.26.137]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D86DE1FB0; Wed, 15 Jan 2014 19:50:36 +0000 (UTC) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.14.7/8.14.7) with ESMTP id s0FJoY3X083402; Wed, 15 Jan 2014 12:50:34 -0700 (MST) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.14.7/8.14.7/Submit) with ESMTP id s0FJoXxW083399; Wed, 15 Jan 2014 12:50:33 -0700 (MST) (envelope-from wblock@wonkity.com) Date: Wed, 15 Jan 2014 12:50:33 -0700 (MST) From: Warren Block To: Ian Smith Subject: Re: Creating code slice before disk image in nanobsd In-Reply-To: <20140116034220.B43023@sola.nimnet.asn.au> Message-ID: References: <20120629133759.GA19373@snail.casa> <20140114161533.GB19601@snail.casa> <6027B660-1D2E-4058-B87F-83D8225F0DC3@bsdimp.com> <20140116034220.B43023@sola.nimnet.asn.au> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (wonkity.com [127.0.0.1]); Wed, 15 Jan 2014 12:50:34 -0700 (MST) Cc: "freebsd-embedded@freebsd.org" X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jan 2014 19:50:37 -0000 On Thu, 16 Jan 2014, Ian Smith wrote: > On Wed, 15 Jan 2014 07:53:08 -0700, Warner Losh wrote: > > > I'll take a look at things... It isn't obvious at first blush this is > > the right thing to do, but I need to think about it a bit... > > > > Warner > > Perhaps an aside, but I'm pretty sure Warren (cc'd) has said that gpart > can do anything that fdisk AND bsdlabel can do? Yes. Although there is an exception: gpart silently forces alignment to CHS values on MBR slices, and fdisk does not. So to get a 4K-aligned slice requires fdisk. gpart can align BSD partitions inside a slice to 4K, but that is a workaround. (I believe gpart should default to CHS but use -a alignment or -b values when given for MBR slices, regardless of the MBR spec. This becomes increasingly important as 4K drives and SSDs become more common.) > If that's so, and the > object here is to deprecate fdisk, why not also replace these lines: > > + > + bsdlabel -w -B -b ${NANO_WORLDDIR}/boot/boot ${MD} > + bsdlabel ${MD} > + > > with their gpart equivalents? > > (and no, I don't know what those should be in this context) To create the initial MBR, probably already done before the code above: gpart create -s mbr ${MD} gpart bootcode -b ${NANO_WORLDDIR}/boot/boot ${MD} To create a slice and set it active: gpart add -s freebsd ${MD} [1] gpart set -a active -i1 ${MD} To create the BSDlabel inside the slice and write the bootcode to it: gpart create -s bsd ${MD}s1 gpart bootcode -b ${NANO_WORLDDIR}/boot/boot ${MD}s1 Then BSD partitions can be added with, for example: gpart add -t freebsd-ufs -s2g ${MD}s1 [2] [1] when creating the slice, -a4k or -b1m can be specified but will be silently rounded to CHS values [2] when creating BSD partitions, -a4k can be used and they will be created with an offset inside the slice to end up aligned For reference, see http://www.wonkity.com/~wblock/docs/html/disksetup.html#_the_old_standard_mbr > cheers, Ian > > > On Jan 14, 2014, at 9:23 PM, Adrian Chadd wrote: > > > > > Yes, please! > > > > > > > > > -a > > > > > > > > > On 14 January 2014 08:15, Arrigo Marchiori wrote: > > >> Hello list, > > >> > > >> in 2012 I wrote a patch to build the code image before the full disk > > >> image. It seemed to apply cleanly to 8-STABLE and it seems to apply now > > >> cleanly to 9-STABLE. > > >> > > >> Another effect of that patch is using gpart instead of fdisk. > > >> > > >> Is it of interest to anyone? Shall I file a PR? > > >> > > >> You can find the original patch and explanation at > > >> http://lists.freebsd.org/pipermail/freebsd-embedded/2012-June/001580.html > > >> > > >> Regards, > > >> -- > > >> rigo > > >> > > >> http://rigo.altervista.org >