GSmartControl and any other command line tool (like fdisk
, smartctl
, cat /sys/block/sd*/queue/hw_sector_size
, cat /sys/block/sd*/queue/physical_block_size
) I had used report the same for both of my disks:
Sector Size: 512 bytes logical/physical
This is a default Ubuntu 18.10 (later upgraded to 19.04) installation. However, the stat -f
command on both disks reports:
Block size: 4096 Fundamental block size: 4096
Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something? Does the information returned by stat
(=4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?
Please note the following output (sdb2
is my root partition, sda
is my /home
disk):
# fdisk -l /dev/sd?
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SanDisk SDSSDH35
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Disk model: ADATA SU800NS38
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxxx....
Device Start End Sectors Size Type
/dev/sdb1 2048 1050623 1048576 512M EFI System
/dev/sdb2 1050624 500117503 499066880 238G Linux filesystem
# df / /home
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb2 244568380 17799136 214276188 8% /
/dev/sda 479670976 129685112 325550152 29% /home
In the old days, 512 byte sectors was the norm for disks. The system used to read/write sectors only one sector at a time, and that was the best that the old hard drives could do.
Now, with modern drives being so dense, and so fast, and so smart, reading/writing sectors only one sector at a time really slows down total throughput.
The trick was... how do you speed up total throughput, but still maintain compatibility with old/standard disk subsystems? You create a 4096 block size that are made up of eight 512 byte physical sectors. 4096 is now the minimum read/write transfer to/from the disk, but it's handed off in compatible 512 byte chucks to the OS.
This means that even if the system only needs one 512 byte sector of information, the drive reads eight 512 byte sectors to get it. If however, the system needs the next seven sectors, it's already read them, so no disk I/O needs to occur... hence a speed increase in total throughput.
Modern operating systems can fully take advantage of native 4K block sizes of modern drives.
According to Wikipedia "Advanced Format (AF) is any disk sector format used to store data in disk drives that exceeds 512, 520, or 528 bytes per sector, such as the 4096-byte sectors of an Advanced Format Drive (AFD)." Advanced Format (AF) is a disk format that natively uses a sector size of 4,096 bytes instead of 512 bytes. To maintain compatibility with legacy systems, AF disks emulate a sector size of 512 bytes.
I got the same results as you got by running
sudo fdisk -l /dev/sdX
(whereX
is a letter) on two SSDs. I also got the same results as you got by runningstat -f
andsmartctl
on two SSDs. Both SSDs were automatically recognized by the OS when they were installed and required zero configuration, so it appears that the data you got is the default settings for block size and sector size.Old hardware and Operating Systems used 512 byte sectors, since 2011 (almost) all storage hardware has 4096 (or larger) byte sectors; but some hardware supports emulation of 512 byte sectors for legacy systems. There are exceptions, the Samsung 840 EVO SSD has blocks of size 2048 KB.
An Error Correcting Code (ECC) is calculated for each 512 byte chunk, and as you can imagine, ECC data also requires storage space. It goes without saying that one 4096 byte sector requires less ECC information than eight 512 byte chunks if the ECC algorithms remain unchanged. In the end, the total storage capacity of a hard drive increases as a result of less ECC data overhead.
Using 4K sectors makes sense from an architectural standpoint, as other key figures (like x86 memory pages and many file system clusters) also employ the 4 KB size. The Advanced Format allows for more robust ECC algorithms, which is important in light of ever-increasing capacities. Controllers employ additional techniques beyond error correction through an understanding of the NAND flash memory error characteristics and the workload behavior.
Advanced Format (AF) is any disk sector format used to store data on magnetic disks in hard disk drives (HDDs) that exceeds 512, 520, or 528 bytes per sector, such as the 4096, 4112, 4160, and 4224-byte (4 KB) sectors of an Advanced Format Drive (AFD). Larger sectors enable the integration of stronger error correction algorithms to maintain data integrity at higher storage densities.
For SCSI (SAS) disks the RAID block size is larger than a JBOD block size due to the SCSI T10 standardized data integrity fields along with logical bad block checking stored on each block with the data. The SAS RAID adapters support disk blocks based on 512 Bytes of data or 4K Bytes of data. The RAID block size for the 512 disks is 528 Bytes per sector and the RAID block size for the 4K disks is 4224 bytes per sector.
Because you are writing to memory and not a spinning disk physical sector size has less effect than ensuring that your partitions are aligned with the erase block size. Even so it's best to have up to date software and hardware, and use 4K sector size.
The larger sector size is recommended by Intel - "Gain Optimal Performance by Changes to SSD Physical Sector Size".