Heads and sectors for partition alignment

by Martin Monperrus
There are many cases where aligning the disk partitions yields better perfomance, for instance for database partitions, solid-state disks (SSD), and SAN storage with iSCSI. Here is the result of my Googling on this topic.

Partition alignment means two things: first that the partition boundaries correspond to physical disk block boundaries (which is straightforward for 512 byte blocks, but not for 128k blocks), second that the partition boundaries correspond to kernel volume blocks. Hence, the partitioning tools are responsible for finding "good" partition starting addresses. Most partition tools rely on cylinder/head/sector (CHS) to compute partition addresses, even if the hardware is not anymore based on cylinders/heads for years. In particular, they create partitions at the beginning of cylinders.

For instance, if the kernel volume block is 8KB (i.e. 16 sectors, 16*512=8192), then the CHS geometry must be set so that the first sector of all partitions must be divisible by 16, hence corresponds to a volume block boundary. Also, since SSD disks often have 128k physical blocks, the CHS geometry must be set so that the first sector of all partitions must be divisible by 256.

The following presents different CHS values found on the web, and whether the cylinders will match the required boundaries.

Head/Sector# sectors per cylinder = #head * #sector4KB volume block - Linux (divisible by 8)8KB volume block (divisible by 16)128KB disk block (divisible by 256)Source
255/56 14280yesyesnohttp://comments.gmane.org/gmane.linux.iscsi.open-iscsi/2240
240/63 15120yesyesnohttp://ldn.linuxfoundation.org/blog-entry/aligning-filesystems-ssd%E2%80%99s-erase-block-size
256/32 8192yesyesyeshttp://groups.google.com/group/open-iscsi/browse_thread/thread/37741fb3b3eca1e4
224/56 12544yesyesyeshttp://ldn.linuxfoundation.org/blog-entry/aligning-filesystems-ssd%E2%80%99s-erase-block-size
Note that the first partition must also start at correct sectors. Since it often starts at sector #63, it is not optimal (not divisible by 8!). It is better to make it start at #256 and commonly at sector #2048 (see http://technet.microsoft.com/en-us/library/cc966412.aspx and https://wiki.archlinux.org/index.php/Solid_State_Drives).


Tagged as: