====== Extend Existing Logical Volumes ======
**General Information**
Expanding existing logical volumes non-destructively.
----
===== Basic LVM Setup =====
**Create single partition on a new disk**
fdisk /dev/sdb
n (new partition)
(use defaults)
t (change type)
8e (Linux LVM)
w (write changes and quit)
\\
**Create physical volume**
pvcreate /dev/sdb1
pvdisplay
\\
**Create volume group**
vgcreate vglocal /dev/sdb1
vgdisplay
\\
**Create logical volume**
lvcreate -n lvstorage -L 20G vglocal
lvdisplay
\\
**Create XFS Filesystem**
mkfs -t xfs /dev/vglocal/lvstorage
\\
**Mount the volume**
mkdir -p /mnt/mystorage
mount /dev/vglocal/lvstorage /mnt/mystorage
----
===== Extend a volume group =====
**Create a partition on a new disk**
gdisk /dev/sdc
(same defaults + lvm type change as basic setup)
\\
**Create physical volume from created partition**
pvcreate /dev/sdc1
\\
**Extend the "vglocal" volume group and verify**
vgextend vglocal /dev/sdc1
pvs
----
==== Extend a logical volume ====
**Extend volume to be 30G in size(from 20G original)**
lvextend -L 30G --resizefs /dev/vglocal/lvstorage
OR
lvextend -L +10G --resizefs /dev/vglocal/lvstorage
* df -h shows that filesystem still needs to be resized to fill the LV container (if you did not use "--resizefs")
\\
**Resize the filesystem - if you did NOT use the "--resizefs" option above**
xfs_growfs /dev/vglocal/lvstorage
* If EXT filesystem, use: resize2fs /dev/vglocal/lvstorage
----