linux-old/Documentation/LVM-HOWTO
<<
>>
Prefs
   1Heinz Mauelshagen's LVM (Logical Volume Manager) howto.             02/10/1999
   2
   3
   4Abstract:
   5---------
   6The LVM adds a kind of virtual disks and virtual partitions functionality
   7to the Linux operating system.
   8
   9It achieves this by adding an additional layer between the physical peripherals
  10and the i/o interface in the kernel.
  11
  12This allows the concatenation of several disk partitions or total disks
  13(so-called physical volumes or PVs) or even multiple devices
  14to form a storage pool (so-called Volume Group or VG) with
  15allocation units called physical extents (called PE).
  16You can think of the volume group as a virtual disk.
  17Please see scenario below.
  18
  19Some or all PEs of this VG then can be allocated to so-called Logical Volumes
  20or LVs in units called logical extents or LEs.
  21Each LE is mapped to a corresponding PE.
  22LEs and PEs are equal in size.
  23Logical volumes are a kind of virtual partitions.
  24
  25
  26The LVs can be used through device special files similar to the known
  27/dev/sd[a-z]* or /dev/hd[a-z]* named /dev/VolumeGroupName/LogicalVolumeName.
  28
  29But going beyond this, you are able to extend or reduce
  30VGs _AND_ LVs at runtime!
  31
  32So...
  33If for example the capacity of a LV gets too small and your VG containing
  34this LV is full, you could add another PV to that VG and simply extend
  35the LV afterwards.
  36If you reduce or delete a LV you can use the freed capacity for different
  37LVs in the same VG.
  38
  39
  40The above scenario looks like this:
  41
  42     /------------------------------------------\
  43     |  /--PV2---\      VG 1      /--PVn---\    |
  44     |  |-VGDA---|                |-VGDA-- |    |
  45     |  |PE1PE2..|                |PE1PE2..|    |
  46     |  |        |     ......     |        |    |
  47     |  |        |                |        |    |
  48     |  |    /-----------------------\     |    |
  49     |  |    \-------LV 1------------/     |    |
  50     |  |   ..PEn|                |   ..PEn|    |
  51     |  \--------/                \--------/    |
  52     \------------------------------------------/
  53
  54PV 1 could be /dev/sdc1 sized 3GB
  55PV n could be /dev/sde1 sized 4GB
  56VG 1 could be test_vg
  57LV 1 could be /dev/test_vg/test_lv
  58VGDA is the volume group descriptor area holding the LVM metadata
  59PE1 up to PEn is the number of physical extents on each disk(partition)
  60
  61
  62
  63Installation steps see INSTALL and insmod(1)/modprobe(1), kmod/kerneld(8)
  64to load the logical volume manager module if you did not bind it
  65into the kernel.
  66
  67
  68Configuration steps for getting the above scenario:
  69
  701. Set the partition system id to 0x8e on /dev/sdc1 and /dev/sde1.
  71
  722. do a "pvcreate /dev/sd[ce]1"
  73   For testing purposes you can use more than one partition on a disk.
  74   You should not use more than one partition because in the case of
  75   a striped LV you'll have a performance breakdown.
  76
  773. do a "vgcreate test_vg /dev/sd[ce]1" to create the new VG named "test_vg"
  78   which has the total capacity of both partitions.
  79   vgcreate activates (transfers the metadata into the LVM driver in the kernel)
  80   the new volume group too to be able to create LVs in the next step.
  81
  824. do a "lvcreate -L1500 -ntest_lv test_vg" to get a 1500MB linear LV named
  83   "test_lv" and it's block device special "/dev/test_vg/test_lv".
  84
  85   Or do a "lvcreate -i2 -I4 -l1500 -nanother_test_lv test_vg" to get a 100 LE
  86   large logical volume with 2 stripes and stripesize 4 KB.
  87
  885. For example generate a filesystem in one LV with
  89   "mke2fs /dev/test_vg/test_lv" and mount it.
  90
  916. extend /dev/test_vg/test_lv to 1600MB with relative size by
  92   "lvextend -L+100 /dev/test_vg/test_lv"
  93   or with absolute size by
  94   "lvextend -L1600 /dev/test_vg/test_lv"
  95 
  967. reduce /dev/test_vg/test_lv to 900 logical extents with relative extents by
  97   "lvreduce -l-700 /dev/test_vg/test_lv"
  98   or with absolute extents by
  99   "lvreduce -l900 /dev/test_vg/test_lv"
 100 
 1019. rename a VG by deactivating it with
 102   "vgchange -an test_vg"   # only VGs with _no_ open LVs can be deactivated!
 103   "vgrename test_vg whatever"
 104   and reactivate it again by
 105   "vgchange -ay whatever"
 106
 1079. rename a LV after closing it by
 108   "lvchange -an /dev/whatever/test_lv" # only closed LVs can be deactivated
 109   "lvrename  /dev/whatever/test_lv  /dev/whatever/whatvolume"
 110   or by
 111   "lvrename  whatever test_lv whatvolume"
 112   and reactivate it again by
 113   "lvchange -ay /dev/whatever/whatvolume"
 114
 11510. if you own Ted Tso's/Powerquest's resize2fs program, you are able to
 116    resize the ext2 type filesystems contained in logical volumes without
 117    destroyiing the data by
 118    "e2fsadm -L+100 /dev/test_vg/another_test_lv"
 119
 120
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.