From owner-freebsd-fs@FreeBSD.ORG Sun Mar 10 19:06:26 2013 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B2AB7D5 for ; Sun, 10 Mar 2013 19:06:26 +0000 (UTC) (envelope-from cr@caltel.com) Received: from mail1.caltel.com (mail1.caltel.com [66.102.144.6]) by mx1.freebsd.org (Postfix) with ESMTP id 550D6B2F for ; Sun, 10 Mar 2013 19:06:26 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqAEAGnYPFFCZpCq/2dsb2JhbABCwWCCYYFgdIImAQEEAThABgsLGAkWDwkDAgECAUUTCAEBiAkGu1KPFYNAA4hyjWOFZ4sOgyoc X-IPAS-Result: AqAEAGnYPFFCZpCq/2dsb2JhbABCwWCCYYFgdIImAQEEAThABgsLGAkWDwkDAgECAUUTCAEBiAkGu1KPFYNAA4hyjWOFZ4sOgyoc X-IronPort-AV: E=Sophos;i="4.84,819,1355126400"; d="scan'208";a="16945837" Received: from host-170.a66-102-144.caltel.com (HELO codys-mac.local) ([66.102.144.170]) by smtp.caltel.com with ESMTP/TLS/DHE-RSA-CAMELLIA256-SHA; 10 Mar 2013 12:06:19 -0700 Message-ID: <513CD9AB.5080903@caltel.com> Date: Sun, 10 Mar 2013 12:06:19 -0700 From: Cody Ritts Organization: CalTel User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130216 Thunderbird/17.0.3 MIME-Version: 1.0 To: freebsd-fs@freebsd.org Subject: Re: Aligning MBR for ZFS boot help References: <513C1629.50501@caltel.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2013 19:06:26 -0000 So, aligning to 63MB was still tricky. I found your thread, but I could not find step by step how to calculate the offset. So to put a close to this thread (hopefully), here is how I calculated my MBR alignment. The MBR seems to force partitions to start on a track There are 63 sectors/track Rule of thumb for SSD Erase Blocks is align to 1MB (2048s) I can start a partition on every 63rd sector: 63,126,189,252... etc 63 and 2048 have no common multiples, so 63x2048 = 129024 > root@:/root # gpart add -b 129024 -t freebsd ada0 > ada0s1 added > root@:/root # gpart show ada0 > => 63 125045361 ada0 MBR (59G) > 63 128961 - free - (63M) > 129024 124916400 1 freebsd (59G) YAY, my partition now starts at track 2048. 1MB for SSDs is a rule of thumb and most erase blocks are 128 256 or 512. (so I have read on the internet). Odds are, my SSD has an erase block of 512K or less, so, I can choose a smaller offset: 512K = 1024 sectors 1024*63 = 64512 > root@:/root # gpart add -b 64512 -t freebsd ada0 > ada0s1 added > root@:/root # gpart show ada0 > => 63 125045361 ada0 MBR (59G) > 63 64449 - free - (31M) > 64512 124980912 1 freebsd (59G) Anyway, that is good enough for me. In the end, here are my working commands to create an aligned MBR partition ready for zpool creation and boot. > gpart create -s mbr ada0 > gpart add -b 64512 -t freebsd ada0 > gpart create -s bsd ada0s1 > gpart add -s 52833M -t freebsd-zfs ada0s1 > gpart add -t freebsd-swap ada0s1 > gpart set -a active -i 1 ada0 > gpart bootcode -b /boot/mbr ada0 > dd if=/boot/zfsboot of=/dev/ada0s1 count=1 > dd if=/boot/zfsboot of=/dev/ada0s1a skip=1 seek=1024 Also as related bonus, if you are reading about alignment, here is how to get 4k blocks for your zpool on an SSD or AF/4K hard drive. > glabel label zfs /dev/ada0s1a > gnop create -S 4096 /dev/label/zfs > zpool create -R /mnt tank /dev/label/zfs.nop > zpool export tank > gnop destroy /dev/label/zfs.nop > zpool import -R /mnt -o cachefile=/tmp/zpool.cache system > zdb -U /tmp/zpool.cache | grep ashift > ashift: 12 2^12 = 4096 Thanks, Cody On 3/10/13 9:22 AM, Warren Block wrote: > On Sat, 9 Mar 2013, Cody Ritts wrote: > >> Poking around on the internet, it looks like gpart is possibly >> enforcing geometry boundaries? > > Not gpart, but the kernel. At present, I don't know of any way to use > FreeBSD for creating MBR slices aligned to anything other than 63 > blocks. FreeBSD partitions can be aligned inside a slice with an > offset. Putting ZFS on one of those partitions may be the easiest way > to do this. Put the slice at block 2016, then align the first FreeBSD > partition inside that slice to 1M and it should land at block 2048. > > Another option is to create the MBR with aligned slices using another > operating system, one that allows deviation from the MBR standard. > Ronald Guilmette recently showed an interesting approach of starting the > slice at 63M, the least common multiple of 63 and 1M. > > If the BIOS does not like GPT, check for BIOS updates. And make sure > the vendor knows about the problem. >