ZFS with 4K sectors

6502

New Member

Reaction score: 2
Messages: 11

Hello. Is it good idea to use ZFS with 4K sectors if the system is with 512-byte sector HDD and no SSD? I guess some disk space will be lost because of larger sectors but don't know whether small sectors (512) will waste more RAM or other resources.
 

tommiie

Active Member

Reaction score: 40
Messages: 155

I'm not an expert but I would go for 4k sectors so that you can more easily upgrade later on. Also, even though the HDD might report that it has 512-byte sectors, in fact they could be 4k in reality.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,292
Messages: 29,742

Most disks lie about their sector sizes. Besides that, modern filesystems use block suballocation, so slack isn't as big of a problem as it used to be.
 

ralphbsz

Daemon

Reaction score: 1,007
Messages: 1,627

Unless your disks are over 10 years old, they probably do already have 4K sectors in hardware. Just as SirDice said.

The other thing is that for most workloads, the lost of disk space is not relevant. Yes, you may have many small files, and wasting a little extra space for each small file may look like a lot of waste. But the bulk of your disk space use is probably not coming from those many small files, but from a smallish number of large files. For most real-world workloads, using 4K blocks in the file system is a net gain in performance, with a negligible loss of capacity. There are exceptions, for example supercomputing cluster workloads for certain forms of genetic (biochemistry) data sets, which do create billions of tiny files. But you are probably not running those workloads.

If you feel like doing this scientifically, try this: make a little script that makes a list of all file sizes (pretty easy to do with find and xargs), then bin the file sizes by powers of 2, and count them for each bin. Then draw yourself the distribution of file sizes, weighted by file size. Most likely, you will see that stuff below a few kB is just not relevant.
 
OP
OP
6502

6502

New Member

Reaction score: 2
Messages: 11

The disk is 320GB Hitachi about 10 years old. At that time 4K was something advanced and I think nobody will lie that it is with 512b sectors. The lost disk space is not important. I am interested about other resources (RAM/CPU) used by ZFS. I hope this depends on number of sectors and with 4K is better from this viewpoint.
 

tommiie

Active Member

Reaction score: 40
Messages: 155

Don't forget it is easier to upgrade your vdev later with new disks should you now choose 4k sector sizes.
 
Top