Partition alignment check

For best performance (skipping the theory), partitions should be properly aligned to physical sector boundaries:

If you are using LVM, PV alligment must be done also

NOT ALIGNED
(starting on 63rd logical sector, which may be fine for old 512b sector drives, bun not for latest 4k sector multi TB drives)

[root@server ~]# fdisk -lu

Disk /dev/vda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes

Device Boot Start End Blocks Id System
/dev/vda1 * 63 14811929 7405933+ 83 Linux
/dev/vda2 14811930 20948759 3068415 82 Linux swap / Solaris

Both partition starting sector numbers are NOT dividable by 2048.

PROPERLY ALIGNED:

[root@server ~]# fdisk -lu

Disk /dev/vda: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002bb80

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 1026047 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1026048 104857599 51915776 8e Linux LVM

Both partition starting sector numbers areĀ dividable by at least 2048, so both partitions are properly aligned (2048 x 512b = 1MB offset, which is dividable by most sector sizes (512b for older drives, or 4K for newer drives and SSD drives, 8K sectors on some SANs, etc)

May be multiple of 2048 (4096 for example)

LVM (physical volume alignment)

If you are using LVM, also important to have PV starting ofset in multiply of 4K, meaning 1MB ofset is also fine.

Check:

[root@server ~]#Ā pvs -o +pe_start
PV VG Fmt Attr PSize PFree 1st PE
/dev/vda2 vg_group lvm2 a– 19.51g 0 1.00m

So LVM physical volume is also starting with offset of 1MB, which is fine

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: