1LVM(8) System Manager's Manual LVM(8)
2
3
4
6 lvm — LVM2 tools
7
9 lvm [command|file]
10
12 The Logical Volume Manager (LVM) provides tools to create virtual block
13 devices from physical devices. Virtual devices may be easier to manage
14 than physical devices, and can have capabilities beyond what the physi‐
15 cal devices provide themselves. A Volume Group (VG) is a collection of
16 one or more physical devices, each called a Physical Volume (PV). A
17 Logical Volume (LV) is a virtual block device that can be used by the
18 system or applications. Each block of data in an LV is stored on one
19 or more PV in the VG, according to algorithms implemented by Device
20 Mapper (DM) in the kernel.
21
22 The lvm command, and other commands listed below, are the command-line
23 tools for LVM. A separate manual page describes each command in de‐
24 tail.
25
26 If lvm is invoked with no arguments it presents a editline prompt (as‐
27 suming it was compiled with editline support). LVM commands may be en‐
28 tered interactively at this prompt with editline facilities including
29 history and command name and option completion. Refer to editline(3)
30 for details.
31
32 If lvm is invoked with argv[0] set to the name of a specific LVM com‐
33 mand (for example by using a hard or soft link) it acts as that com‐
34 mand.
35
36 On invocation, lvm requires that only the standard file descriptors
37 stdin, stdout and stderr are available. If others are found, they get
38 closed and messages are issued warning about the leak. This warning
39 can be suppressed by setting the environment variable LVM_SUP‐
40 PRESS_FD_WARNINGS.
41
42 Where commands take VG or LV names as arguments, the full path name is
43 optional. An LV called "lvol0" in a VG called "vg0" can be specified
44 as "vg0/lvol0". Where a list of VGs is required but is left empty, a
45 list of all VGs will be substituted. Where a list of LVs is required
46 but a VG is given, a list of all the LVs in that VG will be substi‐
47 tuted. So lvdisplay vg0 will display all the LVs in "vg0". Tags can
48 also be used - see --addtag below.
49
50 One advantage of using the built-in shell is that configuration infor‐
51 mation gets cached internally between commands.
52
53 A file containing a simple script with one command per line can also be
54 given on the command line. The script can also be executed directly if
55 the first line is #! followed by the absolute path of lvm.
56
57 Additional hyphens within option names are ignored. For example,
58 --readonly and --read-only are both accepted.
59
61 The following commands are built into lvm without links normally being
62 created in the filesystem for them.
63
64 config The same as lvmconfig(8) below.
65 devtypes Display the recognised built-in block device types.
66 dumpconfig The same as lvmconfig(8) below.
67 formats Display recognised metadata formats.
68 fullreport Report information about PVs, PV segments, VGs, LVs and
69 LV segments, all at once.
70 help Display the help text.
71 lastlog Display log report of last command run in LVM shell if
72 command log reporting is enabled.
73 lvpoll Complete lvmpolld operations (Internal command).
74 segtypes Display recognised Logical Volume segment types.
75 systemid Display any system ID currently set on this host.
76 tags Display any tags defined on this host.
77 version Display version information.
78
80 The following commands implement the core LVM functionality.
81
82 pvchange Change attributes of a Physical Volume.
83 pvck Check Physical Volume metadata.
84 pvcreate Initialize a disk or partition for use by LVM.
85 pvdisplay Display attributes of a Physical Volume.
86 pvmove Move Physical Extents.
87 pvremove Remove a Physical Volume.
88 pvresize Resize a disk or partition in use by LVM2.
89 pvs Report information about Physical Volumes.
90 pvscan Scan all disks for Physical Volumes.
91 vgcfgbackup Backup Volume Group descriptor area.
92 vgcfgrestore Restore Volume Group descriptor area.
93 vgchange Change attributes of a Volume Group.
94 vgck Check Volume Group metadata.
95 vgconvert Convert Volume Group metadata format.
96 vgcreate Create a Volume Group.
97 vgdisplay Display attributes of Volume Groups.
98 vgexport Make volume Groups unknown to the system.
99 vgextend Add Physical Volumes to a Volume Group.
100 vgimport Make exported Volume Groups known to the system.
101 vgimportclone Import and rename duplicated Volume Group (e.g. a hard‐
102 ware snapshot).
103 vgimportdevices Add PVs from a VG to the devices file.
104 vgmerge Merge two Volume Groups.
105 vgmknodes Recreate Volume Group directory and Logical Volume spe‐
106 cial files
107 vgreduce Reduce a Volume Group by removing one or more Physical
108 Volumes.
109 vgremove Remove a Volume Group.
110 vgrename Rename a Volume Group.
111 vgs Report information about Volume Groups.
112 vgscan Scan all disks for Volume Groups.
113 vgsplit Split a Volume Group into two, moving any logical vol‐
114 umes from one Volume Group to another by moving entire
115 Physical Volumes.
116 lvchange Change attributes of a Logical Volume.
117 lvconvert Convert a Logical Volume from linear to mirror or snap‐
118 shot.
119 lvcreate Create a Logical Volume in an existing Volume Group.
120 lvdisplay Display attributes of a Logical Volume.
121 lvextend Extend the size of a Logical Volume.
122 lvmconfig Display the configuration information after loading
123 lvm.conf(5) and any other configuration files.
124 lvmdevices Manage the devices file.
125 lvmdiskscan Scan for all devices visible to LVM2.
126 lvmdump Create lvm2 information dumps for diagnostic purposes.
127 lvreduce Reduce the size of a Logical Volume.
128 lvremove Remove a Logical Volume.
129 lvrename Rename a Logical Volume.
130 lvresize Resize a Logical Volume.
131 lvs Report information about Logical Volumes.
132 lvscan Scan (all disks) for Logical Volumes.
133
134 The following LVM1 commands are not implemented in LVM2: lvmchange,
135 lvmsadc, lvmsar, pvdata. For performance metrics, use dmstats(8) or to
136 manipulate the kernel device-mapper driver used by LVM2 directly, use
137 dmsetup(8).
138
140 The valid characters for VG and LV names are: a-z A-Z 0-9 + _ . -
141
142 VG names cannot begin with a hyphen. The name of a new LV also cannot
143 begin with a hyphen. However, if the configuration setting meta‐
144 data/record_lvs_history is enabled then an LV name with a hyphen as a
145 prefix indicates that, although the LV was removed, it is still being
146 tracked because it forms part of the history of at least one LV that is
147 still present. This helps to record the ancestry of thin snapshots
148 even after some links in the chain have been removed. A reference to
149 the historical LV 'lvol1' in VG 'vg00' would be 'vg00/-lvol1' or just
150 '-lvol1' if the VG is already set. (The latter form must be preceded
151 by '--' to terminate command line option processing before reaching
152 this argument.)
153
154 There are also various reserved names that are used internally by lvm
155 that can not be used as LV or VG names. A VG cannot be called anything
156 that exists in /dev/ at the time of creation, nor can it be called '.'
157 or '..'. An LV cannot be called '.', '..', 'snapshot' or 'pvmove'.
158 The LV name may also not contain any of the following strings:
159 '_cdata', '_cmeta', '_corig', '_iorig', '_mimage', '_mlog', '_pmspare',
160 '_rimage', '_rmeta', '_tdata', '_tmeta', '_vdata', '_vorigin' or
161 '_wcorig'. A directory bearing the name of each Volume Group is cre‐
162 ated under /dev when any of its Logical Volumes are activated. Each
163 active Logical Volume is accessible from this directory as a symbolic
164 link leading to a device node. Links or nodes in /dev/mapper are in‐
165 tended only for internal use and the precise format and escaping might
166 change between releases and distributions. Other software and scripts
167 should use the /dev/VolumeGroupName/LogicalVolumeName format to reduce
168 the chance of needing amendment when the software is updated. Should
169 you need to process the node names in /dev/mapper, you may use dmsetup
170 splitname to separate out the original VG, LV and internal layer names.
171
173 VG names should be unique. vgcreate will produce an error if the spec‐
174 ified VG name matches an existing VG name. However, there are cases
175 where different VGs with the same name can appear to LVM, e.g. after
176 moving disks or changing filters.
177
178 When VGs with the same name exist, commands operating on all VGs will
179 include all of the VGs with the same name. If the ambiguous VG name is
180 specified on the command line, the command will produce an error. The
181 error states that multiple VGs exist with the specified name. To
182 process one of the VGs specifically, the --select option should be used
183 with the UUID of the intended VG: --select vg_uuid=<uuid>
184
185 An exception is if all but one of the VGs with the shared name is for‐
186 eign (see lvmsystemid(7)). In this case, the one VG that is not for‐
187 eign is assumed to be the intended VG and is processed.
188
189 LV names are unique within a VG. The name of an historical LV cannot
190 be reused until the historical LV has itself been removed or renamed.
191
193 When an operation needs to allocate Physical Extents for one or more
194 Logical Volumes, the tools proceed as follows:
195
196 First of all, they generate the complete set of unallocated Physical
197 Extents in the Volume Group. If any ranges of Physical Extents are
198 supplied at the end of the command line, only unallocated Physical Ex‐
199 tents within those ranges on the specified Physical Volumes are consid‐
200 ered.
201
202 Then they try each allocation policy in turn, starting with the
203 strictest policy (contiguous) and ending with the allocation policy
204 specified using --alloc or set as the default for the particular Logi‐
205 cal Volume or Volume Group concerned. For each policy, working from
206 the lowest-numbered Logical Extent of the empty Logical Volume space
207 that needs to be filled, they allocate as much space as possible ac‐
208 cording to the restrictions imposed by the policy. If more space is
209 needed, they move on to the next policy.
210
211 The restrictions are as follows:
212
213 Contiguous requires that the physical location of any Logical Extent
214 that is not the first Logical Extent of a Logical Volume is adjacent to
215 the physical location of the Logical Extent immediately preceding it.
216
217 Cling requires that the Physical Volume used for any Logical Extent to
218 be added to an existing Logical Volume is already in use by at least
219 one Logical Extent earlier in that Logical Volume. If the configura‐
220 tion parameter allocation/cling_tag_list is defined, then two Physical
221 Volumes are considered to match if any of the listed tags is present on
222 both Physical Volumes. This allows groups of Physical Volumes with
223 similar properties (such as their physical location) to be tagged and
224 treated as equivalent for allocation purposes.
225
226 When a Logical Volume is striped or mirrored, the above restrictions
227 are applied independently to each stripe or mirror image (leg) that
228 needs space.
229
230 Normal will not choose a Physical Extent that shares the same Physical
231 Volume as a Logical Extent already allocated to a parallel Logical Vol‐
232 ume (i.e. a different stripe or mirror image/leg) at the same offset
233 within that parallel Logical Volume.
234
235 When allocating a mirror log at the same time as Logical Volumes to
236 hold the mirror data, Normal will first try to select different Physi‐
237 cal Volumes for the log and the data. If that's not possible and the
238 allocation/mirror_logs_require_separate_pvs configuration parameter is
239 set to 0, it will then allow the log to share Physical Volume(s) with
240 part of the data.
241
242 When allocating thin pool metadata, similar considerations to those of
243 a mirror log in the last paragraph apply based on the value of the al‐
244 location/thin_pool_metadata_require_separate_pvs configuration parame‐
245 ter.
246
247 If you rely upon any layout behaviour beyond that documented here, be
248 aware that it might change in future versions of the code.
249
250 For example, if you supply on the command line two empty Physical Vol‐
251 umes that have an identical number of free Physical Extents available
252 for allocation, the current code considers using each of them in the
253 order they are listed, but there is no guarantee that future releases
254 will maintain that property. If it is important to obtain a specific
255 layout for a particular Logical Volume, then you should build it up
256 through a sequence of lvcreate(8) and lvconvert(8) steps such that the
257 restrictions described above applied to each step leave the tools no
258 discretion over the layout.
259
260 To view the way the allocation process currently works in any specific
261 case, read the debug logging output, for example by adding -vvvv to a
262 command.
263
265 Some logical volume types are simple to create and can be done with a
266 single lvcreate(8) command. The linear and striped logical volume
267 types are an example of this. Other logical volume types may require
268 more than one command to create. The cache (lvmcache(7)) and thin pro‐
269 visioning (lvmthin(7)) types are examples of this.
270
272 All tools return a status code of zero on success or non-zero on fail‐
273 ure. The non-zero codes distinguish only between the broad categories
274 of unrecognised commands, problems processing the command line argu‐
275 ments and any other failures. As LVM remains under active development,
276 the code used in a specific case occasionally changes between releases.
277 Message text may also change.
278
280 HOME Directory containing .lvm_history if the internal editline shell
281 is invoked.
282
283 LVM_OUT_FD
284 File descriptor to use for common output from LVM commands.
285
286 LVM_ERR_FD
287 File descriptor to use for error output from LVM commands.
288
289 LVM_REPORT_FD
290 File descriptor to use for report output from LVM commands.
291
292 LVM_COMMAND_PROFILE
293 Name of default command profile to use for LVM commands. This
294 profile is overridden by direct use of --commandprofile command
295 line option.
296
297 LVM_RUN_BY_DMEVENTD
298 This variable is normally set by dmeventd plugin to inform lvm2
299 command it is running from dmeventd plugin so lvm2 takes some
300 extra action to avoid communication and deadlocks with dmeventd.
301
302 LVM_SYSTEM_DIR
303 Directory containing lvm.conf(5) and other LVM system files.
304 Defaults to "/etc/lvm".
305
306 LVM_SUPPRESS_FD_WARNINGS
307 Suppress warnings about unexpected file descriptors passed into
308 LVM.
309
310 LVM_SUPPRESS_SYSLOG
311 Suppress contacting syslog.
312
313 LVM_VG_NAME
314 The Volume Group name that is assumed for any reference to a
315 Logical Volume that doesn't specify a path. Not set by default.
316
317 LVM_LVMPOLLD_PIDFILE
318 Path to the file that stores the lvmpolld process ID.
319
320 LVM_LVMPOLLD_SOCKET
321 Path to the socket used to communicate with lvmpolld..
322
323 LVM_LOG_FILE_EPOCH
324 A string of up to 32 letters appended to the log filename and
325 followed by the process ID and a startup timestamp using this
326 format string "_%s_%d_%llu". When set, each process logs to a
327 separate file.
328
329 LVM_LOG_FILE_MAX_LINES
330 If more than this number of lines are sent to the log file, the
331 command gets aborted. Automated tests use this to terminate
332 looping commands.
333
334 LVM_EXPECTED_EXIT_STATUS
335 The status anticipated when the process exits. Use ">N" to
336 match any status greater than N. If the actual exit status
337 matches and a log file got produced, it is deleted.
338 LVM_LOG_FILE_EPOCH and LVM_EXPECTED_EXIT_STATUS together allow
339 automated test scripts to discard uninteresting log data.
340
341 LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES
342 Used to suppress warning messages when the configured locking is
343 known to be unavailable.
344
345 DM_ABORT_ON_INTERNAL_ERRORS
346 Abort processing if the code detects a non-fatal internal error.
347
348 DM_DISABLE_UDEV
349 Avoid interaction with udev. LVM will manage the relevant nodes
350 in /dev directly.
351
352 DM_DEBUG_WITH_LINE_NUMBERS
353 Prepends source file name and code line number with libdm debug‐
354 ging.
355
357 /etc/lvm/lvm.conf
358 $HOME/.lvm_history
359
361 lvm(8), lvm.conf(5), lvmconfig(8),
362
363 pvchange(8), pvck(8), pvcreate(8), pvdisplay(8), pvmove(8),
364 pvremove(8), pvresize(8), pvs(8), pvscan(8),
365
366 vgcfgbackup(8), vgcfgrestore(8), vgchange(8), vgck(8), vgcreate(8),
367 vgconvert(8), vgdisplay(8), vgexport(8), vgextend(8), vgimport(8),
368 vgimportclone(8), vgmerge(8), vgmknodes(8), vgreduce(8), vgremove(8),
369 vgrename(8), vgs(8), vgscan(8), vgsplit(8),
370
371 lvcreate(8), lvchange(8), lvconvert(8), lvdisplay(8), lvextend(8),
372 lvreduce(8), lvremove(8), lvrename(8), lvresize(8), lvs(8), lvscan(8),
373
374 lvm-fullreport(8), lvm-lvpoll(8), blkdeactivate(8), lvmdump(8),
375
376 dmeventd(8), lvmpolld(8), lvmlockd(8), lvmlockctl(8), cmirrord(8),
377 lvmdbusd(8),
378
379 lvmsystemid(7), lvmreport(7), lvmraid(7), lvmthin(7), lvmcache(7),
380 lvmautoactivation(7),
381
382 dmsetup(8), dmstats(8), editline(3)
383
384
385
386Red Hat, Inc. LVM TOOLS 2.03.18(2)-git (2022-11-10) LVM(8)