<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.outlandsmud.com/wiki/index.php?action=history&amp;feed=atom&amp;title=LVM_Cheat_Sheet</id>
	<title>LVM Cheat Sheet - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.outlandsmud.com/wiki/index.php?action=history&amp;feed=atom&amp;title=LVM_Cheat_Sheet"/>
	<link rel="alternate" type="text/html" href="http://www.outlandsmud.com/wiki/index.php?title=LVM_Cheat_Sheet&amp;action=history"/>
	<updated>2026-05-18T05:35:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>http://www.outlandsmud.com/wiki/index.php?title=LVM_Cheat_Sheet&amp;diff=575&amp;oldid=prev</id>
		<title>Michael Kohler: Created page with &quot;Logical Volume Manager (LVM)  This is a quick and dirty cheat sheet on LVM using Linux, I have highlighted many of the common attributes for each command however this is not a...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.outlandsmud.com/wiki/index.php?title=LVM_Cheat_Sheet&amp;diff=575&amp;oldid=prev"/>
		<updated>2014-09-30T13:19:34Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Logical Volume Manager (LVM)  This is a quick and dirty cheat sheet on LVM using Linux, I have highlighted many of the common attributes for each command however this is not a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Logical Volume Manager (LVM)&lt;br /&gt;
&lt;br /&gt;
This is a quick and dirty cheat sheet on LVM using Linux, I have highlighted many of the common attributes for each command however this is not an extensive list, make sure you look up the command.&lt;br /&gt;
&lt;br /&gt;
With the pvs, vgs and lvs commands, the number of verboses added the more verbose information for example pvs -vvvvv&lt;br /&gt;
Directory and Files&lt;br /&gt;
Directories and Files 	## Directories&lt;br /&gt;
/etc/lvm                    - default lvm directory location&lt;br /&gt;
/etc/lvm/backup         - where the automatic backups go&lt;br /&gt;
/etc/lvm/cache          - persistent filter cache&lt;br /&gt;
/etc/lvm/archive        - where automatic archives go after a volume group change&lt;br /&gt;
/var/lock/lvm             - lock files to prevent metadata corruption&lt;br /&gt;
&lt;br /&gt;
# Files&lt;br /&gt;
/etc/lvm/lvm.conf       - main lvm configuration file&lt;br /&gt;
$HOME/.lvm               - lvm history&lt;br /&gt;
Tools&lt;br /&gt;
diagnostic 	lvmdump&lt;br /&gt;
lvmdump -d &amp;lt;dir&amp;gt;&lt;br /&gt;
dmsetup [info|ls|status]&lt;br /&gt;
&lt;br /&gt;
Note: by default the lvmdump command creates a tar ball&lt;br /&gt;
Physical Volumes&lt;br /&gt;
display 	&lt;br /&gt;
&lt;br /&gt;
pvdisplay -v&lt;br /&gt;
pvs -v&lt;br /&gt;
pvs -a&lt;br /&gt;
pvs --segments (see the disk segments used)&lt;br /&gt;
&lt;br /&gt;
pvs attributes are:&lt;br /&gt;
1. (a)llocatable&lt;br /&gt;
2. e(x)ported&lt;br /&gt;
scanning 	pvscan -v&lt;br /&gt;
&lt;br /&gt;
Note: scans for disks for non-LVM and LVM disks&lt;br /&gt;
adding 	pvcreate /dev/sdb1&lt;br /&gt;
&lt;br /&gt;
## Create physical volume with specific UUID, used to recover volume groups (see miscellaneous section)&lt;br /&gt;
pvcreate --uuid &amp;lt;UUID&amp;gt; /dev/sdb1&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-M2 create a LVM2 physical volume&lt;br /&gt;
removing 	pvremove /dev/sdb1&lt;br /&gt;
checking 	pvck -v /dev/sdb1&lt;br /&gt;
&lt;br /&gt;
Note: check the consistency of the LVM metadata&lt;br /&gt;
change physical attributes 	&lt;br /&gt;
&lt;br /&gt;
## do not allow allocation of extents on this drive, however the partition must be in a vg otherwise you get an error&lt;br /&gt;
pvchange -x n /dev/sdb1&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
--addtag add a tag&lt;br /&gt;
-x allowed to allocate extents&lt;br /&gt;
-u change the uuid&lt;br /&gt;
moving 	pvmove -v /dev/sdb2 /dev/sdb3&lt;br /&gt;
&lt;br /&gt;
Note: moves any used extents from this volume to another volume, in readiness to remove that volume. However you cannot use this on mirrored volumes, you must convert back to non-mirror using &amp;quot;lvconvert -m 0&amp;quot;&lt;br /&gt;
Volume Groups&lt;br /&gt;
display 	vgdisplay -v&lt;br /&gt;
vgs -v&lt;br /&gt;
vgs -a -o +devices&lt;br /&gt;
&lt;br /&gt;
vgs flags:&lt;br /&gt;
#PV - number of physical devices&lt;br /&gt;
#LV - number of configured volumes        &lt;br /&gt;
&lt;br /&gt;
vgs attributes are:&lt;br /&gt;
1. permissions (r)|(w)&lt;br /&gt;
2. resi(z)eable&lt;br /&gt;
3. e(x)ported&lt;br /&gt;
4. (p)artial&lt;br /&gt;
5. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited&lt;br /&gt;
6. (c)luster&lt;br /&gt;
scanning 	vgscan -v&lt;br /&gt;
creating 	&lt;br /&gt;
&lt;br /&gt;
vgcreate VolData00 /dev/sdb1 /dev/sdb2 /dev/sdb3&lt;br /&gt;
vgcreate VolData00 /dev/sdb[123]&lt;br /&gt;
&lt;br /&gt;
## Use 32MB extent size&lt;br /&gt;
vgcreate VolData00 -s 32 /dev/sdb1&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-l  maximum logical volumes&lt;br /&gt;
-p maximum physical volumes&lt;br /&gt;
-s physical extent size (default is 4MB)&lt;br /&gt;
-A autobackup&lt;br /&gt;
extending 	vgextend VolData00 /dev/sdb3&lt;br /&gt;
reducing 	vgreduce VolData00 /dev/sdb3&lt;br /&gt;
&lt;br /&gt;
vgreduce --removemissing --force VolData00&lt;br /&gt;
removing 	vgremove VolData00&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-f force the removal of any logical volumes&lt;br /&gt;
checking 	vgck VolData00&lt;br /&gt;
&lt;br /&gt;
Note: check the consistency of the LVM metadata&lt;br /&gt;
change volume attributes 	vgchange -a n VolData00&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-a control availability of volumes within the group&lt;br /&gt;
-l  maximum logical volumes&lt;br /&gt;
-p maximum physical volumes&lt;br /&gt;
-s physical extent size (default is 4MB)&lt;br /&gt;
-x resizable yes or no (see VG status in vxdisplay)&lt;br /&gt;
renaming 	vgrename VolData00 Data_Vol_01&lt;br /&gt;
&lt;br /&gt;
note: the volume group must not have any active logical volumes&lt;br /&gt;
converting metadata type 	vgconvert -M2 VolData00&lt;br /&gt;
&lt;br /&gt;
Note: vgconvert allows you to convert from one type of metadata format to another for example from LVM1 to LVM2, LVM2 offers bigger capacity, clustering and mirroring&lt;br /&gt;
merging 	# the old volumes group will be merged into the new volume group&lt;br /&gt;
vgmerge New_Vol_Group Old_Vol_Group&lt;br /&gt;
&lt;br /&gt;
Note: you must unmount any fielsystems and deactivate the vg that is being merged &amp;quot;vgchange -a n &amp;lt;vg&amp;gt;&amp;quot;, then you can activiate it again afterwards &amp;quot;vgchange -a y &amp;lt;vg&amp;gt;&amp;quot;, then perform a vgscan, dont forget to backup the configuration&lt;br /&gt;
spliting 	vgsplit Old_Vol_Group New_Vol_Group [physical volumes] [-n logical volume name]&lt;br /&gt;
importing 	vgimport VolData00&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-a import all exported volume groups&lt;br /&gt;
exporting 	## to see if a volume has already been export use &amp;quot;vgs&amp;quot; and look at the third attribute should be a x&lt;br /&gt;
vgexport VolData00&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-a export all inactive volume groups&lt;br /&gt;
backing up 	&lt;br /&gt;
&lt;br /&gt;
## Backup to default location (/etc/lvm/backup)&lt;br /&gt;
vgcfgbackup VolData00&lt;br /&gt;
&lt;br /&gt;
# Backup to specific location&lt;br /&gt;
vgcfgbackup -f /var/backup/VolData00_bkup VolData00&lt;br /&gt;
&lt;br /&gt;
# Backup to specific location all volume groups (notice the %s)&lt;br /&gt;
vgcfgbackup -f /var/backup/vg_backups_%s&lt;br /&gt;
&lt;br /&gt;
Note: the backup is written in plain text and are by default located in /etc/lvm/backup&lt;br /&gt;
restoring 	vgcfgrestore -f /var/backup/VolData00_bkup VolData00&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-l list backups of file&lt;br /&gt;
-f backup file&lt;br /&gt;
-M metadataype 1 or 2&lt;br /&gt;
cloning 	vgimportclone /dev/sdb1&lt;br /&gt;
&lt;br /&gt;
Note: used to import and rename duplicated volume group&lt;br /&gt;
special files 	vgmknodes VolData00&lt;br /&gt;
&lt;br /&gt;
Note: recreates volume group directory and logical volume special files in /dev&lt;br /&gt;
Logical Volumes&lt;br /&gt;
display 	&lt;br /&gt;
&lt;br /&gt;
lvdisplay -v&lt;br /&gt;
lvdisplay --maps      display mirror volumes&lt;br /&gt;
&lt;br /&gt;
lvs -v&lt;br /&gt;
lvs -a -o +devices&lt;br /&gt;
&lt;br /&gt;
## lvs commands for mirror volumes&lt;br /&gt;
lvs -a -o +devices&lt;br /&gt;
lvs -a -o +seg_pe_ranges --segments&lt;br /&gt;
&lt;br /&gt;
## Stripe size&lt;br /&gt;
lvs -v --segments&lt;br /&gt;
lvs -a -o +stripes,stripesize&lt;br /&gt;
&lt;br /&gt;
## use complex command&lt;br /&gt;
lvs -a -o +devices,stripes,stripesize,seg_pe_ranges --segments&lt;br /&gt;
&lt;br /&gt;
lvs attributes are:&lt;br /&gt;
1. volume type: (m)irrored, (M)irrored without initail sync, (o)rigin, (p)vmove, (s)napshot, invalid (S)napshot, (v)irtual, mirror (i)mage&lt;br /&gt;
                      mirror (I)mage out-of-sync, under (c)onversion&lt;br /&gt;
2. permissions: (w)rite, (r)ead-only&lt;br /&gt;
3. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited&lt;br /&gt;
4. fixed (m)inor&lt;br /&gt;
5. state: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid (S)uspended snapshot, mapped (d)evice present with-out tables,&lt;br /&gt;
             mapped device present with (i)nactive table&lt;br /&gt;
6. device (o)pen (mounted in other words)&lt;br /&gt;
scanning 	lvscan -v&lt;br /&gt;
lvmdiskscan&lt;br /&gt;
creating 	&lt;br /&gt;
&lt;br /&gt;
## plain old volume&lt;br /&gt;
lvcreate -L 10M VolData00&lt;br /&gt;
&lt;br /&gt;
## plain old volume but use extents, use 10 4MB extents (if extent size is 4MB)&lt;br /&gt;
lvcreate -l 10 VolData00&lt;br /&gt;
&lt;br /&gt;
## plain old volume but with a specific name web01&lt;br /&gt;
lvcreate -L 10M -n web01 VolData00&lt;br /&gt;
&lt;br /&gt;
## plain old volume but on a specific disk&lt;br /&gt;
lvcreate -L 10M VolData00 /dev/sdb1&lt;br /&gt;
&lt;br /&gt;
## a striped volume called lvol1 (note the captial i for the stripe size), can use -l (extents) instead of -L&lt;br /&gt;
lvcreate -i 3 -L 24M -n lvol1 vg01&lt;br /&gt;
&lt;br /&gt;
## Mirrored volume&lt;br /&gt;
lvcreate -L 10M -m1 -n data01 vg01&lt;br /&gt;
&lt;br /&gt;
## Mirrored volume without a mirror log file&lt;br /&gt;
lvcreate -L 10M -m1 --mirrorlog core -n data01 vg01&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-L size of the volume [kKmMgGtT]&lt;br /&gt;
-l number of extents&lt;br /&gt;
-C contiguous [y|n]&lt;br /&gt;
-i stripes&lt;br /&gt;
-I stripe size&lt;br /&gt;
-m mirrors&lt;br /&gt;
--mirrorlog&lt;br /&gt;
-n volume name&lt;br /&gt;
extending 	&lt;br /&gt;
&lt;br /&gt;
lvextend -L 20M /dev/VolData00/vol01&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-L size of the volume [kKmMgGtT]&lt;br /&gt;
-l number of extents&lt;br /&gt;
-C contiguous [y|n]&lt;br /&gt;
-i stripes&lt;br /&gt;
-I stripe size&lt;br /&gt;
&lt;br /&gt;
Note: you can extend a ext2/ext3 filesystem using the &amp;quot;resize2fs&amp;quot; or &amp;quot;fsadm&amp;quot; command&lt;br /&gt;
&lt;br /&gt;
fsadm resize /dev/VolData01/data01&lt;br /&gt;
resize2fs -p /dev/mapper/VolData01-data01 [size]&lt;br /&gt;
&lt;br /&gt;
The -p option displays bars of progress while extendingthe filesystem&lt;br /&gt;
reducing/resizing 	&lt;br /&gt;
&lt;br /&gt;
lvreduce -L 5M /dev/VolData00/vol01&lt;br /&gt;
lvresize -L 5M /dev/VolData00/vol01&lt;br /&gt;
&lt;br /&gt;
Note: rounding will occur when extending and reducing volumes to the next extent (4MB by default), you can use resize2fs or fsadm to shrink the filesystem&lt;br /&gt;
&lt;br /&gt;
fsadm resize /dev/VolData01/data01 [size]&lt;br /&gt;
resize2fs -p /dev/mapper/VolData01-data01 [size]&lt;br /&gt;
removing 	lvremove /dev/VolData00/vol01&lt;br /&gt;
adding a mirror to a non-mirrored volume 	&lt;br /&gt;
&lt;br /&gt;
lvconvert -m1 --mirrorlog core /dev/VolData00/vol01 /dev/sdb2&lt;br /&gt;
&lt;br /&gt;
Note: you can also use the above command to remove a unwanted log&lt;br /&gt;
removing a mirror from a mirrored volume 	&lt;br /&gt;
&lt;br /&gt;
lvconvert -m0 /dev/VolData00/vol01 /dev/sdb2&lt;br /&gt;
&lt;br /&gt;
Note: the disk in the command is the one you want to remove&lt;br /&gt;
Mirror a volume that has stripes 	lvconvert --stripes 3 -m1 --mirrorlog core /dev/VolData00/data01 /dev/sdd1 /dev/sde1 /devsdf1&lt;br /&gt;
change volume attributes 	&lt;br /&gt;
&lt;br /&gt;
lvchange -a n /dev/VolData00/vol01&lt;br /&gt;
&lt;br /&gt;
Common Attributes that you may want to use:&lt;br /&gt;
&lt;br /&gt;
-a availability&lt;br /&gt;
-C contiguous [y|n]&lt;br /&gt;
renaming 	lvrename /dev/VolData00/vol_old /dev/VolData00/vol_new&lt;br /&gt;
snapshotting 	lvcreate --size 100M --snapshot -name snap /dev/vg01/data01&lt;br /&gt;
Miscellaneous&lt;br /&gt;
Simulating a disk failure 	dd if=/dev/zero of=/dev/sdb2 count=10&lt;br /&gt;
reparing a failed mirror no LVM corruption 	## check volume, persume /dev/sdb2 has failed&lt;br /&gt;
lvs -a -o +devices&lt;br /&gt;
&lt;br /&gt;
# remove the failed disk from the volume (if not already done so) , this will convert volume into a non-mirrored volume&lt;br /&gt;
vgreduce --removemissing --force VolData00&lt;br /&gt;
&lt;br /&gt;
## replace the disk physically, remember to partion it with type 8e&lt;br /&gt;
fdisk /dev/sdb&lt;br /&gt;
........&lt;br /&gt;
&lt;br /&gt;
## add new disk to LVM&lt;br /&gt;
pvcreate /dev/sdb2&lt;br /&gt;
&lt;br /&gt;
## add the disk back into volume group&lt;br /&gt;
vgextend VolData00 /dev/sdb2&lt;br /&gt;
&lt;br /&gt;
## mirror up the volume&lt;br /&gt;
lvconvert -m1 --mirrorlog core /dev/VolData00/vol02 /dev/sdb2&lt;br /&gt;
corrupt LVM metadata without replacing drive 	# attempt to bring the volume group online&lt;br /&gt;
vgchange -a y VolData00&lt;br /&gt;
&lt;br /&gt;
# Restore the LVM configation&lt;br /&gt;
vgcfgrestore VolData00&lt;br /&gt;
&lt;br /&gt;
# attempt to bring the volume grou online&lt;br /&gt;
vgchange -a y VolData00&lt;br /&gt;
&lt;br /&gt;
# file system check&lt;br /&gt;
e2fsck /dev/VolData00/data01&lt;br /&gt;
corrupt LVM metadata but replacing the faulty disk 	&lt;br /&gt;
&lt;br /&gt;
# attempt to bring the volume group online but you get UUID conflict errors make note of the UUID number&lt;br /&gt;
vgchange -a y VolData00&lt;br /&gt;
vgchange -a n VolData00&lt;br /&gt;
&lt;br /&gt;
## sometimes it my only be a logical volume problem&lt;br /&gt;
lvchange -a y /dev/VolData00/web02&lt;br /&gt;
lvchange -a n /dev/Voldata00/web02&lt;br /&gt;
&lt;br /&gt;
## replace the disk physically, remember to partion it with type 8e&lt;br /&gt;
fdisk /dev/sdb&lt;br /&gt;
........&lt;br /&gt;
&lt;br /&gt;
# after replacing the faulty drive the disk must have the previuos UUID number or you can get it from /etc/lvm directory&lt;br /&gt;
pvcreate --uuid &amp;lt;previous UUID number taken from above command&amp;gt; /dev/sdb2&lt;br /&gt;
&lt;br /&gt;
# Restore the LVM configation&lt;br /&gt;
vgcfgrestore VolData00&lt;br /&gt;
&lt;br /&gt;
# attempt to bring the volume group online or logical volume&lt;br /&gt;
vgchange -a y VolData00&lt;br /&gt;
lvchange -a y /dev/VolData00/web02&lt;br /&gt;
&lt;br /&gt;
# file system check&lt;br /&gt;
e2fsck /dev/VolData00/data01&lt;br /&gt;
&lt;br /&gt;
Note: if you have backed the volume group configuration you can obtain the UUID number in the backup file by default located in /etc/lvm/backup or running &amp;quot;pvs -v&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Source: [http://www.datadisk.co.uk/html_docs/redhat/rh_lvm.htm Red Hat LVM Cheatsheet]&lt;/div&gt;</summary>
		<author><name>Michael Kohler</name></author>
	</entry>
</feed>