From owner-freebsd-questions@freebsd.org Tue Sep 5 13:07:22 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C69D2E08342 for ; Tue, 5 Sep 2017 13:07:22 +0000 (UTC) (envelope-from trond@fagskolen.gjovik.no) Received: from smtp.fagskolen.gjovik.no (smtp.fagskolen.gjovik.no [IPv6:2001:700:1100:1:200:ff:fe00:b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.fagskolen.gjovik.no", Issuer "Fagskolen i Gj??vik" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 70B3E65223 for ; Tue, 5 Sep 2017 13:07:22 +0000 (UTC) (envelope-from trond@fagskolen.gjovik.no) Received: from mail.fig.ol.no (localhost [127.0.0.1]) by mail.fig.ol.no (8.15.2/8.15.2) with ESMTPS id v85D6veR027462 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 5 Sep 2017 15:06:57 +0200 (CEST) (envelope-from trond@fagskolen.gjovik.no) Received: from localhost (trond@localhost) by mail.fig.ol.no (8.15.2/8.15.2/Submit) with ESMTP id v85D6vCu027459; Tue, 5 Sep 2017 15:06:57 +0200 (CEST) (envelope-from trond@fagskolen.gjovik.no) X-Authentication-Warning: mail.fig.ol.no: trond owned process doing -bs Date: Tue, 5 Sep 2017 15:06:57 +0200 (CEST) From: =?ISO-8859-1?Q?Trond_Endrest=F8l?= Sender: Trond.Endrestol@fagskolen.gjovik.no To: Louie Cardone-Noott cc: freebsd-questions@freebsd.org Subject: Re: Sector-size and advanced format (4k) disks In-Reply-To: <60623dab-3041-386d-4b19-9cc2e42c2424@fastmail.net> Message-ID: References: <60623dab-3041-386d-4b19-9cc2e42c2424@fastmail.net> User-Agent: Alpine 2.21 (BSF 202 2017-01-01) Organization: Fagskolen Innlandet OpenPGP: url=http://fig.ol.no/~trond/trond.key MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.2 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail.fig.ol.no X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2017 13:07:22 -0000 On Mon, 4 Sep 2017 21:48+0100, Louie Cardone-Noott wrote: > Dear list, > > I searched the handbook, archives, and web but couldn't find a concrete answer > to this. > > From what I can work out: > 1. for compatibility, most HDDs these days present themselves as having 512 B > logical / 4 k physical sectors > 2. freebsd newfs (typically) sets a sector-size of 512 B and a fragment size > of 4 k > > Some questions then please. First, is it optimal to force the sector size to 4 > k to match the physical sector size, or is the default (point 2, above) fine? > Second, how alarmed should I be that `man newfs` says setting the sector-size > makes it impossible for fsck to find alternate superblocks? > > I thought partitioning with (say) 1 M alignment and invoking newfs with `-S > 4096` would be best. True or false? The default block size (-b) is 32768 bytes, which is a multiple of both 512 bytes and 4096 bytes. The default fragment size (-f) is 4096, still a multiple of both 512 bytes and 4096 bytes. newfs(8) states: The optimal block:fragment ratio is 8:1. Other ratios are possible, but are not recommended, and may produce poor results. A file containing a single byte will thus consume 4096 bytes of disk space, i.e. eight disk blocks. I guess you can create a file system of your desire by specifying -b 4096 -f 512, in which a file consisting of a single byte will only consume 512 bytes of disk space, i.e. one disk block. Changing the sector size is not recommended according to newfs(8): The following options override the standard sizes for the disk geometry. Their default values are taken from the disk label. Changing these defaults is useful only when using newfs to build a file system whose raw image will eventually be used on a different type of disk than the one on which it is initially created (for example on a write-once disk). Note that changing any of these values from their defaults will make it impossible for fsck(8) to find the alternate superblocks if the standard superblock is lost. -S sector-size The size of a sector in bytes (almost never anything but 512). Maybe Dr. McKusick's lectures can enlighten you to make a wise choice: Keynote Address: A Brief History of the BSD Fast Filesystem (FAST '15) https://www.youtube.com/watch?v=TMjgShRuYbg A Brief History of the BSD Fast Filesystem, Kirk McKusick (AsiaBSDCon '08) https://www.youtube.com/watch?v=tzieR5MM06M -- Trond.