Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

migrated from serverfault.com Aug 10 '11 at 20:13

This question came from our site for professional system and network administrators.

    
Hi, Grzegorzu :) You should have a look at answers to this question. –  rozcietrzewiacz Aug 11 '11 at 10:20
    
Yes, I've looked at LVM manuals and tutorials, but answers I've managed to found where to me too vague. Could you find there precise answer and could reference precisely to any of those resources ? –  Grzegorz Wierzowiecki Aug 11 '11 at 10:31
    
Unfortunately, I myself know very little about LVM, so I can't judge any of the tutorials. –  rozcietrzewiacz Aug 11 '11 at 10:35

1 Answer 1

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:

# cat /sys/block/sdb/queue/physical_block_size
4096
# cat  /sys/block/sdb/queue/logical_block_size
512

Update: To check for kernel support, you can check if /sys contains the mentioned files, you can call fdisk -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. Most mkfs 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.

share|improve this answer
    
That's great tip. Thanks. Now question stays : how to apply this knowledge while creating LVM partition and partitions on LVM :). . Best, Greg –  Grzegorz Wierzowiecki Aug 11 '11 at 9:04
    
@Grzegorz Wierzowiecki as he said, ( recent versions of ) the tools apply it automatically. –  psusi Aug 11 '11 at 13:47
    
@psusi Can I be sure about it ? Is it the case of tools: 'fdisk' , 'cfdisk', 'pvcreate', 'lvcreate' ? Should I just start partitioning and with them, creating lvms and everything will be aligned ? - please, ensure me. References to tools documentation are welcome. –  Grzegorz Wierzowiecki Aug 11 '11 at 14:19
    
@Grzegorz Wierzowiecki, updated the answer with some comments about checking. –  maxschlepzig Aug 11 '11 at 14:31
    
I have Seagate ST2000DL003 while is described as 4k disk, while $ cat /sys/block/sdg/queue/physical_block_size gives 512 - I am afraid it's due to "AF" technology. So I'd like to ensure 4k aligning. –  Grzegorz Wierzowiecki Aug 11 '11 at 16:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.