4K Partition Alignment

Position: How Tos - Partition Management - 4K Partition Alignment

Do you know what is 4K partition alignment? How do you know if partitions on your hard drive or SSD are 4K aligned? How to partition disk into 4K aligned volumes? This page gives detailed introduction of partition alignment and helps users get best performance of storage devices.

DiskGenius - Allow users to partition HDD or SSD into 4K aligned volumes so as to get best performance.

ô  Free Download

Quick Navigation:

Once important point should be noted is that when partitioning a hard drive, partitions should be 4K alignment. Disk performance may degrade if partitions are not properly 4K aligned, especially solid-state drives (SSD). Cannot figure out causes of slow disk read/write speed? The possible reason might be 4K alignment. So, what is partition alignment? Why align? How to align partitions? How to check whether partition is 4K aligned? Now we'll discuss all you want to know about 4K alignment.

Physical sectors

Partition alignment refers to aligning partition starting location to certain sectors. First, we need to have a general understanding of the relationship between alignment and sectors. As we all now, the basic read/write unit of hard drive is "Sector". As to hard drive, each read/write action is performed in the unit of sector, and one sector (usually 512 bytes) at least. Due to the limitation on hard drive data storage structure, it is not possible to read or write only one or several bytes. It seems that reading/writing a few bytes are available by way of API provided by operating system, which in fact is realized by operating system conversion. The actual read/write action executed by hard drive is still entire sector.

In recent years, with the increasing demand of hard drive capacity, hard drive manufacturers usually employ the way to enlarge sector size so as to increase data storage density. Then, hard drive whose sector size is 4096 bytes is produced. We call such sector "physical sector". However, such large sector brings about compatibility issue and some system or software cannot adapt it. To solve the issue, hard drive divides physical sector into multiple segments and reports them as average sector (typically 512 types) to operating system and applications. We refer these sector segments as "logical sector". Application (firmware) in hard drive is responsible for converting between physical sectors and logical sectors during actual read/write actions, thus, upper level program does not feel the existence of physical sector.

A logical sector is the minimum operating unit that hard drive receives read and write commands and it can be accessed by operating system and applications. In most cases, the size of a logical sector is 512 bytes. Generally, the sector we mention refers to logical sector. Physical sector means the sector on hard drive in the sense of underlying hardware and it is actually the minimum unit of read/write operations. Physical sectors can only be accessed directly by hard drive, and operating system and applications cannot directly access them. A physical sector can consist of several logical sectors (e.g. a physical sector on most hard drive contains 8 logical sectors). When a logical sector is read or written, the actual underlying operations of hard drive reads or writes the entire physical sector where the logical sector is located.

Concepts like "hard drive" "sectors" mentioned here also apply to memory card and solid-state drive (SSD). Then we'll refer them as "disk". The basic principles of their usage are consistent. SSD is more complicated to implement, as it has "pages" and "blocks", which can be simply regarded as logical sectors and physical sectors for ease of understanding. In addition, SSD has to execute data erasing operation before writing data, as data cannot be written to blocks that already contain data. Hence, SSD has a higher demand for partition 4K alignment. If it is not aligned, extra actions increase and read/write performance degrades.

Partitioning and formatting

A disk should be partitioned and formatted prior to storing data. Simply put, a partition is a large area of contiguous sectors divided from disk. Formatting works to plan the usage of sectors in the partition, for instance, how to arrange the storage of file data, where to store file attributes, how to store directory structure, etc. A partition can be used to store data after being formatted. Formatting process groups all sectors in the partition from beginning to end, dividing them into fixed-size clusters and numbering clusters in sequence. Each cluster can fixedly contain one or more sectors and sector count is always 2 to the power of n. Once a partition gets formatted, cluster will be the smallest unit to read or write action. File information such as data, attributes and so on is stored to clusters.

Why do you want to align partition?

When partitioning a disk, partitions are divided in the unit of logical sectors and a partition can start from any numbered logical sectors. If the starting position of a partition is not aligned to the edge of a certain physical sector, after formatting, all clusters won't align to the edge of physical sector, either. As shown in the picture below, each physical sector consists of 4 logical sectors and partition starts from sector No.3. After formatting, each cluster occupies 4 logical sectors and none of these clusters are aligned to the edge of physical sector, that is, each cluster spans 2 physical sectors.

4K Partition Alignment

Since disk always reads and writes in the unit of physical sectors, in this case, it has to read an additional physical sector when a cluster is to be read. For instance, to read data on cluster No.0 (4 logical sectors), in actual execution, the disk has to read physical sector No.0 and physical sector No.1 (8 logical sectors in total). Similarly, the write operation to cluster is same process. Obviously, read/write performance degrades greatly.

Let's take a look at an aligned example. As shown below, partition starts from sector No.4 and aligns to the edge of physical sector No.1. After formatting, each cluster contains 4 logical sectors and all clusters align to the edge of physical sectora.

4K Partition Alignment

In such situation, when reading a cluster, disk does not need to read any additional physical sectors, which gives full play to disk read/write performance. Obviously, this is exactly what we need.

Therefore, partition 4K alignment can maximize disk read/write performance when physical sector size is not consistent with logical sector size. Misalignment can decline disk read/write performance.

How to align a partition?

As shown in the two examples above, formatting process will align each cluster to the edge of physical sector as long as partition's starting position is aligned to the edge of physical sector. Thus, it is quite easy to get 4K alignment.

How to check physical sector size?

Physical sector size on your disk should be aware in order to achieve 4K alignment during disk partitioning. How to check physical sector size?

Launch DiskGenius and select the disk from the main interface and you can view disk parameters in details. Then locate "Sector Size" and "Physical Sector Size". "Sector Size" presents logical sector size. As shown in the picture below, the physical sector size of selected disk is 4096 bytes. It contains 8 logical sectors via simple calculation.

4K Partition Alignment

How many sectors should be aligned?

If you've known "sector size" and "physical sector size", divide "physical sector size" by the "sector size" and you can get logical sector number contained in each physical sector. This value is the minimum sector number we should align. It will do as long as align partition's starting position to an integer multiple of this value. For example, if physical sector size is 4096 bytes and logical sector size is 512 bytes, then divide 4096 by 512 and we get 8. Requirements of partition alignment can be met by aligning partition beginning position to an integer multiple of 8 sectors. For example, align to 8, 16, 24, 32, …1024, 2048 and so on, as long as sector number is divisible by 8. But that does not mean the larger number is better. In Windows the default sector number to align partition is 8 which is basically able to satisfy 4K alignment requirements of almost all disks.

Why does everyone say 4K alignment?

It is just out of habits. When physical sector concept became to be known, its size on most disk is 4096 bytes, i.e. 4K. Thus, it is customary to call 4 alignment. The physical sector size should be checked first during partitioning disk, for physical sector on some disk may contain 4, 8, 16 or more logical sectors (always 2 nth power). If you know the exact physical sector size, you can follow the calculation method mentioned above to get sector number. Then align to the actual physical sector size based on the logical sector number included in physical sector. If physical sector size is 8192 bytes, then align partition in line with 8192, which, strictly speaking, cannot be called 4K alignment.

How to align partition during disk partitioning?

Let's take DiskGenius as an example. When creating new partition, on the "Create New Partition" window, you can select "Align to Integral Multiples of Sectors" option and choose sector number to be aligned. Click "OK" button and the newly created partition will be 4K aligned, as follows:

4K Partition Alignment

DiskGenius provides lots of options in the sector number drop-down list, any of which is larger than physical sector size meets alignment requirements. The application gives so many options for the purpose of increasing the freedom of choice, which does not mean the larger value is better. Choosing a value that is way too large may lead to a waste of disk space. The default setting has been able to meet 4K alignment requirements of almost all disks.

Apart from creating new partition, DiskGenius also provides a function "Quick Partition" which can set partition alignment, as shown below:

4K Partition Alignment

How to check if partitions are aligned?

DiskGenius, effective disk partition software, provides the function to check if partitions are 4K aligned, and you can follow this guide to have a check whether partitions on your hard drive are properly aligned.

Select the disk to be checked on the left pane of DiskGenius, and click Tools -> 4KB Partition Alignment Detection, as follows:

4K Partition Alignment

A window shows up and displays partition alignment status, as picture below. "Y" under the Alignment column means the partition is aligned, and misaligned partition is displayed in red.

4K Partition Alignment

How to correct unaligned partition?

For the case that partition is not aligned and contains data, DiskGenius currently has not provided a direct solution to align partition (which might be available on future versions). However, we can still align the partition using DiskGenius via three steps, here are steps in detail:

Step 1. Backup the partition to be aligned to an image file.

Step 2. Delete the unaligned partition, and recreate it. Then you can select 4K alignment during creating the partition.

Step 3. Restore the newly created partition from the image file which is backed up in step 1.

Till now, have you gained a comprehensive understanding of partition 4K alignment? Should you have any question regarding 4K alignment or DiskGenius, please feel free to contact us.


DiskGenius - Free tool to partition HDD/USB disk, create partition, resize partition, allocate free space, etc.

ô  Free Download
Copyright © 2010-2024 Eassos Ltd. All Rights Reserved.