How to Extend LVM Partition in Linux Vmware

In this Post we will discuss how to extend lvm partition in linux with help of lvextend command.
how to extend lvm partition in linux

Prerequisites:

Before extend the volume group first we have to check enough free space available or not on volume group (vg) to extend a Logical volume using the below command. If we don’t have free space the how to extend lvm partition in linux. Please follow the below steps.

  • #vgdisplay

How to extend a Logical Volume?.

Assume that we have a filesystem “/dev/my_vg01/my_lv01” with size 60GB and Application team want more 2GB, so now we need to increase the size by 2GB.

There are two ways to extend lvm.

  1. If enough space is available on volume group (vg) then you can increase logical volume (lv). Directly start  from step5.
  2. If enough space is not available on volume group (vg), then follow the below steps.

Step 1

Go to vmware workstation/virtual-box and right click on your server/host and cleck on settings, select Hard Disk and cleck on Add, then add your disk as per your requirement. This lab I am going to add 2GB new Disk.

how to extend lvm partition in linux

Step 2.

Scan the new disks on server and verify with help of below command.

  • # for i in /sys/class/scsi_host/*; do echo “- – -” | sudo tee $i/scan; ls /dev/sd* ; done
how to extend lvm partition in linux

Step3.

Create partition on new disk or else you create PV (Physical Volumes) also but, here we are going to use crate partition.

Step4.

Extend to volume group (VG). Below command will extend the volume group to total 2GB.

  • [root@myaansible ~]# vgextend aap_vg /dev/sdb1

Step 5.

Now Extend to Logical volume (LV). Below command will help to extend the logical volume to total 2GB. As a mentioned below command will be use entire volume group, because in command we are using 100%. If you want to use particular amount of volume size then you can use this command  lvextend -L +2GB /dev/aap_vg/app_lv01

  • [root@myaansible ~]# lvextend -l +100%FREE /dev/aap_vg/app_lv01

Step 6.

After extending the Logical Volume, its mandatory to increase the filesystem in partition table to match. Because now it will show the logical volume size as 62GB, but when you do “df -hP“, it won’t show you the extended size.


Use resizing tools to increase the filesystem size to match the extended size. For each filesystem, we have different tools.

For ext2/ext3/ext4 we are using resize2fs command.

  • [root@myaansible ~]# resize2fs /dev/mapper/app_vg_app_lv01

If you have xfs file system then you can use xfsgrowfs to resize the file system in linux.

  • #xfsgrowfs /dev/mapper/app_vg_app_lv01

Leave your message if anything missed and we appreciate your comments. You can also watch this video “How to Extend LVM Partition in Linux“.

 

Related Posts

Leave a Reply

Your email address will not be published.