Linux Logical Volume Manager LVM
Linux Logical Volume Manager LVM
LVM - schema
LVM - terminology 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 information
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 "granularity" of of
lvmetad caching service for one PV to another vgcreate create VG from one
disk space allocatio‐
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 configuration
in PV configuration VG
directory
LE - The same as PE but and size vgchange change VG
logical for Logical Volumes /etc/l‐ LVM configuration
attributes
extents vm/‐ file
LVM - Volume Group vgextend extend VG with one
lvm.conf
PV - Disks, partitions, vgs|vg‐ displays VG or more PVs
physical RAID volumes /etc/l‐ Backup and archive
display information vgmerge merge VGs
volume vm/{ar‐ of LVM configuration
vgmknodes create the special vgscan scan VGs for
chive|‐
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/‐ customizable config‐
LV - Entity that contains tency LVM - Logical Volume
profile uration settings that
logical information, 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
characteristics in vgcfgr‐ restore VG lvchange change attributes of
volume group
various environments 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 environment 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‐ configuration. vgconvert change VG
vm/lvm.conf metadata format
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_autoextend_t‐ automatic mount <PA‐ Mount a
LVM reshold and extension of TH_TO_LV> filesystem in a
To create an LV you need a
snapshot_aut‐ snapshots <MOUNTPOI‐ given location
lvscan scan LVs for volume group.
oextend_percent by adjusting NT>
metadata changes
in lvm.conf the values mount -a Mount all
and size LVM - Snapshots
Snapshots contain differences filesystems
lvremove remove LV lvcreate -L <SIZE> - Create a
from the point a given LV has listed in
s -n <NAME_OF_‐ snapshot
been created - not the real data. /etc/fstab
LVM - create PV SNAPSHOT> <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/<disk_d‐ PV from lvcreate -L 4G -s -n data_lv-s‐
and there is no way to restore devices and layout.
evice> device napshot /dev/mapper/data--vg_‐
data from it.
data--lv
pvcreate /dev/sdb Old state of an LV can be LVM - extend PV
lvremove <PATH_‐ Remove restored from a snapshot, but
To create a PV you need a
TO_SNAPSHOT> snapshot rescan-scsi-‐ Rescan
usable storage device. please remember to unmount
bus.sh|echo 1 underlying
Try lvmdiskscan command. lvremove /dev/mapper/data--v‐ the filesystem first.
> /sys/block/<‐ storage to
g_data--lv
DEVICE>/d‐ detect change
LVM - create VG lvextend -L <SIZE> Extend Useful storage commands
evice/rescan in disk size
<PATH_TO_LV> snapshot (Bonus)
vgcreate create a volume rescan-scsi-bus.sh|echo 1 >
<VG> groups that consists lvextend -L +10G /dev/mapper/‐ lsblk -o List block
/sys/block/sdb/device/rescan
<PV> of one or more PVs data--vg_data--lv name,m‐ devices with
partprobe Detect
<PV> ountpoint,la‐ useful inform‐
lvconvert --merge Restore
changes in
bel,size,uuid ation
vgcreate data_vg /dev/sdb <PATH_TO_SNA‐ data
partition size
/dev/sdc PSHOT> 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/mapper/‐
the maximum
data--vg_data--lv lvs -o Print LVs, VGs
possible size
+devices and device paths
LVM - create LV of partition or
vgs -o Print information disk/LUN
lvcreate -n create a LV of
+lv_size,‐ about LVs, VGs,
<LV_NAME> - a given size in pvresize /dev/sdb
lv_name sizes and
L <SIZE> 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_NAME> - that fills 100%
<FS> filesystem for
l 100%FREE of free space
XFS
<VG> in VG