How to align partitions for HDD with 4KB sector

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

Some HDD like a Western Digital WD20EARS uses 4KB sectors rather than 512 byte sectors (it is called “Advanced Format”). As result, if your partitions are mis-aligned, a read-modify-write performance penalty incurred.

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


# 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

Parted “–align optimal” option can be used too to select optimal align, but disk parameters should be detected correctly to use this option with 4KB sectors.