How to do the following with Linux tools :
LVM partition alignment and alignment of partition on LVM ?
What in case where I want to setup LVM partition (for "pv") and then partitions ?
To be more specifig, I'd like to make following setup:
- sda1 – boot , about 256MB
- sda2 – LVM pv
On LVM : swap, root, home etc.
How to setup LVM parition and paritions on LVM to obtain best performance?
(Command line linux tools please 😉 )
Am I right, that when LVM extents are aligned, created partitions are as well ?
What's the best size of block? : Thanks to @maxschlepzig, we have elegant method of obtaining sector size – for example 4k. Now, questions stays, how to apply this knowledge.
Best Answer
On a recent Linux distribution, the kernel should provide the physical sector size of the device and the partition/lvm/mkfs tools should automatically chose the alignment such that it is compatible with the physical sector size (for best performance).
For example on a Debian system of mine:
Update: To check for kernel support, you can check if
/sys
contains the mentioned files, you can callfdisk -l
to check if it prints this information (it should), you can check the specification of your hard disk (available by your vendor), you can check the changelog and/or source of LVM tools. Mostmkfs
commands provide a verbose option to see what block size is used. Last but not least you can just do a simple benchmark - e.g. one without any LVM (e.g. whole disk as device) and repeat it when your LVM setup is in place.