You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines

  1. [[chapter_lvm]]
  2. Logical Volume Manager (LVM)
  3. ----------------------------
  4. ifdef::wiki[]
  5. :pve-toplevel:
  6. endif::wiki[]
  7. Most people install {pve} directly on a local disk. The {pve}
  8. installation CD offers several options for local disk management, and
  9. the current default setup uses LVM. The installer let you select a
  10. single disk for such setup, and uses that disk as physical volume for
  11. the **V**olume **G**roup (VG) `pve`. The following output is from a
  12. test installation using a small 8GB disk:
  13. ----
  14. # pvs
  15. PV VG Fmt Attr PSize PFree
  16. /dev/sda3 pve lvm2 a-- 7.87g 876.00m
  17. # vgs
  18. VG #PV #LV #SN Attr VSize VFree
  19. pve 1 3 0 wz--n- 7.87g 876.00m
  20. ----
  21. The installer allocates three **L**ogical **V**olumes (LV) inside this
  22. VG:
  23. ----
  24. # lvs
  25. LV VG Attr LSize Pool Origin Data% Meta%
  26. data pve twi-a-tz-- 4.38g 0.00 0.63
  27. root pve -wi-ao---- 1.75g
  28. swap pve -wi-ao---- 896.00m
  29. ----
  30. root:: Formatted as `ext4`, and contains the operation system.
  31. swap:: Swap partition
  32. data:: This volume uses LVM-thin, and is used to store VM
  33. images. LVM-thin is preferable for this task, because it offers
  34. efficient support for snapshots and clones.
  35. For {pve} versions up to 4.1, the installer creates a standard logical
  36. volume called ``data'', which is mounted at `/var/lib/vz`.
  37. Starting from version 4.2, the logical volume ``data'' is a LVM-thin pool,
  38. used to store block based guest images, and `/var/lib/vz` is simply a
  39. directory on the root file system.
  40. Hardware
  41. ~~~~~~~~
  42. We highly recommend to use a hardware RAID controller (with BBU) for
  43. such setups. This increases performance, provides redundancy, and make
  44. disk replacements easier (hot-pluggable).
  45. LVM itself does not need any special hardware, and memory requirements
  46. are very low.
  47. Bootloader
  48. ~~~~~~~~~~
  49. We install two boot loaders by default. The first partition contains
  50. the standard GRUB boot loader. The second partition is an **E**FI **S**ystem
  51. **P**artition (ESP), which makes it possible to boot on EFI systems.
  52. Creating a Volume Group
  53. ~~~~~~~~~~~~~~~~~~~~~~~
  54. Let's assume we have an empty disk `/dev/sdb`, onto which we want to
  55. create a volume group named ``vmdata''.
  56. CAUTION: Please note that the following commands will destroy all
  57. existing data on `/dev/sdb`.
  58. First create a partition.
  59. # sgdisk -N 1 /dev/sdb
  60. Create a **P**hysical **V**olume (PV) without confirmation and 250K
  61. metadatasize.
  62. # pvcreate --metadatasize 250k -y -ff /dev/sdb1
  63. Create a volume group named ``vmdata'' on `/dev/sdb1`
  64. # vgcreate vmdata /dev/sdb1
  65. Creating an extra LV for `/var/lib/vz`
  66. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67. This can be easily done by creating a new thin LV.
  68. # lvcreate -n <Name> -V <Size[M,G,T]> <VG>/<LVThin_pool>
  69. A real world example:
  70. # lvcreate -n vz -V 10G pve/data
  71. Now a filesystem must be created on the LV.
  72. # mkfs.ext4 /dev/pve/vz
  73. At last this has to be mounted.
  74. WARNING: be sure that `/var/lib/vz` is empty. On a default
  75. installation it's not.
  76. To make it always accessible add the following line in `/etc/fstab`.
  77. # echo '/dev/pve/vz /var/lib/vz ext4 defaults 0 2' >> /etc/fstab
  78. Resizing the thin pool
  79. ~~~~~~~~~~~~~~~~~~~~~~
  80. Resize the LV and the metadata pool can be achieved with the following
  81. command.
  82. # lvresize --size +<size[\M,G,T]> --poolmetadatasize +<size[\M,G]> <VG>/<LVThin_pool>
  83. NOTE: When extending the data pool, the metadata pool must also be
  84. extended.
  85. Create a LVM-thin pool
  86. ~~~~~~~~~~~~~~~~~~~~~~
  87. A thin pool has to be created on top of a volume group.
  88. How to create a volume group see Section LVM.
  89. # lvcreate -L 80G -T -n vmstore vmdata