Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Sep 2017 15:06:57 +0200 (CEST)
From:      =?ISO-8859-1?Q?Trond_Endrest=F8l?= <Trond.Endrestol@fagskolen.gjovik.no>
To:        Louie Cardone-Noott <lcn@fastmail.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Sector-size and advanced format (4k) disks
Message-ID:  <alpine.BSF.2.21.1709051451210.87288@mail.fig.ol.no>
In-Reply-To: <60623dab-3041-386d-4b19-9cc2e42c2424@fastmail.net>
References:  <60623dab-3041-386d-4b19-9cc2e42c2424@fastmail.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.21.1709051451210.87288>