LVM Striping: Improve the efficiency of the data I/O

 

This article explains how to improve the efficiency of the data I/O with LVM (Logical Volume Manager).

Contents :

  • Logical Volume Manager?
  • Striping with LVM
  • Let’s begin

 

1- Logical Volume Manager:

LVM is a software storage manager for a computer (Linux Kernel), it is integrated with the Device Mapper module and it is commonly used as a storage manager by default in most Linux distributions such as CentOS, RedHat, Fedora, etc..

This technology grouped several physical disks into a single volume group and this volume group can be divided to many logical volume.

With LVM, it is possible to create, resize and move a logical volume without the need to stop your operating system.

LVM-Eng LVM

The LVM has other benefits such as the striping (increase read/write performance) and the mirroring (High Availability/Fault Tolerance of a physical disk) that are inherited from the storage technology RAID.

 

2- Striping:

With the LVM can enhance performance by writing data to a different physical volume, for more information, see this URL.

LVM-Striping

Striping with LVM (enhance performance)

 

3- Let’s begin

 

  • Preparing a physical volume:

For the implementation of this method, I have two disks, each one has 1 GB size ( /dev/sdb, /dev/sdc).

I want to create for each disk a 8e partition type:

# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         130     1044193+  83  Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
 Calling ioctl() to re-read partition table.
Syncing disks.

Note: Do the same for the second disk /dev/sdc

Verify the type of partitions:

# fdisk -l /dev/sdb
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         130     1044193+  8e  Linux LVM

Note: Do the same for the second disk /dev/sdc to verify.

The pvcreate command creates a physical volume. One or many partitions  can be specified.

 # pvcreate /dev/sdb1 /dev/sdc1
  • Create a volume Group « vg1 »

The vgcreate command creates a Volume Group “vg1″ with two physical volumes.

# vgcreate vg1 /dev/sdb1 /dev/sdc1
   Volume group "vg1" successfully created

The vgdisplay commande displays the details of a volume groupe:

# vgdisplay -v vg1
    Using volume group(s) on command line
    Finding volume group "vg1"
  --- Volume group ---
  VG Name               vg1
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               1.98 GB
  PE Size               4.00 MB
  Total PE              508
  Alloc PE / Size       0 / 0
  Free  PE / Size       508 / 1.98 GB
  VG UUID               OOMa7A-TfqW-XUV6-wV30-JTQD-sRoO-r8pbIY
  --- Physical volumes ---
  PV Name               /dev/sdb1
  PV UUID               DYvZb1-JfkF-qOJD-s9h4-SyX2-nGnW-sx5P0u
  PV Status             allocatable
  Total PE / Free PE    254 / 254
  PV Name               /dev/sdc1
  PV UUID               M370st-7Mx6-HPmT-WfuH-5Axr-NKI9-AHprz8
  PV Status             allocatable
  Total PE / Free PE    254 / 254
  • Create a logical volume:

The lvcreate commande is the responsable of creating one or many logiques volumes. The i (–stripes) parameter gives the number of stripes.  Also the I (–stripesize) gives  the  number  of  kilobytes  for  the  granularity  of the stripes. The L parameter indicates the size and the n parameter for the nom of the logical volume:

# lvcreate -i2 -n lv1 -L500M vg1
  Using default stripesize 64.00 KB
  Rounding size (125 extents) up to stripe boundary size (126 extents)
  Logical volume "lv1" created

The lvdisplay command is to consult the logical volume informations, the m parameter is to display the mapping of logical extents to physical volumes and physical extents:

# lvdisplay -m /dev/vg1/lv1
  --- Logical volume ---
  LV Name                /dev/vg1/lv1
  VG Name                vg1
  LV UUID                PJ9BN1-SNwQ-t4Ow-mRch-hapj-1C6e-APma0b
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                504.00 MB
  Current LE             126
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     512
  Block device           252:2
  --- Segments ---
  Logical extent 0 to 125:
    Type                striped
    Stripes             2
    Stripe size         64 KB
    Stripe 0:
      Physical volume   /dev/sdb1
      Physical extents  0 to 62
    Stripe 1:
      Physical volume   /dev/sdc1
      Physical extents  0 to 62

The pvdisplay command with the m parameter is used to verify on wicth physical volume the data is allocated, on this case we have two disks so the data is saved on the second disk.

# pvdisplay -m /dev/sdb1 /dev/sdc1
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               vg1
  PV Size               1019.72 MB / not usable 3.72 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              254
  Free PE               191
  Allocated PE          63
  PV UUID               DYvZb1-JfkF-qOJD-s9h4-SyX2-nGnW-sx5P0u  
--- Physical Segments ---
  Physical extent 0 to 62:
    Logical volume      /dev/vg1/lv1
    Logical extents     0 to 125
  Physical extent 63 to 253:
    FREE
  --- Physical volume ---
  PV Name               /dev/sdc1
  VG Name               vg1
  PV Size               1019.72 MB / not usable 3.72 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              254
  Free PE               191
  Allocated PE          63
  PV UUID               M370st-7Mx6-HPmT-WfuH-5Axr-NKI9-AHprz8
  --- Physical Segments ---
  Physical extent 0 to 62:
   Logical volume      /dev/vg1/lv1
    Logical extents     0 to 125
  Physical extent 63 to 253:
    FREE

Conclusion:

With LVM, we have the possibility to improve the efficiency of the data I/O.

Share it now!
Bookmark the permalink.
Loading Facebook Comments ...

Leave a Reply