From owner-freebsd-fs@FreeBSD.ORG Fri Feb 23 10:11:46 2007 Return-Path: X-Original-To: freebsd-fs@FreeBSD.org Delivered-To: freebsd-fs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7ED8416A400 for ; Fri, 23 Feb 2007 10:11:46 +0000 (UTC) (envelope-from bde@zeta.org.au) Received: from mailout1.pacific.net.au (mailout1-3.pacific.net.au [61.8.2.210]) by mx1.freebsd.org (Postfix) with ESMTP id 2114B13C47E for ; Fri, 23 Feb 2007 10:11:46 +0000 (UTC) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout1.pacific.net.au (Postfix) with ESMTP id B73C25A1D56; Fri, 23 Feb 2007 21:11:44 +1100 (EST) Received: from besplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id 482872741A; Fri, 23 Feb 2007 21:11:43 +1100 (EST) Date: Fri, 23 Feb 2007 21:11:41 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: j w In-Reply-To: Message-ID: <20070223184946.A14691@besplex.bde.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-fs@FreeBSD.org Subject: Re: strange fdisk numbers X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Feb 2007 10:11:46 -0000 On Thu, 22 Feb 2007, j w wrote: > I am working up the courage to use growfs, but got a little confused > by fdisk's numbers. > The output is below, but what interests me is that it says "heads=16", > but then later on has some partitions(slices) saying "head 254" and > such This has been broken since FreeBSD-4. > there's 16 tracks/cylinder, so maybe that figures in the calculation > somehow? (16 tracks * 16 heads ?) > > I put the output of bsdlabel -A as well > ******* Working on device /dev/ad2 ******* > parameters extracted from in-core disklabel are: > cylinders=26310 heads=16 sectors/track=63 (1008 blks/cyl) After FreeBSD-4, almost everything is broken here: o The parameters weren't actually extracted from the in-core disk label. They were extracted from the "firmware". The "firmware" is usually the drive firmware, except possibly for very old drives which have broken or barely existing firmware, in which case the parameters are fictitious. o The firmware parameters are not the ones needed here. The BIOS parameters are the ones needed. In FreeBSD[2-4], the parameters here were actually extracted from the in-core disk label (for the whole disk), and the latter were set to the system's best guess at the BIOS parameters, so they were actually useful here and in sysinstall's fdisk in cases where they were guessed correctly (mainly in cases where a non-weird fisk table already existed; otherwise, "firmware" parameters were set in the in-core label). So the procedure for getting the correct parameters here is the same in all cases as it was in FreeBSD-[2-4] in the case where the fdisk table doesn't already exist: o ignore the "extracted" parameters here o type in the correct parameters. If an fdisk table already exists, then the correct parameters are the ones used to create the table. These may be determined from one or more of: - your records of what you type in to create the table. - BIOS configuration. What you typed in there, or auto-detected. - FreeBSD[2-4] fdisk or disklabel on the whole disk. The system should auto-detect the BIOS parameters in the same way as the BIOS. - AnOtherOS wth non-broken fdisk on the whole disk. Might work under emulation under FreeBSD, depending on whether the auto-detection is in the kernel or the application. (FreeBSD puts it in the kernel so that it doesn't need to be duplicated in utilities.) If the fdisk table doesn't exist, then almost any parameters that you type in can work, but parameters should be chosen for consistency and portability. Generally, it is best to configure the parameters in the BIOS and duplicate what you got or typed in there. Note that fdisk(8) permits typing in unreasonable (invalid) parameters. The fdisk in sysinstall(8) has more sanity checking, but at least in RELENG_6 its sanity checking is insane so it gets in the way of typing in reasonable (valid) parameters. E.g., the now-standard ATA "firmware" geometry of 16 heads and 63 sectors/track is considered insane for disks larger than 33GB (1GB = 10^9 bytes) since it gives > 65536 cylinders. This was only insane many years ago when BIOSes didn't support > 65536 (virtual) cylinders at much the same time that BIOSes didn't support disks larger than 33GB. Now it is only insane for old BIOSes. sysinstall also considers more than 63 sectors/ track to be insane, but newer BIOSes support up to about 255 sectors/ track. Some BIOSes even default to 255 (?) sectors/track when they don't need to, so if sysinstall actually knows the BIOS geometry like it does in some cases in FreeBSD[2-4], then it considers the perfectly configured and working geometry to be insane, and "fixes" (breaks) it to a "sane" geometry. The parameters are irrelvant to growfs unless you need to grow a slice to make space for growing the fs. Then the same parameters as were used to create the slice should be used. Bruce