Increase Logical Volume

We will be increasing the size of halilv by 2GB

So first check what is the size of harilv with df -PTh command  and also lvs command

[root@linux ~]# lvs | grep harilv
harilv datavg -wi-ao---- 1.00g

[root@linux ~]# df -PTh | grep datavg
/dev/mapper/datavg-harilv ext4 976M 1.3M 924M 1% /haridai
/dev/mapper/datavg-srisirlv ext4 976M 1.3M 924M 1% /srisir

Cheek the volume group is it  has enough space using vgs command

[root@linux ~]# vgs | grep datavg
datavg 1 2 0 wz--n- 5.01g 3.01g

SInce datavg has 3 GB of space the needed 2Gb of space is avaliable. Now we will use lvextend command to extend the size.

[root@linux ~]# lvextend -r -L +2G /dev/datavg/harilv
Size of logical volume datavg/harilv changed from 1.00 GiB (256 extents) to 3.00 GiB (768 extents).
Logical volume harilv successfully resized
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/datavg-harilv is mounted on /haridai; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/mapper/datavg-harilv to 786432 (4k) blocks.
The filesystem on /dev/mapper/datavg-harilv is now 786432 blocks long.

Now we will checking using df and lvs command

root@linux ~]# lvs | grep harilv
harilv datavg -wi-ao---- 3.00g
[root@linux ~]# df -PTh | grep harilv
/dev/mapper/datavg-harilv ext4 3.0G 1.5M 2.8G 1% /haridai

We have another logicalvolume

[root@linux ~]# df -PTh | grep datavg
/dev/mapper/datavg-srisirlv ext4 976M 1.3M 924M 1% /srisir

we want to increase sirissirlv to 5GB total

lets check if the datavg has enough space or not

[root@linux ~]# vgs datavg
VG #PV #LV #SN Attr VSize VFree
datavg 1 2 0 wz--n- 5.01g 1.01g

datavg has only 1GB left but we need 4GB more so we will need to extend the volume group

we can achieve that by using vgextend command

but first we need to have a physical volume that is not being used by any volume group

[root@linux ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 appvg lvm2 a-- 67.75g 41.75g
/dev/sdb1 datavg lvm2 a-- 5.01g 1.01g
/dev/sdb2 lvm2 --- 5.01g 5.01g

we have /dev/sdb2 physical volume avaliable so we will use that

[root@linux ~]# vgextend datavg /dev/sdb2
Volume group "datavg" successfully extended

now check volumegroup

[root@linux ~]# pvs | grep /dev/sdb2
/dev/sdb2 datavg lvm2 a-- 5.01g 5.01g
[root@linux ~]# vgs datavg
VG #PV #LV #SN Attr VSize VFree
datavg 2 2 0 wz--n- 10.02g 6.02g

now we can see /dev/sdb2 has been added to datavg, and datavg has now 6GB of free space

so now we can extend the size of srisirlv

[root@linux ~]# lvextend -r -L 5G /dev/datavg/srisirlv
Size of logical volume datavg/srisirlv changed from 1.00 GiB (256 extents) to 5.00 GiB (1280 extents).
Logical volume srisirlv successfully resized
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/datavg-srisirlv is mounted on /srisir; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/mapper/datavg-srisirlv to 1310720 (4k) blocks.
The filesystem on /dev/mapper/datavg-srisirlv is now 1310720 blocks long.

Now check the size again

[root@linux ~]# lvs | grep srisir
srisirlv datavg -wi-ao---- 5.00g
[root@linux ~]# df -PTh | grep srisir
/dev/mapper/datavg-srisirlv ext4 4.9G 2.0M 4.7G 1% /srisir

 

Leave a Reply