From owner-freebsd-fs@FreeBSD.ORG Mon Mar 18 12:03:05 2013 Return-Path: Delivered-To: freebsd-fs@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AD9F75B1 for ; Mon, 18 Mar 2013 12:03:05 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx07.syd.optusnet.com.au (fallbackmx07.syd.optusnet.com.au [211.29.132.9]) by mx1.freebsd.org (Postfix) with ESMTP id 10D8A695 for ; Mon, 18 Mar 2013 12:03:03 +0000 (UTC) Received: from mail04.syd.optusnet.com.au (mail04.syd.optusnet.com.au [211.29.132.185]) by fallbackmx07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id r2I6HhVC010164 for ; Mon, 18 Mar 2013 17:17:43 +1100 Received: from c211-30-173-106.carlnfd1.nsw.optusnet.com.au (c211-30-173-106.carlnfd1.nsw.optusnet.com.au [211.30.173.106]) by mail04.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id r2I6HUCP025820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 18 Mar 2013 17:17:32 +1100 Date: Mon, 18 Mar 2013 17:17:30 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Peter Maloney Subject: Re: Aligning MBR for ZFS boot help In-Reply-To: <5141BA2A.9080904@brockmann-consult.de> Message-ID: <20130318170513.X1164@besplex.bde.org> References: <513C1629.50501@caltel.com> <513CD9AB.5080903@caltel.com> <513CE369.4030303@caltel.com> <1362951595.99445.2.camel@btw.pki2.com> <513E1208.5020804@caltel.com> <20130312203745.A1130@besplex.bde.org> <513F8F04.60206@caltel.com> <20130313232247.B1078@besplex.bde.org> <5140F373.1010907@caltel.com> <20130314195715.Y909@besplex.bde.org> <5141B8B6.4010209@brockmann-consult.de> <5141BA2A.9080904@brockmann-consult.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=JMpjKL2b c=1 sm=1 a=u3bVZBOdoLwA:10 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=cUKNXEIY390A:10 a=KQk-SLzs4LMGY7x5F1IA:9 a=CjuIK1q_8ugA:10 a=TEtd8y5WR3g2ypngnwZWYw==:117 Cc: freebsd-fs@FreeBSD.org 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: Mon, 18 Mar 2013 12:03:05 -0000 On Thu, 14 Mar 2013, Peter Maloney wrote: > On 2013-03-14 12:47, Peter Maloney wrote: >> On 2013-03-14 10:41, Bruce Evans wrote: >>> On Wed, 13 Mar 2013, Cody Ritts wrote: >>> >>>> So, by setting those CHS values I am: >>>> making the partition table more compatible with other operating >>>> systems and BIOSes? >>>> and giving some utilities the CHS stuff they need to function right? >>> It's not completely clear that S=32 H=64 is portable, but it is what most >>> old SCSI BIOSes used. >>> >>> Also, if the disk already has some partitions with a certain geometry, >>> use >>> the same geometry for other partitions and don't use fdisk's defaults if >>> they differ. >>> >>> Bruce >> Oh man... I thought yeah that -a 1 or -a 2048 should work, but it >> doesn't. And then I thought I'd be extra crafty and use dd to directly >> write the partition table myself and send that as a solution to you >> guys, but even that fails! >> >> Here's writing a 63 alignment mbr to the disk, just to prove dd can do this: >> >> # gdd if=mbr.img of=/dev/md10 bs=512 count=1 >> 1+0 records in >> 1+0 records out >> 512 bytes (512 B) copied, 16.8709 s, 0.0 kB/s >> >> # gpart show md10 >> => 63 4194241 md10 MBR (2.0G) >> 63 40950 1 freebsd (20M) >> 41013 4153291 - free - (2G) >> >> Here's changing the start sector on the first partition to 2048 ;) >> Writing to the device works with bs=512, but not bs=1, so we use a file >> and bs=1 to do our edits, and then bs=512 to the disk. I use files too often to edit disks, because the binary editor that I use is old and assumes that block devices aren't broken, so it doesn't do its own blocking and thus always fails for disks, since it always writes 1 byte at a time. Of course, it is safer to edit a copy, but then it is too easy to make an error with the input or output offsets when dd'ing the files back to the disk. >> # gdd if=<(echo -ne "\x00\x08" ) of=mbr.img bs=1 seek=454 >> 2+0 records in >> 2+0 records out >> 2 bytes (2 B) copied, 0.000112023 s, 17.9 kB/s >> >> Here's writing the new 2048 aligned mbr to the disk: >> >> # gdd if=mbr.img of=/dev/md10 bs=1 count=1 >> gdd: writing `/dev/md10': *Invalid argument* >> 1+0 records in >> 0+0 records out >> 0 bytes (0 B) copied, 21.0247 s, 0.0 kB/s >> >> :O >> _________________________________________ > > Oh, and I almost forgot the most important part... the solution! > > The solution is to align to 129024 sectors instead, which fits the needs > of modern 512/1024/2048 alignment, and also the crazy old thing. Except it is beyond the end of the disk for a crazy old fdisk :-). > # gpart add -t freebsd -a 129024 -s 1M md10 > md10s1 added > # gpart add -t freebsd -a 129024 -s 1511M md10 > md10s2 added > # gpart show md10 > => 63 4194241 md10 MBR (2.0G) > 63 128961 - free - (63M) > 129024 2016 1 freebsd (1M) > 131040 127008 - free - (62M) > 258048 2967552 2 freebsd (1.4G) > 3225600 968704 - free - (473M) > ... Bruce