Adding a new disk to a LVM Linux server

Logical Volume Management
Logical Volume Management

Introduction

This guide is written for CentOS 7 64-bit. Assuming you have attached a new disk to the system, named /dev/sdb, we will proceed to integrate it into the LVM.

Prerequisites

  • Basic knowledge of Linux OS.

Get the LVM Information

Run this command:

lvdisplay

You will see the output similar to the following:

--- Logical volume ---
LV Path      /dev/cl/root
LV Name      root
VG Name      cl
LV UUID      0hWLVK-3NY2-Tq4o-4oYd-4KGp-Wnhc-fW5CtP

...

--- Logical volume ---
LV Path      /dev/cl/swap
LV Name      swap
VG Name      cl

Remember the LV Path /dev/cl/root and VG Name cl for later steps.

Create physical volume

Run this command:

pvcreate /dev/sdb

Add physical volume to the volume group

Run this command:

vgextend cl /dev/sdb

Extend the logical volume

Run this command:

lvextend -l +100%FREE /dev/cl/root

Resize filesystem

(use resize2fs for ext4 file system):

xfs_growfs /

Note: if you change your sdb, then you can increase LVM by running the following commands:

pvresize /dev/sdb
lvextend -l +100%FREE /dev/cl/root
xfs_growfs /

Conclusion

You have now added a new disk to the LVM.