How does TrueNas selects ashift/sector size for SSD/HDD?

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
Hi,

Here is an example output of smartctl for my SSDs and the HDD
Code:
smartctl --xall /dev/da10
smartctl 7.2 2021-09-14 r5236 [FreeBSD 13.1-RELEASE amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               SEAGATE
Product:              ST800FM0053
Revision:             XGEC
Compliance:           SPC-4
User Capacity:        800,166,076,416 bytes [800 GB]
Logical block size:   512 bytes
Physical block size:  4096 bytes
LB provisioning type: not reported [LBPME=1, LBPRZ=0]
Rotation Rate:        Solid State Device
Form Factor:          2.5 inches
Logical Unit id:      0x5000c50030135897
Serial number:        Z3G014RB0000Z3G014RB
Device type:          disk
Transport protocol:   SAS (SPL-3)
Local Time is:        Thu Dec  8 16:58:43 2022 GMT
SMART support is:     Available - device has SMART capability.
SMART support is:     Enabled
Temperature Warning:  Enabled
Read Cache is:        Enabled
Writeback Cache is:   Enabled


Code:
smartctl --xall /dev/da2
smartctl 7.2 2021-09-14 r5236 [FreeBSD 13.1-RELEASE amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               HGST
Product:              HUC101818CS4205
Revision:             NE05
Compliance:           SPC-4
User Capacity:        1,800,360,124,416 bytes [1.80 TB]
Logical block size:   512 bytes
Physical block size:  4096 bytes
Formatted with type 2 protection
8 bytes of protection information per logical block
LU is fully provisioned
Rotation Rate:        10520 rpm
Form Factor:          2.5 inches
Logical Unit id:      0x5000cca02c655e70
Serial number:        08HTS73A
Device type:          disk
Transport protocol:   SAS (SPL-3)
Local Time is:        Thu Dec  8 16:59:37 2022 GMT
SMART support is:     Available - device has SMART capability.
SMART support is:     Enabled
Temperature Warning:  Enabled
Read Cache is:        Enabled
Writeback Cache is:   Disabled


Clearly the physical block size is 4K but TrueNas created the logical block size of 512 bytes? Is that a problem? I thought both should be match???

Here is diskinfo output:

Code:
diskinfo -v /dev/da10
/dev/da10
        512             # sectorsize
        800166076416    # mediasize in bytes (745G)
        1562824368      # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        97281           # Cylinders according to firmware.
        255             # Heads according to firmware.
        63              # Sectors according to firmware.
        SEAGATE ST800FM0053     # Disk descr.
        Z3G014RB0000Z3G014RB    # Disk ident.
        mpr1            # Attachment
        Yes             # TRIM/UNMAP support
        0               # Rotation rate in RPM
        Not_Zoned       # Zone Mode

root@truenas[/mnt/ssd_fast10/postgres]# diskinfo -v /dev/da2
/dev/da2
        512             # sectorsize
        1800360124416   # mediasize in bytes (1.6T)
        3516328368      # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        218881          # Cylinders according to firmware.
        255             # Heads according to firmware.
        63              # Sectors according to firmware.
        HGST HUC101818CS4205    # Disk descr.
        08HTS73A        # Disk ident.
        mpr0            # Attachment
        No              # TRIM/UNMAP support
        10520           # Rotation rate in RPM
        Not_Zoned       # Zone Mode


the diskinfo is showing the sector size to be 512 and My drives are of 4K? Am I doing it wrong?
I created the pools via GUI so I didn't mentioned any value of ashift=12.
 
Joined
Oct 22, 2019
Messages
3,641
I created the pools via GUI so I didn't mentioned any value of ashift=12
Using the GUI defaults to ashift=12

You can confirm with the following command:
Code:
zpool get ashift mypool


The smallest unit that can be written to your pool (hence the drives) is 4 KiB (because of ashift=12). Your physical sector size is 4 KiB. You're good to go.

:cool:
 

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
yup, all pools are showing the value of ashift = 12. It was just confusing me with the sector size of 512
 
Joined
Oct 22, 2019
Messages
3,641
It was just confusing me with the sector size of 512
If it's not a native "4 KiB only" drive (4Kn), it will report and emulate 512-byte sector size for "legacy" operating systems.

These "legacy" OSes include Windows 7 (and earlier) and Linux kernel prior to 2.6.31.

Irrelevant for those of us using modern OSes that do not attempt writes smaller than 4 KiB, anyways.
 
Last edited:
Joined
Jul 3, 2015
Messages
926
Most drives these days are native 4k but by default are logical 512 it's nothing to do with "TrueNAS making them that way". If your drive reports a logical block size of 512 it will be treated accordingly by TrueNAS. Back in the day you would choose at purchase if you wanted a 512 or 4k drive but not anymore they are all 4kn with logical 512 as an option and normally on by default.

I often have to 4k my new drives before building a pool out of them using
Code:
sg_format —format —ffmt=1 —size=4096 /dev/da0


After that both logical and physical are 4k.
 
Joined
Oct 22, 2019
Messages
3,641
I often have to 4k my new drives before building a pool out of them using
I'm not suggesting that you're wasting your time with that, but everything I've read (even from other users in this community) conclude that there is no real performance gain from this, and that not all drives support changing the logical sector size.

With a default of ashift=12 (4 KiB writes), and HDDs that have 4 KiB physical sectors, doing the above formatting of news drives has little real-world payoff.


 
Joined
Jul 3, 2015
Messages
926
It's more about space efficiency not performance from what I understand. Some say almost 10%.
 
Joined
Jul 3, 2015
Messages
926
Top