Striping Logical Volumes

A Logical Volume (LV) is created from a Logical Volume Manager (LVM) Volume Group (VG). The VG is the central storage component in an LVM based system, a VG can contain one or more Physical Volumes (PV), which are basically disks presented to the files system, partitioned as an LVM disk and then converted to a PV using the pvcreate command, finally the PV is added to a single VG.

The space in the VG consists of Physical Extents or PE’s, each one is a block of usable storage. If you keep adding PV’s then you add more PE’s.

The LV represents a mountable file system once its been formatted. The LV is allocated from the VG. Normally a non-stripped LV just uses the PE’s in sequential order, this has the effect of potentially all the IO been put onto one PV.

However if you specify stripping when you create the LV initially, then provided the number of available PV’s has enough space, your LV will span across the number of disks specified in the strip. Needless to say you cannot create a 6 disk stripe if there are only 4 PV’s in the VG.

The picture below shows an LV with 4 stripes, the I/O being written will use 1 PE across each PV in order 1-2-3-4 then back to 1 in sequence.

To create a 12G LV across 4 PV’s is:

lvcreate -L 12G -i 4 -I 64k -n lv_data vg_data -v

If you do not specify striping then the PE’s are allocated sequentially as show below:

The key take away from this is that the I/O delay is greatly reduced when I/O is spread across multiple PV’s due to the number of IO queues that are available.

Due to the flexibility of LVM, you can create a new LV that is stripped, prepare it, mount it and then rsync over the data from the existing one, then just remount the new LV in place of the old LV when no applications are running that use the LV.

-oOo-

You may also like...

Popular Posts