issue in adding physical volume to volume group lvm

Can anyone please help me fix the problem to add more GB to vg?

lsblk Output

NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                 8:0    0  128G  0 disk
|-sda1              8:1    0  500M  0 part /boot/efi
|-sda2              8:2    0  500M  0 part /boot
|-sda3              8:3    0    2M  0 part
`-sda4              8:4    0  127G  0 part
  |-rootvg-tmplv  253:0    0    2G  0 lvm  /tmp
  |-rootvg-usrlv  253:1    0   10G  0 lvm  /usr
  |-rootvg-optlv  253:2    0    2G  0 lvm  /opt
  |-rootvg-homelv 253:3    0    1G  0 lvm  /home
  |-rootvg-varlv  253:4    0   35G  0 lvm  /var
  `-rootvg-rootlv 253:5    0   12G  0 lvm  /
# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  rootvg   1   6   0 wz--n- <63.02g <1.02g
 #lvs
  LV     VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  homelv rootvg -wi-ao----  1.00g
  optlv  rootvg -wi-ao----  2.00g
  rootlv rootvg -wi-ao---- 12.00g
  tmplv  rootvg -wi-ao----  2.00g
  usrlv  rootvg -wi-ao---- 10.00g
  varlv  rootvg -wi-ao---- 35.00g

I need to use the unused GB’s from sda4 and extend the size of rootvg-varlv
can anyone please suggest me the steps to do that?

Asked By: ss2712

||

you can use vgextend command on your vg and then extend the lv with lvextend or lvresize. The problem is that usually you can not extend vg with size , just with another/new vg .Other problem is that usually it is somewhat risky to run those on live systems, thus i’d would suggest to do so on usb boot.

vgextend command:

pvcreate /dev/sdX
vgextend rootvg /dev/sdX
# sdX being new drive that you are extending the rootvg with -> it can be even usb device, although ssd is prefered
# just to clarify -> not the same usb that you are booting from.

lvextend command:

lvextend -L+20G /dev/rootvg/rootlv
# you need path to lv that you are extending.
Answered By: silent-mobius

It looks like you haven’t used all the available space in /dev/sda4 for your Physical Volume (PV). There’s 127GB assigned here:

`-sda4              8:4    0  127G  0 part

and although the LVs add up only to approximately 62GB:

|-rootvg-tmplv  253:0    0    2G  0 lvm  /tmp
|-rootvg-usrlv  253:1    0   10G  0 lvm  /usr
|-rootvg-optlv  253:2    0    2G  0 lvm  /opt
|-rootvg-homelv 253:3    0    1G  0 lvm  /home
|-rootvg-varlv  253:4    0   35G  0 lvm  /var
`-rootvg-rootlv 253:5    0   12G  0 lvm  /

the VG claims it has only around 1GB available out of 63GB:

rootvg   1   6   0 wz--n- <63.02g <1.02g

Try extending the PV. (As an aside, did you resize /dev/sda and/or /dev/sda4 at some point? It looks like that’s a possibility.)

pvresize /dev/sda4

Assuming it reports a successful increase in size, vgs should immediately show the extra available space, which you can then allocate as appropriate. Here’s an example showing how to add a further 10 GiB to the varlv LV:

lvextend --size +10G --resizefs /dev/rootvg/varlv

Don’t throw everything at varlv just because you can; just assign what you need right now. You can add more later if you need it, but by holding some back you can increase the sizes of other LVs should that become necessary. It’s much much easier to add space than to (safely) remove it.

Answered By: Chris Davies
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.