Section: Maintenance Commands (8)
Updated: LVM TOOLS (2) (2014-09-01)
lvm provides the command-line tools for LVM2. A separate manual page describes each command in detail.
If lvm is invoked with no arguments it presents a readline prompt (assuming it was compiled with readline support). LVM commands may be entered interactively at this prompt with readline facilities including history and command name and option completion. Refer to readline?(3) for details.
If lvm is invoked with argv set to the name of a specific LVM command (for example by using a hard or soft link) it acts as that command.
On invocation, lvm requires that only the standard file descriptors stdin, stdout and stderr are available. If others are found, they get closed and messages are issued warning about the leak. This warning can be suppressed by setting the environment variable LVM_SUPPRESS_FD_WARNINGS.
Where commands take VG or LV names as arguments, the full path name is optional. An LV called "lvol0" in a VG called "vg0" can be specified as "vg0/lvol0". Where a list of VGs is required but is left empty, a list of all VGs will be substituted. Where a list of LVs is required but a VG is given, a list of all the LVs in that VG will be substituted. So lvdisplay vg0 will display all the LVs in "vg0". Tags can also be used - see --addtag below.
One advantage of using the built-in shell is that configuration information gets cached internally between commands.
A file containing a simple script with one command per line can also be given on the command line. The script can also be executed directly if the first line is #! followed by the absolute path of lvm.
The following commands are built into lvm without links normally being created in the filesystem for them.
:devtypes --- Display the recognised built-in block device types.
:formats --- Display recognised metadata formats.
:help --- Display the help text.
:pvdata --- Not implemented in LVM2.
:segtypes --- Display recognised Logical Volume segment types.
:tags --- Display any tags defined on this host.
:version --- Display version information.
The following commands implement the core LVM functionality.
:pvchange --- Change attributes of a Physical Volume.
:pvck --- Check Physical Volume metadata.
:pvcreate --- Initialize a disk or partition for use by LVM.
:pvdisplay --- Display attributes of a Physical Volume.
:pvmove --- Move Physical Extents.
:pvremove --- Remove a Physical Volume.
:pvresize --- Resize a disk or partition in use by LVM2.
:pvs --- Report information about Physical Volumes.
:pvscan --- Scan all disks for Physical Volumes.
:vgcfgbackup --- Backup Volume Group descriptor area.
:vgcfgrestore --- Restore Volume Group descriptor area.
:vgchange --- Change attributes of a Volume Group.
:vgck --- Check Volume Group metadata.
:vgconvert --- Convert Volume Group metadata format.
:vgcreate --- Create a Volume Group.
:vgdisplay --- Display attributes of Volume Groups.
:vgexport --- Make volume Groups unknown to the system.
:vgextend --- Add Physical Volumes to a Volume Group.
:vgimport --- Make exported Volume Groups known to the system.
:vgimportclone --- Import and rename duplicated Volume Group (e.g. a hardware snapshot).
:vgmerge --- Merge two Volume Groups.
:vgmknodes --- Recreate Volume Group directory and Logical Volume special files
:vgremove --- Remove a Volume Group.
:vgrename --- Rename a Volume Group.
:vgs --- Report information about Volume Groups.
:vgscan --- Scan all disks for Volume Groups and rebuild caches.
:lvchange --- Change attributes of a Logical Volume.
:lvconvert --- Convert a Logical Volume from linear to mirror or snapshot.
:lvcreate --- Create a Logical Volume in an existing Volume Group.
:lvdisplay --- Display attributes of a Logical Volume.
:lvextend --- Extend the size of a Logical Volume.
:lvmchange --- Change attributes of the Logical Volume Manager.
:lvmdiskscan --- Scan for all devices visible to LVM2.
:lvmdump --- Create lvm2 information dumps for diagnostic purposes.
:lvreduce --- Reduce the size of a Logical Volume.
:lvremove --- Remove a Logical Volume.
:lvrename --- Rename a Logical Volume.
:lvresize --- Resize a Logical Volume.
:lvs --- Report information about Logical Volumes.
:lvscan --- Scan (all disks) for Logical Volumes.
The following options are available for many of the commands. They are implemented generically and documented here rather than repeated on individual manual pages.
The valid characters for VG and LV names are: a-z A-Z 0-9 + _ . -
VG and LV names cannot begin with a hyphen. There are also various reserved names that are used internally by lvm that can not be used as LV or VG names. A VG cannot be called anything that exists in /dev/ at the time of creation, nor can it be called '.' or '..'. An LV cannot be called '.', '..', 'snapshot' or 'pvmove'. The LV name may also not contain any of the following strings: '_cdata', '_cmeta', '_mlog', '_mimage', '_pmspare', '_rimage', '_rlog', '_tdata' or '_tmeta'. A directory bearing the name of each Volume Group is created under /dev when any of its Logical Volumes are activated. Each active Logical Volume is accessible from this directory as a symbolic link leading to a device node. Links or nodes in /dev/mapper are intended only for internal use and the precise format and escaping might change between releases and distributions. Other software and scripts should use the /dev/VolumeGroupName/LogicalVolumeName format to reduce the chance of needing amendment when the software is updated. Should you need to process the node names in /dev/mapper, you may use dmsetup splitname to separate out the original VG, LV and internal layer names.
When an operation needs to allocate Physical Extents for one or more Logical Volumes, the tools proceed as follows:
First of all, they generate the complete set of unallocated Physical Extents in the Volume Group. If any ranges of Physical Extents are supplied at the end of the command line, only unallocated Physical Extents within those ranges on the specified Physical Volumes are considered.
Then they try each allocation policy in turn, starting with the strictest policy (contiguous) and ending with the allocation policy specified using --alloc or set as the default for the particular Logical Volume or Volume Group concerned. For each policy, working from the lowest-numbered Logical Extent of the empty Logical Volume space that needs to be filled, they allocate as much space as possible according to the restrictions imposed by the policy. If more space is needed, they move on to the next policy.
The restrictions are as follows:
Contiguous requires that the physical location of any Logical Extent that is not the first Logical Extent of a Logical Volume is adjacent to the physical location of the Logical Extent immediately preceding it.
Cling requires that the Physical Volume used for any Logical Extent to be added to an existing Logical Volume is already in use by at least one Logical Extent earlier in that Logical Volume. If the configuration parameter allocation/cling_tag_list is defined, then two Physical Volumes are considered to match if any of the listed tags is present on both Physical Volumes. This allows groups of Physical Volumes with similar properties (such as their physical location) to be tagged and treated as equivalent for allocation purposes.
When a Logical Volume is striped or mirrored, the above restrictions are applied independently to each stripe or mirror image (leg) that needs space.
Normal will not choose a Physical Extent that shares the same Physical Volume as a Logical Extent already allocated to a parallel Logical Volume (i.e. a different stripe or mirror image/leg) at the same offset within that parallel Logical Volume.
When allocating a mirror log at the same time as Logical Volumes to hold the mirror data, Normal will first try to select different Physical Volumes for the log and the data. If that's not possible and the allocation/mirror_logs_require_separate_pvs configuration parameter is set to 0, it will then allow the log to share Physical Volume(s) with part of the data.
When allocating thin pool metadata, similar considerations to those of a mirror log in the last paragraph apply based on the value of the allocation/thin_pool_metadata_require_separate_pvs configuration parameter.
If you rely upon any layout behaviour beyond that documented here, be aware that it might change in future versions of the code.
For example, if you supply on the command line two empty Physical Volumes that have an identical number of free Physical Extents available for allocation, the current code considers using each of them in the order they are listed, but there is no guarantee that future releases will maintain that property. If it is important to obtain a specific layout for a particular Logical Volume, then you should build it up through a sequence of lvcreate?(8) and lvconvert?(8) steps such that the restrictions described above applied to each step leave the tools no discretion over the layout.
To view the way the allocation process currently works in any specific case, read the debug logging output, for example by adding -vvvv to a command.
Some logical volume types are simple to create and can be done with a single lvcreate?(8) command. The linear and striped logical volume types are an example of this. Other logical volume types may require more than one command to create. The cache (lvmcache?(7)) and thin provisioning (lvmthin?(7)) types are examples of this.
The selection criteria are a set of statements combined by logical and grouping operators. The statement consists of column name for which a set of valid values is defined using comparison operators. For complete list of column names (fields) that can be used in selection, see the output of <lvm reporting command> -S help.
Comparison operators (cmp_op):
Binary logical operators (cmp_log):
Unary logical operators:
Informal grammar specification:
:STATEMENT = column cmp_op VALUE | STATEMENT log_op STATEMENT | (STATEMENT) | !(STATEMENT)VALUE = [VALUE log_op VALUE]
For list-based types: string list. The log_op must always be of one type within the whole list value.VALUE = value
For scalar types: number (integer), size (floating point number with size unit suffix), percent (floating point number with or without % suffix), string.:
(5), lvmcache?(7), lvmthin?(7), lvm dumpconfig?(8), clvmd?(8), dmsetup?(8), lvchange?(8), lvcreate?(8), lvdisplay?(8), lvextend?(8), lvmchange?(8), lvmdiskscan?(8), lvreduce?(8), lvremove?(8), lvrename?(8), lvresize?(8), lvs?(8), lvscan?(8), pvchange?(8), pvck?(8), pvcreate?(8), pvdisplay?(8), pvmove?(8), pvremove?(8), pvs?(8), pvscan?(8), vgcfgbackup?(8), vgchange?(8), vgck?(8), vgconvert?(8), vgcreate?(8), vgdisplay?(8), vgextend?(8), vgimport?(8), vgimportclone?(8), vgmerge?(8), vgmknodes?(8), vgreduce?(8), vgremove?(8), vgrename?(8), vgs?(8), vgscan?(8), vgsplit?(8), readline?(3)
Tutoriais de Tecnologia Web