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