Heinz Mauelshagen's LVM (Logical Volume Manager) howto.             05/26/1998

LVM is free software.


Abstract:
---------
The LVM adds an additional layer between the physical peripherals
and the i/o interface in the kernel.

This allows the concatenation of several disk partitions or total disks
(so-called physical volumes or PVs) to form a storage pool
(so-called Volume Group or VG) with allocation units called physical
extents (called PE).

Parts out of this VG then can be allocated to so-called Logical Volumes
or LVs in units called logical extents or LEs.
Each LE is mapped to a corresponding PE.
LEs and PEs are equal in size.


The LVs can then be used through device special files similar to
/dev/sd[a-z]* or /dev/hd[a-z]* named /dev/VolumeGroupName/LogicalVolumeName.

But going beyond this, you are able to extend or reduce VGs AND LVs at runtime.

So...
If the capacity of a LV gets too small and your VG containing this LV is full,
you could add another PV to that VG and simply extend the LV afterwards.
If you reduce or delete a LV you can use the freed capacity for different
LVs in the same VG.


The above scenario looks like this:

     /------------------------------------------\
     |  /--------\      VG 1      /--------\    |
     |  |        |                |        |    |
     |  |  PV 1  |     ......     | PV n   |    |
     |  |    /-----------------------\     |    |
     |  |    \-------LV 1------------/     |    |
     |  \--------/                \--------/    |
     \------------------------------------------/

PV 1 could be /dev/sdc1 sized 1GB
PV n could be /dev/sde1 sized 2GB
VG 1 could be test_vg
LV 1 could be /dev/test_vg/test_lv




Installation steps see INSTALL and insmod(1)/modprobe(1), kmod/kerneld(8)
to load the logical volume manager module.


Configuration steps for getting the above scenario:

1. do a "pvcreate /dev/sd[ce]1"
   Think of setting the partition system id to 0xFE before!
   For testing purposes you can use more than one primary partition on a disk.
   (Don't do that for normal LVM operation for performance reasons)

2. do a "vgcreate test_vg /dev/sd[ce]1"
   (vgcreate activates the new volume group too)

3. do a "lvcreate -L1500 -ntest_lv test_vg" to get a 1500MB linear LV named
   /dev/test_vg/test_lv
   or a "lvcreate -i2 -I4 -l1500 -nanother_test_lv test_vg" to get a 100 LE
   large logical volume with 2 stripes and stripesize 4 KB.

4. use created LVs as you like to.
   For example generate a filesystem in one with "mke2fs /dev/test_vg/test_lv"
   and mount it.

5. extend /dev/test_vg/test_lv to 1600MB with:
   "lvextend -L+100 /dev/test_vg/test_lv"
   or
   "lvextend -L1600 /dev/test_vg/test_lv"
 
6. reduce /dev/test_vg/test_lv to 900 logical extends with:
   "lvreduce -l-700 /dev/test_vg/test_lv"
   or
   "lvreduce -l900 /dev/test_vg/test_lv"
 
7. rename a VG with:
   "vgchange -an test_vg"   # only works, if no logical volumes are open
   "vgrename test_vg whatever"
   "vgchange -ay whatever"

8. rename a LV after closing it with:
   "lvchange -an /dev/whatever/test_lv"
   "lvrename  /dev/whatever/test_lv  /dev/whatever/whatvolume"
   or
   "lvrename  whatever test_lv whatvolume"
   "lvchange -ay /dev/whatever/whatvolume" # to reactivate it for use

