Adding a new disk to a LVM Linux server Jul 13, 2017

I'm using CentOS 7 64bit when writing this guide. Assume that you just add a new disk to the system name as /dev/sdb, now we will add it to LVM. 

Logical Volume Management

1. 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

2. Create physical volume

pvcreate /dev/sdb

3. Add physical volume to the volume group

vgextend cl /dev/sdb

4. Extend the logical volume

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

5. Resize file system

(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 /

Done!

Advertisement

Latest Updates