Mert Simsek
Mert Simsek

Reputation: 698

Centos Disk LVM Extension

I am having a problem with a VMWare VM which Centos7 is installed in it.

lsblk command gives something like below

enter image description here

df -h gives this

enter image description here

I am trying to extend root lvm to the partition but I am not able to do it no matter what I tried.

I tried fdisk /dev/sda to create a new partition and extend lvm to this partition but fdisk is getting stuck after partition number.

enter image description here

Some other useful commands give these results just in case they are helpful.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Any help would be appreciated. Thanks in advance.

Upvotes: 1

Views: 580

Answers (2)

Mert Simsek
Mert Simsek

Reputation: 698

I have executed pvresize /dev/sda2 command and after this I got pvs like below.

enter image description here

After this, I tried to execute vgextend centos /dev/sda2 but I got this error.

enter image description here

However vgs and vgdisplay centos commands are giving something different than before like below.

enter image description here

Upvotes: 0

LIU YUE
LIU YUE

Reputation: 1997

from your screenshot, your sda2 partition is 199G, sda1 takes 1G, your sda total size is 200G, you cannot make new partition from sda, that's why it stuck there; and to resolve your issue I provide two options for you to refer,but before operation please make sure you back up all your important data or vm files.

Option 1: this one is just my thoughts,unverified: from your vgs and pvs, you can see your sda2 only contributes <29G to whole VG(centos), so very simple way of extending your /root is:

1) pvresize /dev/sda2

,after execute, pls run pvs to check whether the pv size increased, if not, stop here

2) vgextend centos /dev/sda2

,after execute,pls check your vgs, see whether the size increased, if so go on to the next

3) lvextend -l 100%FREE /dev/mapper/centos-root

,after this, check lvs, if the root size not increased, go on

4) try:

xfs_growfs /dev/mapper/centos-root or resize2fs /dev/mapper/centos-root

Option 2: best practice is to use pvmove, this is strongly recommended for product environment, you can learn from https://askubuntu.com/questions/161279/how-do-i-move-my-lvm-250-gb-root-partition-to-a-new-120gb-hard-disk

Upvotes: 1

Related Questions