The other day while trying to recover my LVM2 volume, I was doing some POC work and while using lvextend
I encountered this error "New size given (XXX extents) not larger than existing size (XXX extents)" and it was not allowing me to perform lvextend
.
The solution is quite straight forward but I will would still give some background on the environment.
My Lab Environment
I added a new disk (/dev/sdb
) to my Virtual Machine to extend my root lvm partition
[root@server1 ~]# lsscsi
[0:0:0:0] cd/dvd VBOX CD-ROM 1.0 /dev/sr0
[1:0:0:0] cd/dvd VBOX CD-ROM 1.0 /dev/sr1
[2:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sda
[3:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sdb
Currently I only have single Physical Volume
[root@server1 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- <14.50g 0
So I created a new physical volume using /dev/sdb
[root@server1 ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created.
Next I extended the existing volume group to also use /dev/sdb PV
[root@server1 ~]# vgextend rhel /dev/sdb Volume group "rhel" successfully extended
List the bew volume group properties. So now I have around 8 GB free space available in my Volume group
[root@server1 ~]# vgs VG #PV #LV #SN Attr VSize VFree rhel 2 2 0 wz--n- 22.49g <8.00g
Currently my root partition size is 14G
[root@server1 ~]# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 14G 6.8G 5.8G 54% /
lvextend error: new size given (xx extents) not larger than existing size (xx extents)
So I planned to use lvextend to increase my root lvm partition size. Here I wanted to increase lvm size by 7.5GB as I already had 8 GB available for which I got this error:
[root@server1 ~]# lvextend -L 7.5G /dev/rhel/root
New size given (1920 extents) not larger than existing size (3472 extents)
Next I tried with a lower size and still the same resule
[root@server1 ~]# lvextend -L 7G /dev/rhel/root
New size given (1792 extents) not larger than existing size (3472 extents)
Next I used 100%FREE to use all the free extend available in the Volume Group and still same error
[root@server1 ~]# lvextend -l 100%FREE /dev/rhel/root
New size given (2047 extents) not larger than existing size (3472 extents)
Solution:
Finally I realised my silly mistake. My existing partition size itself is 14GB and to extend I must use (+) to define the additional size I wish to add to my existing volume
[root@server1 ~]# lvextend -l +100%FREE /dev/rhel/root Size of logical volume rhel/root changed from 13.56 GiB (3472 extents) to <21.56 GiB (5519 extents).
So with +100%FREE
the lvextend
command was successful
I hope this can help others doing the same mistake.
References:
How to fix resizing to the number of free extents rather than adding them to the current size in RHEL
Hey,
In the first place you should’ve used ‘+’ sign before 7.5G like below.
[root@server1 ~]# lvextend -L +7.5G /dev/rhel/root
(I wrote with errors, in a previous post).
I had exactly the same problem.
To resolve, the command was:
# lvextend -l +100%FREE /dev/mapper-name-vg/lv_name
Good luck
I think we all must have copied this typo from somwhere: “
-l100%FREE
” instead of “-l+100%FREE
“Thanks
Its works
thanks,it helps.
i had made same mistake.
thank you for this!
It’s important to mention that, if you rise a disk size, then you should add -r option to lvextend command to resize/update the filesystem as well. So the command could be:
Hope it be useful as this post was for me.
Regards
Hello , how to resolve problem please, New size (12372 extents) matches existing size (12372 extents) ??
Do you have free space available in your VG? Can you share the output of vgs command?
thank you, bro. I got the same silly mistake
thx man!