How to extend LVM Logical Volume
Overview
- Physical Volume (PV) - This is the same as physical disks.
- Physical Extent (PE) - This is a small chunk of equal size. When we combine it, it makes physical volumes, which are called Physical Extents.
- Volume Group (VG) - A volume group simply combines all the physical extents of all the physical volumes to form one large logical volume group.
- Logical Volume (LV) - The volume group, which is a pool of disk space, by combining all physical extents of all the physical volumes. You can make partitions according to need from volume group by creating logical volumes.
pv -> gv -> lv -> fs
Demo
df -h
lsblk -f
sudo fdisk /dev/sdb
# add a new partition
n
# primary partition type
p
<Enter>
<Enter>
<Enter>
#change a partition type
t
# LVM type
8e
# print the partition table
p
# write table to disk and exit
w
Check:
sudo fdisk -l
PV (Physical Volume) Part
sudo pvdisplay
sudo pvcreate /dev/sdb1
sudo pvdisplay
VG (Volume Group) Part
Check VG Name:
sudo vgdisplay | grep -i "vg name"
VG Name ubuntu-vg
sudo vgextend <VG Name> /dev/sdb1
sudo vgdisplay
LV (Logical Volume) Part
Check LV Path:
sudo lvdisplay | grep -i "lv path"
LV Path /dev/ubuntu-vg/ubuntu-lv
sudo lvextend -l +100%FREE <LV Path>
sudo lvdisplay
sudo resize2fs <LV Path>
sudo lvdisplay
Check:
df -h