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