Inspecting 30
The manual calls pvs, vgs and lvs the preferred alternative to the display commands: the same information and more, in a compact and configurable format.
| Command | What it does |
|---|---|
pvs | Report physical volumesOne line per PV with its VG, format, attributes, size and free space. |
pvs -a | Include devices that are not PVsAlso lists devices that LVM has not initialised. |
pvs --segments | Report physical volume segmentsAdds one line per segment with its start extent and length. |
pvs --segments -o+lv_name,seg_start_pe,segtype | Map physical extents to LVsShows which logical volume and segment type sits on each extent range of a PV. |
pvdisplay | Show physical volume detailsVerbose multi-line form; the manual calls pvs the preferred, more compact alternative. |
pvdisplay -m | Show extent mapping of a PVAdds the map from each physical extent range to the LV and logical extents stored there. |
vgs | Report volume groupsOne line per VG with PV, LV and snapshot counts, attributes, size and free space. |
vgs -o systemid VG | Show a volume group's system IDTells you whether a system ID has been stored on that VG. |
vgdisplay | Show volume group detailsVerbose form that also covers the associated PVs and LVs; vgs is the preferred compact report. |
vgdisplay --partial --verbose | List missing physical volumesGives UUID and size of every PV that has gone missing, the input for replacing it. |
lvs | Report logical volumesOne line per LV with its VG, attributes, size, pool, origin and sync percentage. |
lvs -a | Include hidden logical volumesAdds internal component LVs, whose names are printed in square brackets. |
lvs --segments | Report logical volume segmentsOne line per segment with stripe count, segment type and segment size. |
lvs -o lv_name,lv_size | Choose the report columnsReplaces the configured field list with the named fields for this run. |
lvs -o+lv_layout | Add a column to the reportA plus sign appends the field to the default columns instead of replacing them. |
lvs -o-origin | Remove a column from the reportA minus sign drops the named field from the default columns. |
lvs -o help | List available report fieldsPrints every field name the report accepts; pvs and vgs take the same option. |
lvs -S help | Show selection syntax helpLists the fields usable in -S selection criteria, each with its type. |
lvs -o name,size,snap_percent -S 'size=8m' | Filter rows by a field valueKeeps only LVs that match; sizes are read as MiB when no unit is given. |
lvs --units b --nosuffix | Print sizes as plain bytesOverrides the human-readable default: byte counts with no unit suffix. |
lvs --noheadings | Omit the heading lineLeaves only the data rows, without the column titles. |
lvs -o lv_name,lv_size --reportformat json | Report in JSONSwitches from the basic table to JSON output; json_std is the other structured format. |
lvdisplay | Show logical volume detailsVerbose form with size, read/write status and snapshot information; lvs is the preferred report. |
lvdisplay -m | Show extent mapping of an LVAdds the map from logical extents to the PVs and physical extents that hold them. |
lvdisplay vg0 | Show every LV in a volume groupNaming a VG where LVs are expected applies the command to all of its LVs. |
pvscan | List physical volumesRead-only listing when run without --cache; with that option it updates runtime LVM state instead. |
vgscan | Scan for volume groupsSearches every supported block device on the system for VGs. |
lvscan | List all logical volumesOne line per LV: active or not, snapshot or origin, device size and allocation policy. |
lvmdiskscan | Scan devices for LVM labelsDeprecated: the manual says to use pvs instead. |
lvm fullreport | Report all layers at onceGathers PV, VG, LV and segment data per VG under one lock, so the figures agree with each other. |
Physical volumes 8
| Command | What it does |
|---|---|
pvcreate /dev/sdc4 /dev/sde | Initialise devices as PVsLabels one partition and one whole disk so that both can join a volume group. |
pvcreate --dataalignmentoffset 7s /dev/sdb | Shift the start of the data areaFor 4 KiB-sector drives that compensate for Windows partitioning, so LVM data stays aligned. |
pvresize /dev/sda1 | Grow a PV to fill its deviceRun it once the partition has been enlarged so LVM sees the added space. |
pvresize --setphysicalvolumesize 40G /dev/sda1 | Shrink a PV to a set sizeDo this before shrinking the partition, with a size that fits the new partition. |
pvchange -x n /dev/sdk1 | Stop new allocations on a PVFor a disk with errors, or one that will be emptied and removed; y allows allocation again. |
pvck PV | Check PV metadata |
pvck --dump headers PV | Print on-disk LVM headersPrints label, PV and metadata-area headers with warnings for wrong values; other dump targets print the metadata text. |
pvck --labelsector 204800 /dev/sda | Scan a sector for a labelFor a lost partition table: 204800 is the 512-byte sector at 100 MiB. |
Volume groups 16
| Command | What it does |
|---|---|
vgcreate myvg /dev/sdk1 /dev/sdl1 | Create a volume groupBuilds a VG from two PVs; the extent size stays at its default unless -s is given. |
vgcreate -s Size VG_new PV | Set the physical extent sizeChoose it at creation: afterwards it is hard to change without recreating the VG. |
vgextend vg00 /dev/sda4 /dev/sdn1 | Add PVs to a volume groupDevices not yet prepared with pvcreate are initialised by vgextend itself. |
vgrename vg02 myvg | Rename a volume group |
vgrename Zvlifi-Ep3t-e0Ng-U42h-o0ye-KHu1-nl7Ns4 myvg | Rename a VG chosen by UUIDThe way out when two visible VGs carry the same name, e.g. after moving disks between machines. |
vgchange -l 128 vg00 | Set the maximum LV countChanges the limit on logical volumes; the example VG is inactive. |
vgmerge -v databases vg00 | Merge two volume groupsFolds the inactive vg00 into databases and prints verbose progress. |
vgsplit VG VG PV | Split PVs off into another VGMoves whole PVs from the first VG to the second, creating the destination when it does not exist. |
vgsplit -n LV VG VG | Split off the PVs under an LVMoves the PVs that hold the named LV; an LV cannot be divided between the two groups. |
vgexport VG | Export a volume groupPuts the VG offline until it is imported, e.g. before moving its disks; every LV in it must be inactive. |
vgexport -a | Export all volume groups |
vgimport VG | Import an exported volume groupMakes the VG usable again and sets its system ID to that of the importing host. |
vgimport -a | Import all exported VGs |
vgimportclone --basevgname vg00_snap /dev/sdc /dev/sdd | Import and rename a cloned VGFor hardware snapshots of PVs: the copy gets a new VG name and new UUIDs so it can coexist with the original. |
vgck | Check volume group metadata |
vgck --updatemetadata VG | Rewrite VG metadataCorrects problems such as an old metadata copy on a PV that was missing and has come back. |
Creating logical volumes 8
| Command | What it does |
|---|---|
lvcreate -L Size VG | Create a linear LVThe basic form; sizes are in MiB unless a unit follows, and without -n the LV is named lvol#. |
lvcreate -L 64m -n mylv vg00 /dev/sda:0-7 /dev/sdb:0-7 | Create an LV on chosen extentsPlaces a named 64 MiB linear volume on extents 0-7 of two PVs. |
lvcreate -l 100%FREE -n mylv vg00 | Take all unallocated spaceThe -l option counts extents or takes a percentage; %FREE is the space still unallocated in the VG. |
lvcreate -i 3 -I 8 -L 100m vg00 | Create a striped LVThree stripes with an 8 KiB stripe size; with no -n, lvcreate picks the name. |
lvcreate --vdo --size 10G --name vdo0 vg00/vpool1 | Create a VDO volumeMakes the VDO LV vdo0 together with its 10 GiB VDO pool vpool1. |
lvrename /dev/vg02/lvold vg02/lvnew | Rename a logical volume |
lvrename vg02 lvold lvnew | Rename an LV, VG named firstAlternate syntax: the VG once, then the old and the new LV name. |
lvchange -pr vg00/lvol1 | Make an LV read-onlyChanges the permission attribute; rw makes the volume writable again. |
Resizing 10
Wherever a row uses -L with a size, the manual allows -l with an extent count or a percentage such as 50%VG or 100%FREE instead.
| Command | What it does |
|---|---|
lvextend -L +54 vg01/lvol10 /dev/sdk3 | Grow an LV by a sizeAdds 54 MiB, allocated from the PV named last. |
lvextend vg01/lvol01 /dev/sdk3 | Grow an LV onto a whole PVWith no size given the LV takes all free space on that PV, the same as -l +100%PVS. |
lvextend -L+16m vg01/lvol01 /dev/sda:8-9 /dev/sdb:8-9 | Grow an LV on chosen extentsAdds 16 MiB taken from the listed extent ranges of two PVs. |
lvextend -l+100%FREE -r vg01/lvol01 | Use all free space, resize filesystemTakes everything left in the VG and has fsadm grow the file system in the same run. |
lvextend --usepolicies LV | Extend by the configured policyExtends as the policy set in lvm.conf or a profile dictates; for snapshots and thin pools. |
lvreduce -l -3 vg00/lvol1 | Shrink an LV by extentsRemoves three logical extents; data in the removed area is lost, so shrink the file system first. |
lvreduce -r -L Size LV | Shrink LV and filesystem togetherWith -r, fsadm resizes the file system in step with the LV; a minus prefix makes the size relative. |
lvresize -L+16M vg1/lv1 /dev/sda:0-1 /dev/sdb:0-1 | Resize an LV on chosen extentslvresize works like lvextend and lvreduce in one command; here it adds 16 MB from two extent ranges. |
lvresize -l50%VG vg1/lv1 | Size an LV by VG percentageSets the LV to half of the volume group's total size. |
lvresize -r -L Size LV | Resize LV and filesystem togetherTakes a + or - prefix for relative sizes, and -r hands the file system to fsadm. |
Snapshots 6
| Command | What it does |
|---|---|
lvcreate --snapshot --size 100m --name mysnap vg00/mylv | Create a COW snapshotA frozen image of vg00/mylv, usable for backups while the origin stays in use. |
lvcreate -s -l 20%ORIGIN -n mysnap vg00/mylv | Size a snapshot by origin shareRoom to overwrite a fifth of the origin; 100%ORIGIN would cover the whole volume. |
lvcreate --snapshot --virtualsize 1t --size 100m --name mylv vg00 | Create a sparse LVPresents 1 TiB to its users while allocating a little less than 100 MiB. |
lvconvert --mergesnapshot LV | Merge a snapshot into its originStarts at once if origin and snapshot are closed; otherwise it waits for the next activation. |
lvconvert --splitsnapshot LV | Detach a snapshot from its originThe split-off LV holds only the chunks that differ, plus the metadata describing them. |
lvconvert --type snapshot LV LV | Reattach a split snapshotReverses a split: the first argument is the former origin, the second the former snapshot. |
Thin provisioning 25
| Command | What it does |
|---|---|
lvcreate --type thin-pool -n pool0 -L 500M vg | Create a thin poolThe size applies to the pool's data LV; the metadata LV is sized automatically. |
lvcreate --type thin -n vol -V 1G --thinpool pool0 vg | Create a thin LV in a poolThe virtual size may be larger than the physical space the pool has. |
lvcreate --type thin -n vol -V 1G --thinpool pool0 -L500M vg | Create pool and thin LV togetherOne command: first a 500 MiB pool named pool0, then a 1 GiB thin LV inside it. |
lvcreate -T -V 1T --size 256G --name mythin vg00/tpool0 | Create a thin LV with -TShort form of the combined command: a 256 GiB pool tpool0 and a 1 TiB thin volume. |
lvcreate --type thin-pool -n pool0 -L5G --pooldatavdo y vg | Create a thin pool on VDOData of every thin LV in the pool is compressed and deduplicated by dm-vdo. |
lvconvert --type thin-pool --poolmetadata pool0_meta vg/pool0 | Combine two LVs into a thin poolErases both LVs; the pool keeps the name and size of the data LV. |
lvconvert --type thin vg/vol | Convert a thick LV to thinBuilds a new pool around the existing data; the conversion cannot be reversed. |
lvcreate --snapshot -n snap1 vg/vol | Snapshot a thin LVNo size is given: adding one would create a COW snapshot instead of a thin one. |
lvcreate --snapshot -n snap --thinpool pool0 vg/vol | Thin snapshot of an external LVThe origin must be read-only and inactive; writes to the snapshot land in the named pool. |
lvconvert --merge vg/snap | Merge a thin snapshot backThe origin takes the snapshot's content and the snapshot disappears; delayed while the LVs are open. |
lvchange -ay -K VG/SnapLV | Activate a thin snapshotThin snapshots carry the skip-activation property, so a plain -ay passes over them unless -K is added. |
lvchange --setactivationskip n VG/SnapLV | Clear the skip-activation propertyAfterwards -K is no longer needed to activate that thin LV. |
lvextend -L+100M vg/pool0 | Grow a thin poolExtends the pool's data LV; the metadata LV grows too when the new size calls for it. |
lvextend -L+100M --poolmetadatasize 8M vg/pool0 | Grow pool data and metadataRequests an explicit metadata size while the data LV is extended. |
lvextend --poolmetadatasize MetadataSize VG/ThinPool | Grow only the pool metadata |
lvextend --use-policies VG/ThinPool | Run the autoextend checkThe command dmeventd issues: it compares usage with the autoextend threshold and extends data or metadata if needed. |
lvs -o data_percent VG/ThinPool | Show thin pool data usageExtend the pool before this figure, or the metadata one, reaches 100%. |
lvs -o metadata_percent VG/ThinPool | Show thin pool metadata usageShare of the metadata LV that the dm_thin_pool module currently uses. |
lvs -o+seg_monitor VG/ThinPool | Check that a pool is monitoredAutomatic extension only works while dmeventd monitors the pool. |
lvchange --monitor y VG/ThinPool | Start monitoring a thin pool |
lvs -o whenfull VG/ThinPool | Show the when-full behaviourReads error or queue: what a pool that has run out of space does with writes. |
lvchange --errorwhenfull y VG/ThinPool | Fail writes when the pool is fullA full pool then returns write errors immediately; n queues the writes for a period instead. |
lvchange --discards nopassdown VG/ThinPool | Change the discards modeDiscards are processed in the pool but not passed to the underlying device; passdown is the default. |
lvchange -Z n VG/ThinPool | Turn off zeroing in a poolNewly provisioned chunks are no longer overwritten with zeros; zeroing large chunks reduces performance. |
lvconvert --repair VG/ThinPool | Repair thin pool metadataNeeded when thin_check finds damage and the pool will not activate; not always successful. |
RAID and cache 34
| Command | What it does |
|---|---|
lvcreate --type raid1 -m1 -L 500m -n mylv vg00 | Create a RAID1 LVTwo images on two devices, each of which also carries RAID metadata. |
lvcreate --type raid5 -L 5G -i 3 -I 64 -n mylv vg00 | Create a RAID5 LVThree data stripes of 64 KiB on four devices, one of them for parity. |
lvcreate --type raid10 -L 5G -i 2 -m 1 -n mylv vg00 | Create a RAID10 LVStriping over two mirrored pairs: -i counts stripes, -m counts images beyond the first. |
lvcreate --config allocation/raid_stripe_all_devices=1 --type raid5 -l 100%FREE -n mylv vg00 | Create RAID5 across every PVUses all free space and spans all PVs; fails when the VG has more than 8 PVs. |
lvcreate --type mirror -m1 -L 500m -n mylv vg00 | Create a mirror-type LVNeeds three devices: two for the images and one for the disk log. |
lvs -o name,segtype LV | Show an LV's RAID levelThe segment type column names the LV type, which corresponds to the RAID level. |
lvs -a -o name,segtype,devices | Show RAID sub-LVs and devicesThe -a option is needed because image and metadata sub-LVs are hidden. |
lvs -a -o name,sync_percent | Show RAID sync progressA Cpy%Sync value of 100% means synchronisation has finished. |
lvchange --syncaction check LV | Scrub a RAID LVRead-only pass that only detects inconsistent areas. |
lvchange --syncaction repair LV | Scrub and correct a RAID LVChecks every block and rewrites the bad ones so inconsistent areas match again. |
lvs -o name,raid_mismatch_count | Count scrub mismatchesRun it when scrubbing has finished to see how many inconsistent blocks turned up. |
lvs -o name,lv_health_status | Show RAID health statusReads partial when devices are missing from the LV. |
lvchange -ay --activationmode degraded LV | Activate a degraded RAID LVActivates with devices missing only when the RAID level can lose them without losing data. |
lvconvert --repair LV | Replace failed RAID devicesUse when the failed device has vanished from the system; new PVs may be listed last. |
lvconvert --replace /dev/sdb1 vg/lvol1 /dev/sdf1 | Swap a PV in a RAID LVFor a device that is still visible; repeat --replace to swap several PVs at once. |
lvchange --refresh vg/lv | Refresh a RAID LVClears transient device failures and brings the LV back to full redundancy. |
lvchange --rebuild PV LV | Rebuild data on a RAID PVFor PVs known to hold corrupt data; repeat the option to cover several PVs. |
lvconvert --raidintegrity y LV | Add integrity checksumsPuts a dm-integrity layer on each RAID image so corrupted reads are served from a good image. |
lvconvert --type raid1 --mirrors 1 vg/lvol1 | Convert linear to RAID1Adds one image to a linear volume, which makes it a two-way RAID1. |
lvconvert --type linear vg/lvol1 | Convert a mirror back to linearWorks on mirror and raid1 volumes alike. |
lvconvert --type RaidLevel LV | Change the RAID levelCalled takeover, e.g. raid5 to raid6, done to change resilience or to restripe. |
lvconvert --stripes Number LV | Change the stripe countReshapes a RAID LV to a different number of stripe images at the same RAID level. |
lvconvert --splitmirrors 1 --name lv_split vg/lvol1 | Split off a mirror imageDetaches one image of a mirror or raid1 LV as a new LV called lv_split. |
lvconvert --splitmirrors 1 --trackchanges vg/lvol1 | Split an image and track changesThe raid1 LV records what changes while the image is detached, ready for a later merge. |
lvconvert --mergemirrors vg/lvol1_rimage_1 | Merge a tracked image backReturns an image split with --trackchanges to its raid1 LV. |
lvcreate --type cache-pool -L 1G -n my_cpool vg00 /dev/fast1 | Create a cache poolBuilt on a fast device; attach it to an LV afterwards to cache that LV. |
lvcreate --type cache --cachepool my_cpool -L 100G -n mylv vg00 /dev/slow1 | Create a cached LV in one stepMakes a new origin on the slow device and joins it to a cache pool that already exists. |
lvconvert --type cache --cachepool fast vg/main | Attach a cache pool (dm-cache)Starts the dm-cache hot-spot cache on the main LV, with the fast LV as its cache pool. |
lvconvert --type cache --cachevol fast vg/main | Attach a cachevol (dm-cache)With a cachevol, cache data and metadata are kept together on the one fast LV. |
lvconvert --type writecache --cachevol fast vg/main | Attach a write cachedm-writecache speeds up writes only: data read from the main LV is not kept in the cache. |
lvs -ao+devices | Show cache LVs and their devicesWhile attached, the fast LV is hidden and carries a _cvol or _cpool suffix. |
lvs -o+cache_mode VG/LV | Show the cache modeThe mode is set with --cachemode when caching starts, or changed later on a cached LV. |
lvconvert --splitcache vg/main | Detach the cache and keep itSeparates the fast LV; the main LV returns to the type it had before caching. |
lvconvert --uncache vg/main | Detach and delete the cacheStops caching and also removes the cache pool that is no longer needed. |
Moving and removing 17
Repeating the force option as -ff makes pvremove wipe a PV that still belongs to a VG; the manual says vgreduce should normally be used instead.
| Command | What it does |
|---|---|
pvmove /dev/sdb1 | Empty a physical volumeMoves every extent that simple LVs use on this PV to free space elsewhere in the VG. |
pvmove /dev/sdb1 /dev/sdc1 | Move extents to a chosen PVWithout a destination, the normal allocation rules of the VG decide where data goes. |
pvmove -n lvol1 /dev/sdb1 /dev/sdc1 | Move one LV's extentsOnly the extents that belong to lvol1 leave the source PV. |
pvmove /dev/sdb1:1000-1999 | Move a range of extentsExtent numbers 1000 to 1999 inclusive rather than the whole device. |
pvmove /dev/sdb1:1000+1000 | Move a range by start and lengthCounting starts at 0, so this covers the 1001st to the 2000th extent. |
pvmove /dev/sdb1:1000-1999 /dev/sdc1:0-999 | Move a range to chosen extentsSource range and destination range are both named, on two PVs. |
pvmove --alloc anywhere /dev/sdb1:1000-1999 /dev/sdb1:0-999 | Move extents within one diskSource and destination on the same PV require the anywhere allocation policy. |
pvmove | Resume interrupted movesRun with no PV after a crash: unfinished moves restart from their latest checkpoint. |
pvmove -b | Move in the backgroundReturns before the move has finished and leaves the polling to a background process. |
pvmove --abort | Abort running movesMoved segments stay on the destination unless the move was started with --atomic. |
vgreduce VG PV | Remove an unused PVOnly unused PVs can go, so empty the device with pvmove first. |
vgreduce -a VG | Remove all empty PVs |
vgreduce --removemissing VG | Drop PVs that are missingWorks when no LVs are allocated on the lost PVs; with --force it also removes partial LVs. |
pvremove PV | Wipe the LVM label from a deviceLVM then no longer sees the device as a PV; it cannot be done while an active LV uses it. |
lvremove -f vg00/lvol1 | Remove an LV without promptingA single -f skips the confirmation asked for an active LV. |
lvremove vg00 | Remove every LV in a VGRemoving an origin LV also removes all snapshots that depend on it. |
vgremove VG | Remove a volume groupPrompts for confirmation if the VG still contains LVs. |
Activation and metadata backup 14
vgcfgbackup saves VG metadata only: it does not back up the data in LVs, and it does not back up thin pool metadata.
| Command | What it does |
|---|---|
vgchange -a y | Activate all LVsWith no VG named it covers every LV in every VG on the devices present. |
vgchange -a n VG | Deactivate a VG's LVsMakes the LVs unavailable and removes their block devices; required before vgexport. |
vgchange --refresh | Reload LVs with latest metadata |
lvchange -ay vg/vol | Activate one LVAn active LV is reachable through its block device and the /dev/VGName/LVName link. |
lvchange -an vg/vol | Deactivate one LVThe block device and its symbolic link are removed from the system. |
pvscan --cache -a ay | Autoactivate a complete VGNotes the PV as online and activates its VG once all of its PVs are present. |
vgscan --mknodes | Scan and repair device nodesAlso checks the special files in /dev for active LVs, adding missing ones and deleting unused ones. |
vgmknodes | Recreate LV device filesRarely needed on a system whose components work together correctly. |
vgcfgbackup | Back up VG metadataWith no VG named, writes one file per VG under /etc/lvm/backup; LV contents are not included. |
vgcfgbackup -f FILE VG | Back up metadata to a named fileFor several VGs the name acts as a template in which %s becomes the VG name. |
vgcfgrestore VG | Restore VG metadataUses the most recent backup file when none is named. |
vgcfgrestore -f FILE VG | Restore from a chosen backup fileWrites the VG metadata onto the devices named in that backup file. |
vgcfgrestore -l VG | List metadata backups of a VGShows the backup and archive files available for that VG. |
pvcreate --restorefile FILENAME --uuid UUID | Recreate a lost PV with its UUIDInitialises a same-size replacement under the missing PV's UUID, before vgcfgrestore brings the VG metadata back. |
Configuration and diagnostics 23
| Command | What it does |
|---|---|
lvm version | Show version information |
lvm help | Show the help text |
lvm | Start the LVM shellWith no arguments lvm opens a readline prompt with history and command completion. |
lastlog | Show the last command's logTyped at the lvm> prompt of the shell; command log reporting has to be switched on. |
lvm segtypes | List segment typesNames the LV segment types this build recognises. |
lvm formats | List metadata formats |
lvm devtypes | List block device typesShows the built-in device types that LVM recognises. |
lvm tags | List host tagsPrints the tags that are defined on this host. |
lvm systemid | Show the host's system IDTells you whether a system ID is configured on the local machine. |
lvmconfig | Print the LVM configurationFormatted output of the configuration tree, built from lvm.conf and any --config settings. |
lvmconfig --type default --withcomments | Print defaults with commentsThe comments describe each setting, including the individual cache settings. |
lvmconfig --type default activation/activation_mode | Print one default settingName a section/setting path to limit the output to that value. |
lvmdevices | List the devices filePrints the entries of /etc/lvm/devices/system.devices, the list of devices LVM commands will use. |
lvmdevices --adddev DEVICE | Add a device to the devices fileThe device is named by its path; --addpvid takes a PVID instead. |
lvmdevices --deldev DEVICE | Remove a device from the fileLVM no longer sees or uses a device once its entry is gone. |
lvmdevices --check | Check the devices fileReports whether its content needs updating, without changing anything. |
lvmdevices --update | Update the devices fileRewrites fields that are out of date, such as the last known device name. |
vgimportdevices -a | Add the PVs of all visible VGsFills the devices file from every volume group that can be seen. |
vgimportdevices VG | Add the PVs of one VG |
lvmdump | Collect a diagnostic tarballGathers dmsetup info, the process table, recent system log entries, /etc/lvm and device listings. |
lvmdump -m | Include on-disk metadataAdds a 1:1 copy of the metadata area of every visible PV, which can enlarge the dump a lot. |
lvmdump -a | Collect the advanced setAdds debug output of vgscan and pvscan and lists of all VGs, PVs and LVs; may hang if lvm is hung. |
lvmdump -d DIRECTORY | Dump into a directoryLeaves the raw dump tree in that directory rather than one compressed tarball. |
No row on this page matches that filter.
Notes
From disk to filesystem
pvcreate /dev/sdc4 /dev/sde initialises a partition and a whole disk for LVM, vgcreate myvg /dev/sdk1 /dev/sdl1 makes a volume group from two PVs, and lvcreate -L Size VG carves a logical volume out of the group's free extents — -L for a fixed size, lvcreate -l 100%FREE -n mylv vg00 for the rest. Format and mount the resulting /dev/vgname/lvname like any block device. pvs, vgs and lvs are the one-line reports for each layer; pvdisplay, vgdisplay and lvdisplay are the verbose forms, and the manual calls the short reports the preferred alternative.
Growing safely, shrinking carefully
Growing is safe: vgextend vg00 /dev/sda4 /dev/sdn1 adds new PVs to the group, lvextend -l+100%FREE -r vg01/lvol01 grows the LV (with -r to resize the filesystem in the same step), and pvresize /dev/sda1 picks up a partition that was enlarged underneath. Shrinking is the operation that destroys data when done in the wrong order: data in the reduced area is lost, so the filesystem must be resized before lvreduce -l -3 vg00/lvol1 runs. lvreduce -r -L Size LV and lvresize -r -L Size LV have fsadm resize the filesystem together with the LV. vgreduce VG PV removes only unused PVs from a group, so pvmove /dev/sdb1 has to migrate the extents elsewhere first.
Snapshots, recovery and cleanup
lvcreate --snapshot --size 100m --name mysnap vg00/mylv makes a copy-on-write snapshot of an LV — a frozen image for backups or before a risky upgrade — and lvconvert --mergesnapshot LV merges it back into its origin. vgcfgbackup and vgcfgrestore VG save and restore the VG metadata, not the data inside the LVs; by default each VG is backed up to a file under /etc/lvm/backup. When a PV is lost, pvcreate --restorefile FILENAME --uuid UUID recreates it with the old UUID before the metadata is restored. vgexport VG and vgimport VG move a group between hosts cleanly, and vgrename vg02 myvg and lvrename vg02 lvold lvnew fix names without touching data. lvremove vg00, vgremove VG and pvremove PV tear the layers down in that order. lvmdiskscan is deprecated; the manual says to use pvs instead.
Questions
How do I grow a logical volume and its filesystem in one command?
Add -r to lvextend: lvextend -l+100%FREE -r vg01/lvol01 takes all free space in the VG and has fsadm resize the filesystem together with the LV. lvresize -r -L Size LV does the same with an explicit size.
How do I shrink a logical volume safely?
Use lvresize -r -L Size LV or lvreduce -r -L Size LV; the -r option resizes the filesystem together with the LV through fsadm. Without -r, shrink the filesystem yourself first: lvreduce discards the data in the extents it removes.
How do I remove a disk from a volume group?
pvmove /dev/sdb1 migrates its extents to other PVs, then vgreduce VG PV takes the emptied PV out of the group and pvremove PV wipes its LVM label.
What is the difference between pvs and pvdisplay?
pvs prints one line per PV in configurable columns; pvdisplay prints a detailed block per PV. The manual calls pvs the preferred alternative, and the same pairing exists for vgs and vgdisplay, lvs and lvdisplay.
Sources and checks
- lvm(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Built-in lvm commands, the lvm shell and argument conventions
- pvcreate(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Initialising physical volumes
- pvs(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org pvs usage
- pvdisplay(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org pvdisplay usage and options
- pvmove(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Moving extents between physical volumes
- pvremove(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Removing physical volumes
43 more source pages
- pvresize(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Resizing physical volumes
- pvscan(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org pvscan usage
- pvchange(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Changing physical volume attributes
- pvck(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Checking and dumping PV metadata
- vgcreate(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Creating volume groups
- vgs(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org vgs usage
- vgdisplay(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org vgdisplay usage
- vgextend(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Adding PVs to a volume group
- vgreduce(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Removing PVs from a volume group
- vgremove(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Removing volume groups
- vgrename(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Renaming volume groups
- vgchange(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Activation and volume group attributes
- vgexport(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Exporting volume groups
- vgimport(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Importing volume groups
- vgcfgbackup(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Backing up VG metadata
- vgcfgrestore(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Restoring VG metadata and replacing lost PVs
- vgscan(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org vgscan usage
- vgck(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Checking VG metadata
- vgmerge(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Merging volume groups
- vgsplit(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Splitting volume groups
- vgimportclone(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Importing cloned volume groups
- vgmknodes(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org vgmknodes usage
- lvcreate(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Creating linear, striped, snapshot, thin, RAID, cache and VDO volumes
- lvs(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org lvs usage
- lvdisplay(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org lvdisplay usage and options
- lvextend(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Extending logical volumes
- lvreduce(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Reducing logical volumes
- lvresize(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Resizing logical volumes
- lvremove(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Removing logical volumes
- lvrename(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Renaming logical volumes
- lvchange(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Changing logical volume attributes
- lvconvert(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Converting between LV types, snapshots, mirrors and RAID
- lvscan(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org lvscan usage
- lvmdiskscan(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org lvmdiskscan usage and deprecation
- lvmconfig(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org lvmconfig usage
- lvmdevices(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org The devices file: lvmdevices and vgimportdevices
- lvmdump(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org lvmdump options
- lvm-fullreport(8) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org lvm fullreport usage
- lvmthin(7) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Thin pools, thin volumes and thin snapshots
- lvmraid(7) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org RAID levels, scrubbing, repair and takeover
- lvmcache(7) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org dm-cache and dm-writecache
- lvmsystemid(7) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org System ID commands
- lvmreport(7) manual page, LVM tools 2.03.42(2)-git (2026-05-15), man7.org Report options: fields, selection, units and output formats
Every row on this page was matched to a line in the documentation above on . A binding that could not be found there is not listed.
22 rows from the earlier version of this page were removed in that check: duplicates, and bindings the documentation does not list or lists differently.
Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.