0% found this document useful (0 votes)
32 views3 pages

Linux Logical Volume Manager LVM

releted to Linux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views3 pages

Linux Logical Volume Manager LVM

releted to Linux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Linux - Logical Volume Manager (LVM) Cheat Sheet

by Leszek T (leszekt) via cheatography.com/170902/cs/35825/

LVM - schema

Example of an LVM layout.

LVM - termin​ology LVM - commands and LVM - Physical Volume LVM - Volume Group (cont)
components (cont)
PE - The smallest unit of pvcreate create PV vgimport register exported
physical disk space that can lvmdis​‐ prints devices that pvchange change attributes of VG in the system
extents be managed by LVM. kscan could be used as PV vgexport unregister VG from
It's set when you physical volumes the system
pvs|pv​‐ display inform​ation
create a volume lvmdump dumps LVM config​‐ display about PV vgimpo​‐ import a VG from
group. It determines uration to tar file
pvmove moves extents from rtclone cloned PVs
the "​gra​nul​ari​ty" of of
lvmetad caching service for one PV to another vgcreate create VG from one
disk space alloca​tio​‐
LVM metadata or more PVs
n.All physical pvremove removes a PV
volumes in a volume pvresize resizes a PV vgremove remove VG
LVM - important files
group will use the vgreduce remove PVs from
pvscan scans for changes
same extent size. /etc/lvm/ LVM config​uration
in PV config​uration VG
directory
LE - The same as PE but and size vgchange change VG
logical for Logical Volumes /etc/l​‐ LVM config​uration
attributes
extents vm/​‐ file
LVM - Volume Group vgextend extend VG with one
lvm.conf
PV - Disks, partit​ions, vgs|vg​‐ displays VG or more PVs
physical RAID volumes /etc/l​‐ Backup and archive
display inform​ation vgmerge merge VGs
volume vm/​{ar​‐ of LVM config​uration
vgmknodes create the special vgscan scan VGs for
chi​ve|​‐
VG - Group of one or more files for VG
backup} changes in
volume physical volumes devices in /dev metadata and size
group /etc/l​‐ Aa set of selected
vgck check VG consis​‐
vm/​‐ custom​izable config​‐
LV - Entity that contains tency LVM - Logical Volume
profile uration settings that
logical inform​ation, store on
can be used to vgcfgb​‐ make a backup of lvs|lv​‐ print LV metadata
volume physical volumes,
achieve certain ackup VG metadata display
grouped within a
charac​ter​istics in vgcfgr​‐ restore VG lvchange change attributes of
volume group
various enviro​nments estore metadata from LV
or uses. Normally, backup
LVM - commands and lvcreate create a new LV
the name of the
components vgrename rename a VG lvextend extend size of LV
profile should reflect
lvm pseudo shell for vgsplit move PVs to a lvreduce reduce size of LV
that enviro​nment or
LVM new or existing (offline!)
use. An LVM profile
VG
lvmconfig prints LVM config​‐ overrides existing lvresize change size of LV
uration from /etc/l​‐ config​ura​tion. vgconvert change VG
vm/​lvm.conf metadata format

By Leszek T (leszekt) Published 1st December, 2022. Sponsored by CrosswordCheats.com


cheatography.com/leszekt/ Last updated 1st December, 2022. Learn to solve cryptic crosswords!
Page 2 of 3. http://crosswordcheats.com
Linux - Logical Volume Manager (LVM) Cheat Sheet
by Leszek T (leszekt) via cheatography.com/170902/cs/35825/

LVM - Logical Volume (cont) LVM - create LV (cont) LVM - Snapshots (cont) Useful storage commands
(Bonus) (cont)
lvrename rename a LV lvcreate -n data_lv -l 100%FREE modify snapsh​‐ Enable
lvconvert change layout of data_vg ot_​aut​oex​ten​d_t​‐ automatic mount <PA​‐ Mount a
LVM reshold and extension of TH_​TO_​LV> filesystem in a
To create an LV you need a
snapsh​ot_​aut​‐ snapshots <MO​UNT​POI​‐ given location
lvscan scan LVs for volume group.
oex​ten​d_p​ercent by adjusting NT>
metadata changes
in lvm.conf the values mount -a Mount all
and size LVM - Snapshots
Snapshots contain differ​ences filesy​stems
lvremove remove LV lvcreate -L <SI​ZE> - Create a
from the point a given LV has listed in
s -n <NA​ME_​OF_​‐ snapshot
been created - not the real data. /etc/fstab
LVM - create PV SNA​PSH​OT> <PA​‐ of an LV
If the size of a snapshot is Useful in many situations when
TH_​TO_​LV>
pvcreate create a new
exceeded it becomes useless you need to manipulate storage
/dev/<​dis​k_d​‐ PV from lvcreate -L 4G -s -n data_l​v-s​‐
and there is no way to restore devices and layout.
evi​ce> device napshot /dev/m​​a​p​p​e​r/​​da​t​a-​​-​v​g_​​‐
data from it.
d​at​​a--lv
pvcreate /dev/sdb Old state of an LV can be LVM - extend PV
lvremove <PA​TH_​‐ Remove restored from a snapshot, but
To create a PV you need a
TO_​SNA​PSH​OT> snapshot rescan​-sc​si-​‐ Rescan
usable storage device. please remember to unmount
bus.sh​|echo 1 underlying
Try lvmdis​kscan command. lvremove /dev/m​​a​p​p​e​r/​​da​t​a-​​-​v​‐ the filesystem first.
> /sys/b​loc​k/<​‐ storage to
g_​​d​at​​a--lv
DEV​ICE​>/d​‐ detect change
LVM - create VG lvextend -L <SI​ZE> Extend Useful storage commands
evi​ce/​rescan in disk size
<PA​TH_​TO_​LV> snapshot (Bonus)
vgcreate create a volume rescan​-sc​si-​bus.sh​|echo 1 >
<VG> groups that consists lvextend -L +10G /dev/m​​a​p​p​e​r/​​‐ lsblk -o List block
/sys/b​loc​k/s​db/​dev​ice​/rescan
<PV> of one or more PVs da​t​a-​​-​v​g_​​d​at​​a--lv name,m​‐ devices with
partprobe Detect
<PV> oun​tpo​int​,la​‐ useful inform​‐
lvconvert --merge Restore
changes in
bel​,si​ze,uuid ation
vgcreate data_vg /dev/sdb <PA​TH_​TO_​SNA​‐ data
partition size
/dev/sdc PSH​OT> from multipathd Print path status
(if necessary)
snapshot show maps of multipath
To create a VG you need one or pvresize <PV> Resize PV to
status devices
more PVs. lvconvert --merge /dev/m​​a​p​p​e​r/​​‐
the maximum
da​t​a-​​-​v​g_​​d​at​​a--lv lvs -o Print LVs, VGs
possible size
+devices and device paths
LVM - create LV of partition or
vgs -o Print inform​ation disk/LUN
lvcreate -n create a LV of
+lv_si​ze,​‐ about LVs, VGs,
<LV​_NA​ME> - a given size in pvresize /dev/sdb
lv_name sizes and
L <SI​ZE> a VG
attributes To resize a PV you'll need to
<VG>
know the underlying storage and
mkfs.ext4 Format a
lvcreate -n data_lv -L 100G know how to rescan its size.
<FS> filesystem for
data_vg All steps can be performed
EXT4
lvcreate -n create a LV online.
mkfs.xfs Format a
<LV​_NA​ME> - that fills 100%
<FS> filesystem for
l 100%FREE of free space
XFS
<VG> in VG

By Leszek T (leszekt) Published 1st December, 2022. Sponsored by CrosswordCheats.com


cheatography.com/leszekt/ Last updated 1st December, 2022. Learn to solve cryptic crosswords!
Page 3 of 3. http://crosswordcheats.com
Linux - Logical Volume Manager (LVM) Cheat Sheet
by Leszek T (leszekt) via cheatography.com/170902/cs/35825/

LVM - Extend VG Extend filesystem (bonus) (cont)

vgextend Extend existing e2fsck -f /dev/m​​ap​p​e​r/​​dat​​a-​-​v​g_​​‐


<VG> VG with one or dat​​a--lv
<PV> more PVs resize2fs <PA​‐ Reduce size
<PV> TH_​TO_​LV> of filesystem
vgextend data_vg /dev/sdb <SI​ZE>
/dev/sdc resize2fs /dev/m​​ap​p​e​r/​​dat​​a-​-​v​‐
To extend a VG you need a VG g_​​dat​​a--lv 10G
and one or more PVs that are lvreduce -L <SI​‐ Reduce size
not assigned to any PVs yet. ZE> <PA​TH_​‐ of LV
TO_​LV>
LVM - extend LV
lvreduce -L 10G /dev/m​​ap​p​e​r/​​‐
lvextend -L extend logical dat​​a-​-​v​g_​​dat​​a--lv
<SI​ZE> volume by given e2fsck -f <PA​‐ Check for
/dev/m​‐ size (add 10GB to TH_​TO_​LV> errors once
app​er<​‐ existing size) more
PAT​H_T​‐
e2fsck -f /dev/m​​ap​p​e​r/​​dat​​a-​-​v​g_​​‐
O_L​V>
dat​​a--lv
lvextend -L +10G /dev/m​app​er/​‐
mount <FS> Mount
dat​a--​vg_​dat​a--lv
filesystem
lvextend -r extend logical
mount /data
-L <SI​ZE> volume and its
/dev/m​‐ filesystem by Remember to make sure the
app​er<​‐ given size (add size of both: FS (files​ystem) and
PAT​H_T​‐ 10GB to existing LV (logical volume) are the
O_L​V> size) same and there are no errors.
Reducing the size can ONLY be
lvextend -r -L +10G /dev/m​app​‐
done OFFLINE. The filesystem
er/​dat​a--​vg_​dat​a--lv
must be unmounted. Not all
To extend an LV you need its filesy​stems can be reduced at
path. Use df command. all.
In most cases you'll also want to
extend the underlying filesy​stem,
so use -r option to do it.

Extend filesystem (bonus)

umount <FS> Unmount


filesystem
umount /data
e2fsck -f Check and fix
<PA​TH_​TO_​‐ potential errors
LV>

By Leszek T (leszekt) Published 1st December, 2022. Sponsored by CrosswordCheats.com


cheatography.com/leszekt/ Last updated 1st December, 2022. Learn to solve cryptic crosswords!
Page 4 of 3. http://crosswordcheats.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy