LVM-HOWTO
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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