.TH LVM 8 "LVM TOOLS #VERSION#" "Sistina Software UK" \" -*- nroff -*- . .SH NAME . lvm \(em LVM2 tools . .SH SYNOPSIS . .B lvm .RI [ command | file ] . .SH DESCRIPTION . lvm provides the command-line tools for LVM2. A separate manual page describes each command in detail. .P If \fBlvm\fP 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 \fBreadline\fP(3) for details. .P If \fBlvm\fP is invoked with argv[0] set to the name of a specific LVM command (for example by using a hard or soft link) it acts as that command. .P On invocation, \fBlvm\fP 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 .B LVM_SUPPRESS_FD_WARNINGS\fP. .P 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 \fBlvdisplay vg0\fP will display all the LVs in "vg0". Tags can also be used - see \fB\-\-addtag\fP below. .P One advantage of using the built-in shell is that configuration information gets cached internally between commands. .P 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 \fBlvm\fP. . .SH BUILT-IN COMMANDS . The following commands are built into lvm without links normally being created in the filesystem for them. .sp .PD 0 .TP 14 .B config The same as \fBlvmconfig\fP(8) below. .TP .B devtypes Display the recognised built-in block device types. .TP .B dumpconfig The same as \fBlvmconfig\fP(8) below. .TP .B formats Display recognised metadata formats. .TP .B help Display the help text. .TP .B lvpoll Complete lvmpolld operations (Internal command). .TP .B pvdata Not implemented in LVM2. .TP .B segtypes Display recognised Logical Volume segment types. .TP .B systemid Display any system ID currently set on this host. .TP .B tags Display any tags defined on this host. .TP .B version Display version information. .PD . .SH COMMANDS . The following commands implement the core LVM functionality. .sp .PD 0 .TP 14 .B pvchange Change attributes of a Physical Volume. .TP .B pvck Check Physical Volume metadata. .TP .B pvcreate Initialize a disk or partition for use by LVM. .TP .B pvdisplay Display attributes of a Physical Volume. .TP .B pvmove Move Physical Extents. .TP .B pvremove Remove a Physical Volume. .TP .B pvresize Resize a disk or partition in use by LVM2. .TP .B pvs Report information about Physical Volumes. .TP .B pvscan Scan all disks for Physical Volumes. .TP .B vgcfgbackup Backup Volume Group descriptor area. .TP .B vgcfgrestore Restore Volume Group descriptor area. .TP .B vgchange Change attributes of a Volume Group. .TP .B vgck Check Volume Group metadata. .TP .B vgconvert Convert Volume Group metadata format. .TP .B vgcreate Create a Volume Group. .TP .B vgdisplay Display attributes of Volume Groups. .TP .B vgexport Make volume Groups unknown to the system. .TP .B vgextend Add Physical Volumes to a Volume Group. .TP .B vgimport Make exported Volume Groups known to the system. .TP .B vgimportclone Import and rename duplicated Volume Group (e.g. a hardware snapshot). .TP .B vgmerge Merge two Volume Groups. .TP .B vgmknodes Recreate Volume Group directory and Logical Volume special files .TP .B vgreduce Reduce a Volume Group by removing one or more Physical Volumes. .TP .B vgremove Remove a Volume Group. .TP .B vgrename Rename a Volume Group. .TP .B vgs Report information about Volume Groups. .TP .B vgscan Scan all disks for Volume Groups and rebuild caches. .TP .B vgsplit Split a Volume Group into two, moving any logical volumes from one Volume Group to another by moving entire Physical Volumes. .TP .B lvchange Change attributes of a Logical Volume. .TP .B lvconvert Convert a Logical Volume from linear to mirror or snapshot. .TP .B lvcreate Create a Logical Volume in an existing Volume Group. .TP .B lvdisplay Display attributes of a Logical Volume. .TP .B lvextend Extend the size of a Logical Volume. .TP .B lvmchange Change attributes of the Logical Volume Manager. .TP .B lvmconfig Display the configuration information after loading \fBlvm.conf\fP(5) and any other configuration files. .TP .B lvmdiskscan Scan for all devices visible to LVM2. .TP .B lvmdump Create lvm2 information dumps for diagnostic purposes. .TP .B lvreduce Reduce the size of a Logical Volume. .TP .B lvremove Remove a Logical Volume. .TP .B lvrename Rename a Logical Volume. .TP .B lvresize Resize a Logical Volume. .TP .B lvs Report information about Logical Volumes. .TP .B lvscan Scan (all disks) for Logical Volumes. .PD .P The following commands are not implemented in LVM2 but might be in the future: .BR lvmsadc ", " lvmsar ", " pvdata . . .SH OPTIONS . The following options are available for many of the commands. They are implemented generically and documented here rather than repeated on individual manual pages. .P Additional hyphens within option names are ignored. For example, \fB\-\-readonly\fP and \fB\-\-read\-only\fP are both accepted. . .HP .BR \-h | \-? | \-\-help .br Display the help text. . .HP .BR \-\-version .br Display version information. . .HP .BR \-v | \-\-verbose .br Set verbose level. Repeat from 1 to 3 times to increase the detail of messages sent to stdout and stderr. Overrides config file setting. . .HP .BR \-d | \-\-debug .br Set debug level. Repeat from 1 to 6 times to increase the detail of messages sent to the log file and/or syslog (if configured). Overrides config file setting. . .HP .BR \-q | \-\-quiet .br Suppress output and log messages. Overrides \fB\-d\fP and \fB\-v\fP. Repeat once to also suppress any prompts with answer 'no'. . .HP .BR \-\-yes .br Don't prompt for confirmation interactively but instead always assume the answer is 'yes'. Take great care if you use this! . .HP .BR \-t | \-\-test .br Run in test mode. Commands will not update metadata. This is implemented by disabling all metadata writing but nevertheless returning success to the calling function. This may lead to unusual error messages in multi-stage operations if a tool relies on reading back metadata it believes has changed but hasn't. . .HP .BR \-\-driverloaded .RB { y | n } .br Whether or not the device-mapper kernel driver is loaded. If you set this to \fBn\fP, no attempt will be made to contact the driver. . .HP .BR \-A | \-\-autobackup .RB { y | n } .br Whether or not to metadata should be backed up automatically after a change. You are strongly advised not to disable this! See \fBvgcfgbackup\fP(8). . .HP .BR \-P | \-\-partial .br When set, the tools will do their best to provide access to Volume Groups that are only partially available (one or more Physical Volumes belonging to the Volume Group are missing from the system). Where part of a logical volume is missing, \fI\%/dev/ioerror\fP will be substituted, and you could use \fBdmsetup\fP(8) to set this up to return I/O errors when accessed, or create it as a large block device of nulls. Metadata may not be changed with this option. To insert a replacement Physical Volume of the same or large size use \fBpvcreate \-u\fP to set the uuid to match the original followed by \fBvgcfgrestore\fP(8). . .HP .BR \-S | \-\-select .IR Selection .br For reporting commands, display only rows that match \fISelection\fP criteria. All rows are displayed with the additional "selected" column (\fB-o selected\fP) showing 1 if the row matches the \fISelection\fP and 0 otherwise. For non-reporting commands which process LVM entities, the selection can be used to match items to process. See \fBSELECTION CRITERIA\fP section of this man page for more information about the way the selection criteria are constructed. . .HP .BR \-M | \-\-metadatatype .IR Type .br Specifies which \fItype\fP of on-disk metadata to use, such as \fBlvm1\fP or \fBlvm2\fP, which can be abbreviated to \fB1\fP or \fB2\fP respectively. The default (\fBlvm2\fP) can be changed by setting \fBformat\fP in the \fBglobal\fP section of the config file \fBlvm.conf\fP(5). . .HP .BR \-\-ignorelockingfailure .br This lets you proceed with read-only metadata operations such as \fBlvchange \-ay\fP and \fBvgchange \-ay\fP even if the locking module fails. One use for this is in a system init script if the lock directory is mounted read-only when the script runs. . .HP .BR \-\-ignoreskippedcluster .br Use to avoid exiting with an non-zero status code if the command is run without clustered locking and some clustered Volume Groups have to be skipped over. . .HP .BR \-\-readonly .br Run the command in a special read-only mode which will read on-disk metadata without needing to take any locks. This can be used to peek inside metadata used by a virtual machine image while the virtual machine is running. It can also be used to peek inside the metadata of clustered Volume Groups when clustered locking is not configured or running. No attempt will be made to communicate with the device-mapper kernel driver, so this option is unable to report whether or not Logical Volumes are actually in use. . .HP .BR \-\-foreign .br Cause the command to access foreign VGs, that would otherwise be skipped. It can be used to report or display a VG that is owned by another host. This option can cause a command to perform poorly because lvmetad caching is not used and metadata is read from disks. . .HP .BR \-\-shared .br Cause the command to access shared VGs, that would otherwise be skipped when lvmlockd is not being used. It can be used to report or display a lockd VG without locking. . .HP .BR \-\-addtag .IR Tag .br Add the tag \fITag\fP to a PV, VG or LV. Supply this argument multiple times to add more than one tag at once. A tag is a word that can be used to group LVM2 objects of the same type together. Tags can be given on the command line in place of PV, VG or LV arguments. Tags should be prefixed with @ to avoid ambiguity. Each tag is expanded by replacing it with all objects possessing that tag which are of the type expected by its position on the command line. PVs can only possess tags while they are part of a Volume Group: PV tags are discarded if the PV is removed from the VG. As an example, you could tag some LVs as \fBdatabase\fP and others as \fBuserdata\fP and then activate the database ones with \fBlvchange \-ay @database\fP. Objects can possess multiple tags simultaneously. Only the new LVM2 metadata format supports tagging: objects using the LVM1 metadata format cannot be tagged because the on-disk format does not support it. Characters allowed in tags are: .BR A - Z .BR a - z .BR 0 - 9 .BR "_ + . -" and as of version 2.02.78 the following characters are also accepted: .BR "/ = ! : # &" . . .HP .BR \-\-deltag .IR Tag .br Delete the tag \fITag\fP from a PV, VG or LV, if it's present. Supply this argument multiple times to remove more than one tag at once. . .HP .BR \-\-alloc .RB { anywhere | contiguous | cling | inherit | normal } .br Selects the allocation policy when a command needs to allocate Physical Extents from the Volume Group. Each Volume Group and Logical Volume has an allocation policy defined. The default for a Volume Group is \fBnormal\fP which applies common-sense rules such as not placing parallel stripes on the same Physical Volume. The default for a Logical Volume is \fBinherit\fP which applies the same policy as for the Volume Group. These policies can be changed using \fBlvchange\fP(8) and \fBvgchange\fP(8) or overridden on the command line of any command that performs allocation. The \fBcontiguous\fP policy requires that new Physical Extents be placed adjacent to existing Physical Extents. The \fBcling\fP policy places new Physical Extents on the same Physical Volume as existing Physical Extents in the same stripe of the Logical Volume. If there are sufficient free Physical Extents to satisfy an allocation request but \fBnormal\fP doesn't use them, \fBanywhere\fP will - even if that reduces performance by placing two stripes on the same Physical Volume. . .HP .BR \-\-commandprofile .IR ProfileName .br Selects the command configuration profile to use when processing an LVM command. See also \fBlvm.conf\fP(5) for more information about \fBcommand profile config\fP and the way it fits with other LVM configuration methods. Using \fB\-\-commandprofile\fP option overrides any command profile specified via \fBLVM_COMMAND_PROFILE\fP environment variable. . .HP .BR \-\-metadataprofile .IR ProfileName .br Selects the metadata configuration profile to use when processing an LVM command. When using metadata profile during Volume Group or Logical Volume creation, the metadata profile name is saved in metadata. When such Volume Group or Logical Volume is processed next time, the metadata profile is automatically applied and the use of \fB\-\-metadataprofile\fP option is not necessary. See also \fBlvm.conf\fP(5) for more information about \fBmetadata profile config\fP and the way it fits with other LVM configuration methods. . .HP .BR \-\-profile .IR ProfileName .br A short form of \fB\-\-metadataprofile\fP for \fBvgcreate\fP, \fBlvcreate\fP, \fBvgchange\fP and \fBlvchange\fP command and a short form of \fB\-\-commandprofile\fP for any other command (with the exception of \fBlvmconfig\fP command where the \fB\-\-profile\fP has special meaning, see \fBlvmconfig\fP(8) for more information). . .HP .BR \-\-config .IR ConfigurationString .br Uses the ConfigurationString as direct string representation of the configuration to override the existing configuration. The ConfigurationString is of exactly the same format as used in any LVM configuration file. See \fBlvm.conf\fP(5) for more information about \fBdirect config override on command line\fP and the way it fits with other LVM configuration methods. . .SH VALID NAMES . The valid characters for VG and LV names are: .BR a - z .BR A - Z .BR 0 - 9 .BR "+ _ . -" .P VG names cannot begin with a hyphen. The name of a new LV also cannot begin with a hyphen. However, if the configuration setting \fBmetadata/record_lvs_history\fP is enabled then an LV name with a hyphen as a prefix indicates that, although the LV was removed, it is still being tracked because it forms part of the history of at least one LV that is still present. This helps to record the ancestry of thin snapshots even after some links in the chain have been removed. A reference to the historical LV 'lvol1' in VG 'vg00' would be 'vg00/-lvol1' or just '-lvol1' if the VG is already set. (The latter form must be preceded by '--' to terminate command line option processing before reaching this argument.) .P 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 \fI/dev/\fP 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: \fR'_cdata', '_cmeta', '_corig', '_mlog', '_mimage', '_pmspare', \fR'_rimage', '_rmeta', '_tdata', '_tmeta' or '_vorigin'. A directory bearing the name of each Volume Group is created under \fI/dev\fP 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 \fI/dev/mapper\fP 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 \fI/dev/VolumeGroupName/LogicalVolumeName\fP 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 \fBdmsetup splitname\fP to separate out the original VG, LV and internal layer names. .P . .SH UNIQUE NAMES . VG names should be unique. vgcreate will produce an error if the specified VG name matches an existing VG name. However, there are cases where different VGs with the same name can appear to LVM, e.g. after moving disks or changing filters. When VGs with the same name exist, commands operating on all VGs will include all of the VGs with the same name. If the ambiguous VG name is specified on the command line, the command will produce an error. The error states that multiple VGs exist with the specified name. To process one of the VGs specifically, the --select option should be used with the UUID of the intended VG: '--select vg_uuid='. An exception is if all but one of the VGs with the shared name is foreign (see .BR lvmsystemid (7).) In this case, the one VG that is not foreign is assumed to be the intended VG and is processed. .P LV names are unique within a VG. The name of an historical LV cannot be reused until the historical LV has itself been removed or renamed. . .SH ALLOCATION . 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 (\fBcontiguous\fP) and ending with the allocation policy specified using \fB\-\-alloc\fP 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: \fBContiguous\fP 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. \fBCling\fP 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 \fBallocation/cling_tag_list\fP 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. \fBNormal\fP 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 .B 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 .B 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 \fBlvcreate\fP(8) and \fBlvconvert\fP(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 \fB\-vvvv\fP to a command. . .SH LOGICAL VOLUME TYPES . Some logical volume types are simple to create and can be done with a single \fBlvcreate\fP(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 (\fBlvmcache\fP(7)) and thin provisioning (\fBlvmthin\fP(7)) types are examples of this. . .SH SELECTION CRITERIA . The selection criteria are a set of \fBstatements\fP combined by \fBlogical and grouping operators\fP. The \fBstatement\fP consists of \fBcolumn\fP name for which a set of valid \fBvalues\fP is defined using \fBcomparison operators\fP. For complete list of column names (fields) that can be used in selection, see the output of \fB -S help\fP. .P .SS Comparison operators \fR(cmp_op) .sp .PD 0 .TP .B =~ Matching regular expression. .TP .B !~ Not matching regular expression. .TP .B = Equal to. .TP .B != Not equal to. .TP .B >= Greater than or equal to. .TP .B > Greater than .TP .B <= Less than or equal to. .TP .B < Less than. .PD .P .SS Binary logical operators \fR(cmp_log) .sp .PD 0 .TP .B && All fields must match .TP .B , All fields must match .TP .B || At least one field must match .TP .B # At least one field must match .PD .P .SS Unary logical operators .TP .B ! Logical negation .P .SS Grouping operators .sp .PD 0 .TP .B ( Left parenthesis .TP .B ) Right parenthesis .TP .B [ List start .TP .B ] List end .TP .B { List subset start .TP .B } List subset end .PD .SS Informal grammar specification .HP .BR STATEMENT " = " column " cmp_op " VALUE " | " \%STATEMENT " log_op " STATEMENT " | " \%(STATEMENT) " | " \%!(STATEMENT) .br .HP .BR VALUE " = " [VALUE " log_op " VALUE] .br For list-based types: string list. Matches strictly. The log_op must always be of one type within the whole list value. .HP .BR VALUE " = " {VALUE " log_op " VALUE} .br For list-based types: string list. Matches a subset. The log_op must always be of one type within the whole list value. .HP .BR VALUE " = " value .br For scalar types: number (integer), size (floating point number with size unit suffix), percent (floating point number with or without % suffix), string. . .SH DIAGNOSTICS . All tools return a status code of zero on success or non-zero on failure. . .SH ENVIRONMENT VARIABLES . .TP .B HOME Directory containing \fI.lvm_history\fP if the internal readline shell is invoked. .TP .B LVM_COMMAND_PROFILE Name of default command profile to use for LVM commands. This profile is overriden by direct use of \fB\-\-commandprofile\fP command line option. .TP .B LVM_SYSTEM_DIR Directory containing \fBlvm.conf\fP(5) and other LVM system files. Defaults to "\fI#DEFAULT_SYS_DIR#\fP". .TP .B LVM_SUPPRESS_FD_WARNINGS Suppress warnings about unexpected file descriptors passed into LVM. .TP .B LVM_VG_NAME The Volume Group name that is assumed for any reference to a Logical Volume that doesn't specify a path. Not set by default. .TP .B LVM_LVMETAD_PIDFILE Path to the file that stores the lvmetad process ID. .TP .B LVM_LVMETAD_SOCKET Path to the socket used to communicate with lvmetad. .TP .B LVM_LVMPOLLD_PIDFILE Path to the file that stores the lvmpolld process ID. .TP .B LVM_LVMPOLLD_SOCKET Path to the socket used to communicate with lvmpolld.. .TP .B LVM_LOG_FILE_EPOCH A string of up to 32 letters appended to the log filename and followed by the process ID and a timestamp. When set, each process logs to a separate file. .TP .B LVM_EXPECTED_EXIT_STATUS The status anticipated when the process exits. Use ">N" to match any status greater than N. If the actual exit status matches and a log file got produced, it is deleted. .B LVM_LOG_FILE_EPOCH and .B LVM_EXPECTED_EXIT_STATUS together allow automated test scripts to discard uninteresting log data. .TP .B LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES Used to suppress warning messages when the configured locking is known to be unavailable. .TP .B DM_ABORT_ON_INTERNAL_ERRORS Abort processing if the code detects a non-fatal internal error. .TP .B DM_DISABLE_UDEV Avoid interaction with udev. LVM will manage the relevant nodes in /dev directly. . .SH FILES . .I #DEFAULT_SYS_DIR#/lvm.conf .br .I $HOME/.lvm_history . .SH SEE ALSO . .nh .BR lvm.conf (5), .BR lvmcache (7), .BR lvmthin (7), .BR clvmd (8), .BR dmsetup (8), .BR lvchange (8), .BR lvcreate (8), .BR lvdisplay (8), .BR lvextend (8), .BR lvmchange (8), .BR lvmconfig (8), .BR lvmdiskscan (8), .BR lvreduce (8), .BR lvremove (8), .BR lvrename (8), .BR lvresize (8), .BR lvs (8), .BR lvscan (8), .BR pvchange (8), .BR pvck (8), .BR pvcreate (8), .BR pvdisplay (8), .BR pvmove (8), .BR pvremove (8), .BR pvs (8), .BR pvscan (8), .BR vgcfgbackup (8), .BR vgchange (8), .BR vgck (8), .BR vgconvert (8), .BR vgcreate (8), .BR vgdisplay (8), .BR vgextend (8), .BR vgimport (8), .BR vgimportclone (8), .BR vgmerge (8), .BR vgmknodes (8), .BR vgreduce (8), .BR vgremove (8), .BR vgrename (8), .BR vgs (8), .BR vgscan (8), .BR vgsplit (8), .BR readline (3)