Skip to content

LVM Notes

  • PV: Physical volume, a block device
  • VG: Volume group, contains PV
  • LV: Logical volume, resides in a VG
-----------------------------------------------------
|                         |                         |
|      /dev/sda (PV)      |      /dev/sdb (PV)      |
|                         |                         |
-----------------------------------------------------
|                                                   |
|                         VG                        |
|                                                   |
-----------------------------------------------------
|         |                                         |
|   LV1   |                   LV2                   |
|         |                                         |
-----------------------------------------------------
|         |                                         |
|   ext4  |                  btrfs                  |
|         |                                         |
-----------------------------------------------------

Physical Volume (PV)

# create a PV
pvcreate /dev/sda1

# list PVs
pvdisplay

Volume Group (VG)

# create a VG
vgcreate MyVG /dev/sda1 /dev/sdb

# add a PV to a VG
vgextend MyVG /dev/sdc

# list VGs
vgdisplay

Logical Volume (LV)

Created LV will be at /dev/<VG name>/<LV name>, you can use it just like a regular block device

# create a 300GB LV
lvcreate -L 300G MyVG -n MyLV

# create a LV with all the avaiable capacity
lvcreate -l +100%FREE MyVG -n MyLV

# list LVs
lvdisplay

Steps: Create a Cached LV

# create 2 PVs
pvcreate /dev/slowdisk
pvcreate /dev/fastdisk

# create a VG with only slow disk
vgcreate RootVG /dev/slowdisk

# create a LV
lvcreate -l +100%FREE RootVG -n RootLV

# add the fast disk to VG
vgextend RootVG /dev/fastdisk

# create cache with fast disk
lvcreate --type cache --cachemode writeback -l 100%FREE -n Ro RootVG/RootLV /dev/fastdisk

Last update: July 25, 2021
Created: July 25, 2021