How to align partitions on an HDD with 4KB sectors

Dec 20, 2011 00:00 · 162 words · 1 minute read Linux

Some HDDs, like the Western Digital WD20EARS, use 4KB sectors rather than 512 byte sectors (it is called “Advanced Format”). If your partitions are misaligned, a read-modify-write performance penalty is incurred.

If you want to align your partition with 4KB HDD sectors, you should create a partition that starts from a sector divisible by 8 (Linux uses a 512-byte sector size, so 4096 bytes / 512 bytes = 8). So, very easy.

Example:

# parted /dev/sde
(parted) unit s
(parted) mkpart primary 2048 400TB
(parted) mkpart primary  781250560 -1
(parted) quit

Output for aligned HDD:

# parted /dev/sde unit s print
Model: ATA XXXXXXXXXX (scsi)
Disk /dev/sde: XXXXXXXXXXX
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start       End          Size         Type     
 1      2048s       781250559s   781248512s   primary 
 2      781250560s  1953525167s  1172274608s  primary

The parted --align=optimal option can be used too to select the optimal alignment, but disk parameters should be detected correctly to use this option with 4KB sectors.

Links: