To check the partition alignment in a Linux virtual machine, log in to this virtual machine and run the following command:
# fdisk -l -u /dev/device_name
For example, to check the partition alignment on the sdc device, you can run this command:
# fdisk -l -u /dev/sdc
Disk /dev/sdc: 73.0 GB, 73014444032 bytes
255 heads, 63 sectors/track, 8876 cylinders, total 142606336 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 * 63 208844 104391 83 Linux
/dev/sdc2 208845 142592939 71192047+ 8e Linux LVM
Pay attention to the number of sectors in the Start column. Usually, a sector contains 512 bytes, which makes up 32256 bytes for 63 sectors for the /dev/sdc1
partition and 26105625 bytes for 208845 for the /dev/sdc2
partition. For a partition to be properly aligned, it must align with 4096 byte boundaries (assuming that the block size of your storage is 4 KB). As 32256 and 106928640 is not a multiple of 4096, the partitions /dev/sdc1
and /dev/sdc2
are not aligned properly. To align them, you should offset
-
the
/dev/sdc1
partition by 1 sector so that it starts at 64. In this case, 64 sectors each containing 512 bytes make up 32768 that is a multiple of 4096. -
the
/dev/sdc2
partition by 3 sectors so that it starts at 208848. In this case, 208848 sectors each containing 512 bytes make up 106930176 that is a multiple of 4096.