Through the logical volume management technology provided by Linux, we can flexibly manipulate the file systems in every volume.

Prerequisite

The used partitions’ system types must be defined as 8e (Linux LVM).

Device File

  • /dev/dm-#

Mapper Files

  • /dev/mapper/VG_NAME-LV_NAME
    • /dev/mapper/vol0-root
  • /dev/VG_NAME/LV_NAME
    • /dev/vol0/root

Definitions

  • PV: Physical Volume
    • PE: Physical Extent
  • VG: Volume Group
  • LV: Logical Volume
    • LE: Logical Extent

Install LVM Version 2

Before we get started, we need to install the lvm version 2 toolkit:

1
yum install lvm2 -y

Commands

Physical Volume

View Information About Physical Volumes

1
pvs

View the Attributes of the Physical Volume(s)

1
pvdisplay [device]

Initialize the Physical Volume(s)

1
pvcreate device(s)

Remove the LVM label(s) from the Physical Volume(s)

1
pvremove devices(s)

Volume Group

View Information About Volume Groups

1
vgs

View a Volume Group Information

1
pvdisplay [device]

Create Volume Groups

1
vgcreate

Add Physical Volumes to the Volume Group

1
vgextent

Remove Physical Volume(s) from Volume Group(s)

1
vgreduce

Remove Volume Group(s)

1
vgremove

Switch a Volume Group to Unusable State

1
vgexport

Switch a Volume Group to Usable State

1
vgimport

Logical Volume

View Information About Logical Volumes

1
lvs

View a Logical Volume Information

1
lvdisplay [device]

Create Logical Volumes

1
lvcreate

Change Logical Volumes Attributes

1
lvchange

Add Space to Logical Volumes

1
lvextent -L [+]    # Plus means accumulation, without plus means assignment.

Reduces sizes of Logical Volumes

1
lvreduce

Remove Logical Volumes

1
lvremove

References PVS(8), PVDISPLAY(8), PVCREATE(8), PVREMOVE(8), VGS(8), VGDISPLAY(8), VGCREATE(8), VGEXTEND(8), LVREDUCE(8), VGREMOVE(8), VGEXPORT(8), VGIMPORT(8), LVS(8), LVDISPLAY(8), LVCREATE(8), LVCHANGE(8), LVEXTEND(8), LVREDUCE(8), LVREMOVE(8)

Buy me a coffeeBuy me a coffee