Sector-size and advanced format (4k) disks

Trond Endrestøl Trond.Endrestol at
Tue Sep 5 13:07:22 UTC 2017

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)

A Brief History of the BSD Fast Filesystem, Kirk McKusick (AsiaBSDCon '08)


More information about the freebsd-questions mailing list