Tuesday, February 24, 2009

Maximum Size Of A Logical Volume In LVM



What is the maximum size of a single logical volume (LV) in Linux Logical Volume Manager or LVM? How to resize or change LVM PE size of an existing volume group or VG dynamically?

Most probably you’re here because you’re googling these similar LVM FAQ. Hopefully these are the answers!

The physical extent size (PE size) of a LVM volume group (VG) is fixed upon the creation of VG. In Linux command line, the -s option switch of vgcreate command is to explicitly set the physical extent size (PE size) on physical volumes (PV) of the volume group (VG). PE size is defaulted to 4MB if it’s not set explicitly. However, once this value has been set, it’s not possible to change a PE size without recreating the volume group which would involve backing up and restoring data on any logical volumes!

As far as LVM2 is concerned - LVM version 2.02.06 (2006-05-12), Library version 1.02.07 (2006-05-11), Driver version 4.5.0 - there is no LVM commands or utilities, not even the vgmodify in HPUX, to resize or change the LVM PE size of an existing VG dynamically or in online mode!

So, it’s recommended to properly plan ahead before creating a LVM volume group. For example, if the logical volume will store database tables where the database size will likely grow up to more than 300G in near future, you should have not created a volume group with the default PE size of 4MB!

A visualized concept diagram of the Linux Logical Volume Manager or LVM.

What’s the maximum size of a logical volume in Linux LVM?
Why there is a limitation on maximum size of logical volume?

In order to limit the Linux kernel memory usage, there is a limit of 65,536 physical extents (PE) per logical volume (LV). Hence, the LVM PE size will directly determine the maximum size of a logical volume (LV)! For example, 4MB PE size (the default PE size) will limit single logical volume (LV) to 256GB, 16MB PE size will limit single LV to grow beyond 1TB, etc.

Beside the PE size, the maximum size of single LV is also limited by CPU architecture and Linux kernel version:
  • Linux kernel version 2.4.x limit the maximum LV size to 2TB.
  • Some older Linux kernel prior to 2.4.x, the maximum LV size is limited to 1TB (caused by the integer signedness problems in the block layer).
  • The combination of 32-bit CPU and Linux kernel version 2.6.x, the limit of logical volume size is maximized at 16TB.
  • For Linux kernel 2.6.x running on 64-bit CPU, the maximum LV size is 8EB (extremely terrible big storage for this time being!)

No comments: