Table of Contents
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
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
[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)
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).
lvextend command was successful
I hope this can help others doing the same mistake.