How to extend the size of a Linux LVM by adding a new disk

In this example we will extend one LVM partitotion for 120GB which is size of newly added hard disk. vom primeru proširićemo jednu LVM particiju za 120GB koje je veličine novododati disk. Before any ‘gameplay’ with disk recommendation is to make data backup first.

First lets check current spaces in system by using command df -h and filesystem used under LVM patition which we want to extend (in our case is ext4) by using command mount | grep <<fajlsistem>>

Situation before adding new disk we check with command fdisk -l

We added new disk – and here is how it looks like in fdisk now. Please notice newly added disk with 120G of space. We dont see any partition bellow (like /dev/sdb1).

Follow instruction bellow. We start with disk partitiong by command fdisk /dev/sdb
Be carefull, after this step – there is no back.

After adding disk we can continue with LVM wxtend process.

# pvcreate <<newly created partition>>, or in our case
pvcreate /dev/sdb1

# Listing of curent volume group. 
# We will use later VG Name - so remember it somewhere (or copy-paste)

# vgextend <<VG Name>> <<newly created partition>>, or in our case
vgextend cl_centos7 /dev/sdb1

# Scanning for psychical volumes (please notice our with 120GB)

# Listing of logical volumes. 
# We want to extend this with name root and important info for us is LV path

# Logical volume extending
# lvextend <<LV path>> <<newly created partition>>, or in our case
lvextend /dev/cl_centos7/root /dev/sdb1

# Logical volume extending for free space which we added by new disk
# resize2fs <<LV path>>, or in our case
resize2fs /dev/cl_centos7/root
# If you use xfs please use xfs_growfs instead of resize2fs

New check od space by command df -h. Instead of initial 77GB orf root partition now we see 195GB.