1LVM(8) System Manager's Manual LVM(8)
2
3
4
6 lvm — LVM2 tools
7
9 lvm [command|file]
10
12 lvm provides the command-line tools for LVM2. A separate manual page
13 describes each command in detail.
14
15 If lvm is invoked with no arguments it presents a readline prompt
16 (assuming it was compiled with readline support). LVM commands may be
17 entered interactively at this prompt with readline facilities including
18 history and command name and option completion. Refer to readline(3)
19 for details.
20
21 If lvm is invoked with argv[0] set to the name of a specific LVM com‐
22 mand (for example by using a hard or soft link) it acts as that com‐
23 mand.
24
25 On invocation, lvm requires that only the standard file descriptors
26 stdin, stdout and stderr are available. If others are found, they get
27 closed and messages are issued warning about the leak. This warning
28 can be suppressed by setting the environment variable LVM_SUP‐
29 PRESS_FD_WARNINGS.
30
31 Where commands take VG or LV names as arguments, the full path name is
32 optional. An LV called "lvol0" in a VG called "vg0" can be specified
33 as "vg0/lvol0". Where a list of VGs is required but is left empty, a
34 list of all VGs will be substituted. Where a list of LVs is required
35 but a VG is given, a list of all the LVs in that VG will be substi‐
36 tuted. So lvdisplay vg0 will display all the LVs in "vg0". Tags can
37 also be used - see --addtag below.
38
39 One advantage of using the built-in shell is that configuration infor‐
40 mation gets cached internally between commands.
41
42 A file containing a simple script with one command per line can also be
43 given on the command line. The script can also be executed directly if
44 the first line is #! followed by the absolute path of lvm.
45
47 The following commands are built into lvm without links normally being
48 created in the filesystem for them.
49
50 config The same as lvmconfig(8) below.
51 devtypes Display the recognised built-in block device types.
52 dumpconfig The same as lvmconfig(8) below.
53 formats Display recognised metadata formats.
54 help Display the help text.
55 lvpoll Complete lvmpolld operations (Internal command).
56 pvdata Not implemented in LVM2.
57 segtypes Display recognised Logical Volume segment types.
58 systemid Display any system ID currently set on this host.
59 tags Display any tags defined on this host.
60 version Display version information.
61
63 The following commands implement the core LVM functionality.
64
65 pvchange Change attributes of a Physical Volume.
66 pvck Check Physical Volume metadata.
67 pvcreate Initialize a disk or partition for use by LVM.
68 pvdisplay Display attributes of a Physical Volume.
69 pvmove Move Physical Extents.
70 pvremove Remove a Physical Volume.
71 pvresize Resize a disk or partition in use by LVM2.
72 pvs Report information about Physical Volumes.
73 pvscan Scan all disks for Physical Volumes.
74 vgcfgbackup Backup Volume Group descriptor area.
75 vgcfgrestore Restore Volume Group descriptor area.
76 vgchange Change attributes of a Volume Group.
77 vgck Check Volume Group metadata.
78 vgconvert Convert Volume Group metadata format.
79 vgcreate Create a Volume Group.
80 vgdisplay Display attributes of Volume Groups.
81 vgexport Make volume Groups unknown to the system.
82 vgextend Add Physical Volumes to a Volume Group.
83 vgimport Make exported Volume Groups known to the system.
84 vgimportclone Import and rename duplicated Volume Group (e.g. a hard‐
85 ware snapshot).
86 vgmerge Merge two Volume Groups.
87 vgmknodes Recreate Volume Group directory and Logical Volume spe‐
88 cial files
89 vgreduce Reduce a Volume Group by removing one or more Physical
90 Volumes.
91 vgremove Remove a Volume Group.
92 vgrename Rename a Volume Group.
93 vgs Report information about Volume Groups.
94 vgscan Scan all disks for Volume Groups and rebuild caches.
95 vgsplit Split a Volume Group into two, moving any logical volumes
96 from one Volume Group to another by moving entire Physi‐
97 cal Volumes.
98 lvchange Change attributes of a Logical Volume.
99 lvconvert Convert a Logical Volume from linear to mirror or snap‐
100 shot.
101 lvcreate Create a Logical Volume in an existing Volume Group.
102 lvdisplay Display attributes of a Logical Volume.
103 lvextend Extend the size of a Logical Volume.
104 lvmchange Change attributes of the Logical Volume Manager.
105 lvmconfig Display the configuration information after loading
106 lvm.conf(5) and any other configuration files.
107 lvmdiskscan Scan for all devices visible to LVM2.
108 lvmdump Create lvm2 information dumps for diagnostic purposes.
109 lvreduce Reduce the size of a Logical Volume.
110 lvremove Remove a Logical Volume.
111 lvrename Rename a Logical Volume.
112 lvresize Resize a Logical Volume.
113 lvs Report information about Logical Volumes.
114 lvscan Scan (all disks) for Logical Volumes.
115
116 The following commands are not implemented in LVM2 but might be in the
117 future: lvmsadc, lvmsar, pvdata.
118
120 The following options are available for many of the commands. They are
121 implemented generically and documented here rather than repeated on
122 individual manual pages.
123
124 Additional hyphens within option names are ignored. For example,
125 --readonly and --read-only are both accepted.
126
127 -h|-?|--help
128 Display the help text.
129
130 --version
131 Display version information.
132
133 -v|--verbose
134 Set verbose level. Repeat from 1 to 3 times to increase the
135 detail of messages sent to stdout and stderr. Overrides config
136 file setting.
137
138 -d|--debug
139 Set debug level. Repeat from 1 to 6 times to increase the detail
140 of messages sent to the log file and/or syslog (if configured).
141 Overrides config file setting.
142
143 -q|--quiet
144 Suppress output and log messages. Overrides -d and -v. Repeat
145 once to also suppress any prompts with answer 'no'.
146
147 --yes
148 Don't prompt for confirmation interactively but instead always
149 assume the answer is 'yes'. Take great care if you use this!
150
151 -t|--test
152 Run in test mode. Commands will not update metadata. This is
153 implemented by disabling all metadata writing but nevertheless
154 returning success to the calling function. This may lead to
155 unusual error messages in multi-stage operations if a tool
156 relies on reading back metadata it believes has changed but
157 hasn't.
158
159 --driverloaded {y|n}
160 Whether or not the device-mapper kernel driver is loaded. If
161 you set this to n, no attempt will be made to contact the
162 driver.
163
164 -A|--autobackup {y|n}
165 Whether or not to metadata should be backed up automatically
166 after a change. You are strongly advised not to disable this!
167 See vgcfgbackup(8).
168
169 -P|--partial
170 When set, the tools will do their best to provide access to Vol‐
171 ume Groups that are only partially available (one or more Physi‐
172 cal Volumes belonging to the Volume Group are missing from the
173 system). Where part of a logical volume is missing,
174 /dev/ioerror will be substituted, and you could use dmsetup(8)
175 to set this up to return I/O errors when accessed, or create it
176 as a large block device of nulls. Metadata may not be changed
177 with this option. To insert a replacement Physical Volume of the
178 same or large size use pvcreate -u to set the uuid to match the
179 original followed by vgcfgrestore(8).
180
181 -S|--select Selection
182 For reporting commands, display only rows that match Selection
183 criteria. All rows are displayed with the additional "selected"
184 column (-o selected) showing 1 if the row matches the Selection
185 and 0 otherwise. For non-reporting commands which process LVM
186 entities, the selection can be used to match items to process.
187 See SELECTION CRITERIA section of this man page for more infor‐
188 mation about the way the selection criteria are constructed.
189
190 -M|--metadatatype Type
191 Specifies which type of on-disk metadata to use, such as lvm1 or
192 lvm2, which can be abbreviated to 1 or 2 respectively. The
193 default (lvm2) can be changed by setting format in the global
194 section of the config file lvm.conf(5).
195
196 --ignorelockingfailure
197 This lets you proceed with read-only metadata operations such as
198 lvchange -ay and vgchange -ay even if the locking module fails.
199 One use for this is in a system init script if the lock direc‐
200 tory is mounted read-only when the script runs.
201
202 --ignoreskippedcluster
203 Use to avoid exiting with an non-zero status code if the command
204 is run without clustered locking and some clustered Volume
205 Groups have to be skipped over.
206
207 --readonly
208 Run the command in a special read-only mode which will read on-
209 disk metadata without needing to take any locks. This can be
210 used to peek inside metadata used by a virtual machine image
211 while the virtual machine is running. It can also be used to
212 peek inside the metadata of clustered Volume Groups when clus‐
213 tered locking is not configured or running. No attempt will be
214 made to communicate with the device-mapper kernel driver, so
215 this option is unable to report whether or not Logical Volumes
216 are actually in use.
217
218 --foreign
219 Cause the command to access foreign VGs, that would otherwise be
220 skipped. It can be used to report or display a VG that is owned
221 by another host. This option can cause a command to perform
222 poorly because lvmetad caching is not used and metadata is read
223 from disks.
224
225 --shared
226 Cause the command to access shared VGs, that would otherwise be
227 skipped when lvmlockd is not being used. It can be used to
228 report or display a lockd VG without locking. Applicable only if
229 LVM is compiled with lockd support.
230
231 --addtag Tag
232 Add the tag Tag to a PV, VG or LV. Supply this argument multi‐
233 ple times to add more than one tag at once. A tag is a word
234 that can be used to group LVM2 objects of the same type
235 together. Tags can be given on the command line in place of PV,
236 VG or LV arguments. Tags should be prefixed with @ to avoid
237 ambiguity. Each tag is expanded by replacing it with all
238 objects possessing that tag which are of the type expected by
239 its position on the command line. PVs can only possess tags
240 while they are part of a Volume Group: PV tags are discarded if
241 the PV is removed from the VG. As an example, you could tag
242 some LVs as database and others as userdata and then activate
243 the database ones with lvchange -ay @database. Objects can pos‐
244 sess multiple tags simultaneously. Only the new LVM2 metadata
245 format supports tagging: objects using the LVM1 metadata format
246 cannot be tagged because the on-disk format does not support it.
247 Characters allowed in tags are: A-Z a-z 0-9 _ + . - and as of
248 version 2.02.78 the following characters are also accepted: / =
249 ! : # &.
250
251 --deltag Tag
252 Delete the tag Tag from a PV, VG or LV, if it's present. Supply
253 this argument multiple times to remove more than one tag at
254 once.
255
256 --alloc {anywhere|contiguous|cling|inherit|normal}
257 Selects the allocation policy when a command needs to allocate
258 Physical Extents from the Volume Group. Each Volume Group and
259 Logical Volume has an allocation policy defined. The default
260 for a Volume Group is normal which applies common-sense rules
261 such as not placing parallel stripes on the same Physical Vol‐
262 ume. The default for a Logical Volume is inherit which applies
263 the same policy as for the Volume Group. These policies can be
264 changed using lvchange(8) and vgchange(8) or overridden on the
265 command line of any command that performs allocation. The con‐
266 tiguous policy requires that new Physical Extents be placed
267 adjacent to existing Physical Extents. The cling policy places
268 new Physical Extents on the same Physical Volume as existing
269 Physical Extents in the same stripe of the Logical Volume. If
270 there are sufficient free Physical Extents to satisfy an alloca‐
271 tion request but normal doesn't use them, anywhere will - even
272 if that reduces performance by placing two stripes on the same
273 Physical Volume.
274
275 --commandprofile ProfileName
276 Selects the command configuration profile to use when processing
277 an LVM command. See also lvm.conf(5) for more information about
278 command profile config and the way it fits with other LVM con‐
279 figuration methods. Using --commandprofile option overrides any
280 command profile specified via LVM_COMMAND_PROFILE environment
281 variable.
282
283 --metadataprofile ProfileName
284 Selects the metadata configuration profile to use when process‐
285 ing an LVM command. When using metadata profile during Volume
286 Group or Logical Volume creation, the metadata profile name is
287 saved in metadata. When such Volume Group or Logical Volume is
288 processed next time, the metadata profile is automatically
289 applied and the use of --metadataprofile option is not neces‐
290 sary. See also lvm.conf(5) for more information about metadata
291 profile config and the way it fits with other LVM configuration
292 methods.
293
294 --profile ProfileName
295 A short form of --metadataprofile for vgcreate, lvcreate,
296 vgchange and lvchange command and a short form of --commandpro‐
297 file for any other command (with the exception of lvmconfig com‐
298 mand where the --profile has special meaning, see lvmconfig(8)
299 for more information).
300
301 --config ConfigurationString
302 Uses the ConfigurationString as direct string representation of
303 the configuration to override the existing configuration. The
304 ConfigurationString is of exactly the same format as used in any
305 LVM configuration file. See lvm.conf(5) for more information
306 about direct config override on command line and the way it fits
307 with other LVM configuration methods.
308
310 The valid characters for VG and LV names are: a-z A-Z 0-9 + _ . -
311
312 VG and LV names cannot begin with a hyphen. There are also various
313 reserved names that are used internally by lvm that can not be used as
314 LV or VG names. A VG cannot be called anything that exists in /dev/ at
315 the time of creation, nor can it be called '.' or '..'. An LV cannot
316 be called '.', '..', 'snapshot' or 'pvmove'. The LV name may also not
317 contain any of the following strings: '_cdata', '_cmeta', '_corig',
318 '_mlog', '_mimage', '_pmspare', '_rimage', '_rmeta', '_tdata', '_tmeta'
319 or '_vorigin'. A directory bearing the name of each Volume Group is
320 created under /dev when any of its Logical Volumes are activated. Each
321 active Logical Volume is accessible from this directory as a symbolic
322 link leading to a device node. Links or nodes in /dev/mapper are
323 intended only for internal use and the precise format and escaping
324 might change between releases and distributions. Other software and
325 scripts should use the /dev/VolumeGroupName/LogicalVolumeName format to
326 reduce the chance of needing amendment when the software is updated.
327 Should you need to process the node names in /dev/mapper, you may use
328 dmsetup splitname to separate out the original VG, LV and internal
329 layer names.
330
332 VG names should be unique. vgcreate will produce an error if the spec‐
333 ified VG name matches an existing VG name. However, there are cases
334 where different VGs with the same name can appear to LVM, e.g. after
335 moving disks or changing filters.
336
337 When VGs with the same name exist, commands operating on all VGs will
338 include all of the VGs with the same name. If the ambiguous VG name is
339 specified on the command line, the command will produce an error. The
340 error states that multiple VGs exist with the specified name. To
341 process one of the VGs specifically, the --select option should be used
342 with the UUID of the intended VG: '--select vg_uuid=<uuid>'.
343
344 An exception is if all but one of the VGs with the shared name is for‐
345 eign (see lvmsystemid(7).) In this case, the one VG that is not for‐
346 eign is assumed to be the intended VG and is processed.
347
348
350 When an operation needs to allocate Physical Extents for one or more
351 Logical Volumes, the tools proceed as follows:
352
353 First of all, they generate the complete set of unallocated Physical
354 Extents in the Volume Group. If any ranges of Physical Extents are
355 supplied at the end of the command line, only unallocated Physical
356 Extents within those ranges on the specified Physical Volumes are con‐
357 sidered.
358
359 Then they try each allocation policy in turn, starting with the
360 strictest policy (contiguous) and ending with the allocation policy
361 specified using --alloc or set as the default for the particular Logi‐
362 cal Volume or Volume Group concerned. For each policy, working from
363 the lowest-numbered Logical Extent of the empty Logical Volume space
364 that needs to be filled, they allocate as much space as possible
365 according to the restrictions imposed by the policy. If more space is
366 needed, they move on to the next policy.
367
368 The restrictions are as follows:
369
370 Contiguous requires that the physical location of any Logical Extent
371 that is not the first Logical Extent of a Logical Volume is adjacent to
372 the physical location of the Logical Extent immediately preceding it.
373
374 Cling requires that the Physical Volume used for any Logical Extent to
375 be added to an existing Logical Volume is already in use by at least
376 one Logical Extent earlier in that Logical Volume. If the configura‐
377 tion parameter allocation/cling_tag_list is defined, then two Physical
378 Volumes are considered to match if any of the listed tags is present on
379 both Physical Volumes. This allows groups of Physical Volumes with
380 similar properties (such as their physical location) to be tagged and
381 treated as equivalent for allocation purposes.
382
383 When a Logical Volume is striped or mirrored, the above restrictions
384 are applied independently to each stripe or mirror image (leg) that
385 needs space.
386
387 Normal will not choose a Physical Extent that shares the same Physical
388 Volume as a Logical Extent already allocated to a parallel Logical Vol‐
389 ume (i.e. a different stripe or mirror image/leg) at the same offset
390 within that parallel Logical Volume.
391
392 When allocating a mirror log at the same time as Logical Volumes to
393 hold the mirror data, Normal will first try to select different Physi‐
394 cal Volumes for the log and the data. If that's not possible and the
395 allocation/mirror_logs_require_separate_pvs configuration parameter is
396 set to 0, it will then allow the log to share Physical Volume(s) with
397 part of the data.
398
399 When allocating thin pool metadata, similar considerations to those of
400 a mirror log in the last paragraph apply based on the value of the
401 allocation/thin_pool_metadata_require_separate_pvs configuration param‐
402 eter.
403
404 If you rely upon any layout behaviour beyond that documented here, be
405 aware that it might change in future versions of the code.
406
407 For example, if you supply on the command line two empty Physical Vol‐
408 umes that have an identical number of free Physical Extents available
409 for allocation, the current code considers using each of them in the
410 order they are listed, but there is no guarantee that future releases
411 will maintain that property. If it is important to obtain a specific
412 layout for a particular Logical Volume, then you should build it up
413 through a sequence of lvcreate(8) and lvconvert(8) steps such that the
414 restrictions described above applied to each step leave the tools no
415 discretion over the layout.
416
417 To view the way the allocation process currently works in any specific
418 case, read the debug logging output, for example by adding -vvvv to a
419 command.
420
422 Some logical volume types are simple to create and can be done with a
423 single lvcreate(8) command. The linear and striped logical volume
424 types are an example of this. Other logical volume types may require
425 more than one command to create. The cache (lvmcache(7)) and thin pro‐
426 visioning (lvmthin(7)) types are examples of this.
427
429 The selection criteria are a set of statements combined by logical and
430 grouping operators. The statement consists of column name for which a
431 set of valid values is defined using comparison operators. For complete
432 list of column names (fields) that can be used in selection, see the
433 output of <lvm reporting command> -S help.
434
435 Comparison operators (cmp_op)
436 =~ Matching regular expression.
437 !~ Not matching regular expression.
438 = Equal to.
439 != Not equal to.
440 >= Greater than or equal to.
441 > Greater than
442 <= Less than or equal to.
443 < Less than.
444
445 Binary logical operators (cmp_log)
446 && All fields must match
447 , All fields must match
448 || At least one field must match
449 # At least one field must match
450
451 Unary logical operators
452 ! Logical negation
453
454 Grouping operators
455 ( Left parenthesis
456 ) Right parenthesis
457 [ List start
458 ] List end
459 { List subset start
460 } List subset end
461
462 Informal grammar specification
463 STATEMENT = column cmp_op VALUE | STATEMENT log_op STATEMENT |
464 (STATEMENT) | !(STATEMENT)
465
466 VALUE = [VALUE log_op VALUE]
467 For list-based types: string list. Matches strictly. The log_op
468 must always be of one type within the whole list value.
469
470 VALUE = {VALUE log_op VALUE}
471 For list-based types: string list. Matches a subset. The log_op
472 must always be of one type within the whole list value.
473
474 VALUE = value
475 For scalar types: number (integer), size (floating point number
476 with size unit suffix), percent (floating point number with or
477 without % suffix), string.
478
480 All tools return a status code of zero on success or non-zero on fail‐
481 ure.
482
484 HOME Directory containing .lvm_history if the internal readline shell
485 is invoked.
486
487 LVM_COMMAND_PROFILE
488 Name of default command profile to use for LVM commands. This
489 profile is overriden by direct use of --commandprofile command
490 line option.
491
492 LVM_SYSTEM_DIR
493 Directory containing lvm.conf(5) and other LVM system files.
494 Defaults to "/etc/lvm".
495
496 LVM_SUPPRESS_FD_WARNINGS
497 Suppress warnings about unexpected file descriptors passed into
498 LVM.
499
500 LVM_VG_NAME
501 The Volume Group name that is assumed for any reference to a
502 Logical Volume that doesn't specify a path. Not set by default.
503
504 LVM_LVMETAD_PIDFILE
505 Path to the file that stores the lvmetad process ID.
506
507 LVM_LVMETAD_SOCKET
508 Path to the socket used to communicate with lvmetad.
509
510 LVM_LVMPOLLD_PIDFILE
511 Path to the file that stores the lvmpolld process ID.
512
513 LVM_LVMPOLLD_SOCKET
514 Path to the socket used to communicate with lvmpolld..
515
516 LVM_LOG_FILE_EPOCH
517 A string of up to 32 letters appended to the log filename and
518 followed by the process ID and a timestamp. When set, each
519 process logs to a separate file.
520
521 LVM_EXPECTED_EXIT_STATUS
522 The status anticipated when the process exits. Use ">N" to
523 match any status greater than N. If the actual exit status
524 matches and a log file got produced, it is deleted.
525 LVM_LOG_FILE_EPOCH and LVM_EXPECTED_EXIT_STATUS together allow
526 automated test scripts to discard uninteresting log data.
527
528 LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES
529 Used to suppress warning messages when the configured locking is
530 known to be unavailable.
531
532 DM_ABORT_ON_INTERNAL_ERRORS
533 Abort processing if the code detects a non-fatal internal error.
534
535 DM_DISABLE_UDEV
536 Avoid interaction with udev. LVM will manage the relevant nodes
537 in /dev directly.
538
540 /etc/lvm/lvm.conf
541 $HOME/.lvm_history
542
544 lvm.conf(5), lvmcache(7), lvmthin(7), clvmd(8), dmsetup(8),
545 lvchange(8), lvcreate(8), lvdisplay(8), lvextend(8), lvmchange(8),
546 lvmconfig(8), lvmdiskscan(8), lvreduce(8), lvremove(8), lvrename(8),
547 lvresize(8), lvs(8), lvscan(8), pvchange(8), pvck(8), pvcreate(8),
548 pvdisplay(8), pvmove(8), pvremove(8), pvs(8), pvscan(8),
549 vgcfgbackup(8), vgchange(8), vgck(8), vgconvert(8), vgcreate(8),
550 vgdisplay(8), vgextend(8), vgimport(8), vgimportclone(8), vgmerge(8),
551 vgmknodes(8), vgreduce(8), vgremove(8), vgrename(8), vgs(8), vgscan(8),
552 vgsplit(8), readline(3)
553
554
555
556Sistina Software UKLVM TOOLS 2.02.143(2)-RHEL6 (2016-12-13) LVM(8)