Advanced Sector Format of Block Devices

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

This article describes the new sector formatting (Advanced Format) that is being used by all of the major hard drive manufacturers and what should be kept in mind when using such hard drives. Advanced Format (or 4K) sectors offer advantages for hard drives with higher capacities and is now practically standard for hard drives >= 2TB.

Efficiency of Advanced Format

Advanced Format

Advanced Format is the term used to describe the increased sector size of hard drives from 512 bytes to 4KB. By increasing the sector size, the space on the hard drive is used more efficiently and thereby increases the amount of useable capacity. Also, the effect of errors is minimized as the size of a sector's ECC area is doubled[1].

512e

Advanced Format Emulation Logo

In order to ensure compatibility with older operating systems and older software, emulation of 512-byte sectors was implemented by manufacturers. To do this, eight 512-byte sectors are stored in a 4K sector and managed transparently for the system by the controller firmware. This emulation generally does not result in a noticeable performance drop for the hard drive though it does make write operations more complex.

Read Operations

Read operations are very simple compared to write operations:

  1. The host would like to read a 512-byte block.
  2. The controller loads the complete 4KB sector containing the requested 512-byte block.
  3. The controller extracts the data from the 512-byte block and delivers it in the corresponding format to the host.

Write Operations

Write operations use the "read-modify-write" method:

  1. The host would like to write a 512-byte block.
  2. The controller selects a suitable 4KB sector and loads it completely. (read)
  3. The controller modifies 512 bytes in the 4KB sector. (modify)
  4. The controller writes the modified 4KB sector to the hard drive. (write)

Compatibility

In order to keep performance constant, it is necessary that partitions on 512e hard drives be properly aligned (see also Partition Alignment) so that a 4KB sector contains exactly eight 512-byte blocks. Newer operating systems already correctly align the partitions (Windows > Vista SP1; Linux > 2.6.31 (fdisk > 1.2.3))[1]. With the correct alignment, write operations can be optimally cached by the hard drive controller, which optimizes performance.

Alignment states

4K Native

Advanced Format Native Logo

4K native or 4Kn describes hard drives that relay their 4KB sectors directly to the operating system without emulation. This means that the operating system and the software running on the system need to support 4K sectors[2]. Windows supports 4Kn as of 8.1 or Server 2012[3]; Linux from kernel 2.6.31[1].

Mode Recognition

To ascertain the mode of a connected hard drive (512n (512-byte native device), 512e, 4Kn) in Linux, Smartctl or hdparm can be used. This however requires that the hard drives are actually supplying correct data.

In our tests, hdparm proved more reliable in providing correct information on sector size.

512n hdparm

sudo hdparm -I /dev/<device>

The "Configuration" section provides both the physical and logical sector sizes. These values show whether emulation is being used.

[...]
Configuration:
[...]
	Logical  Sector size:                   512 bytes
	Physical Sector size:                   512 bytes
[...]

If both values are 512 bytes, no emulation is being used.

512e hdparm

sudo hdparm -I /dev/<device>
[...]
Configuration:
[...]
	Logical  Sector size:                   512 bytes
	Physical Sector size:                  4096 bytes
[...]

If the physical sector size is reported as 4096 bytes (or 4KB), emulation is being used.

512n smartctl

sudo smartctl -a /dev/<device>

With smartctl, the same information is found in the "Information Section".

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
[...]
Sector Size:      512 bytes logical/physical
[...]

512e smartctl

sudo smartctl -a /dev/<device>
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
[...]
Sector Sizes:     512 bytes logical, 4096 bytes physical
[...]

References

Related articles

I/O data throughput limits
Intel Active Management Technology Features
Safety instructions for AMD Flaws