# Advanced Format

From ArchWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The Advanced Format is a generic term pertaining to any disk sector format used to store data on magnetic disks in hard disk drives (HDDs) that uses 4 kilobyte sectors instead of the traditional 512 byte sectors. The main idea behind using 4096-byte sectors is to increase the bit density on each track by reducing the number of gaps which hold Sync/DAM and ECC (Error Correction Code) information between data sectors. The old format gave a format efficiency of 88.7%, whereas Advanced Format results in a format efficiency of 97.3%.

There are two types of AF drives:

- Advanced Format drives, marked with an orange "AF" logo: internally, they use 4k sectors, but provide an emulation layer for compatibility with OSes which lack support for them.
- Advanced Format 4k native drives, marked with a blue "4Kn" logo: they require OS support (Windows 8+, or Linux 2.6.31+). Because they do not need a translation layer, they are cheaper, however they might be incompatible with old tools.

## How to determine if HDD employ a 4k sector

The physical and logical sector size of hard disk `/dev/sdX` can be determined by reading the following sysfs entries:

    $ cat /sys/class/block/sdX/queue/physical_block_size
    $ cat /sys/class/block/sdX/queue/logical_block_size

Drives with a translation layer (see above) will usually report a logical block size of 512 (for backwards compatibility) and a physical block size of 4096 (indicating they are AF drives).

Tools which will report the sector of a drive (provided the drive will report it correctly) includes:

- fdisk:

    # fdisk -l /dev/sdX | grep 'Sector size'

- smartmontools since 5.41:

    # smartctl -a /dev/sdX | grep 'Sector Sizes:'

- hdparm since 9.12:

    # hdparm -I /dev/sdX | grep 'Sector size:'

Note that both works even for USB-attached discs (if the USB bridge supports SAT aka SCSI/ATA Translation, ANSI INCITS 431-2007).

## Filesystem sector size

The factual accuracy of this article or section is disputed.

Reason: Both `mkfs.ext4` and `mkfs.xfs` set the optimal block size per default[1][2]. (Discuss in Talk:Advanced Format#)

It is recommended to explicitly format the aligned partitions with sector (also named cluster, blocks, depending on the file system) of the same size of the physical sector size, otherwise blocks will be written in other size (usually 512 bytes) and the firmware will still have to do the mapping of many file system sectors to one physical drive sector. While this is usually and transparently done by the translation layer, it is an overhead that can be avoided and doing so will achieve an increased performance.

In particular shingled magnetic recording (SMR) drives that are firmware-managed are severely and negatively impacted if using a logical sector size of 512 bytes if their physical sector size is of 4096 bytes. Those drives have different performance writing zones and remapping reallocation occurs while being idle, but during heavy active writes (e.g., RAID resilvering, backups, writing many small files, rsync, etc.), a different file system sector size could drop write speed to single digit megabytes/second, as the higher performance write areas get depleted, and the sector translation layer gets overworked on the shingled areas.

Here are some examples to set the 4096-byte sector size explicitly:

- ext4

    # mkfs.ext4 -F -b 4096 /dev/device

- XFS

    # mkfs.xfs -f -s size=4096 /dev/device

## See also

- Western Digital’s Advanced Format: The 4K Sector Transition Begins
- White paper entitled "Advanced Format Technology."
- Failure to align one's HDD results in poor read/write performance. See this article for specific examples.

Category:

- Storage

Hidden category:

- Pages or sections flagged with Template:Accuracy