Extend LVM partition size when there is no free space in the Volume Group

There are some cases where we want to extend the size of LVM partition but in case if there is no free space available in the Volume group, then first we have to extend the volume group, to extend the volume group add new disks in volume group using vgextend command.

If there is no free disk available on the Linux box, then you can ask the storage team to assign new disk to the server.

Scenario: Suppose We want to extend the size of /home, but there is no free in the volume group .

Use the df command to verify the space of /home partition and use vgdisplay command to view the available space in the volume group

[[email protected] ~]# df -h /home/
 Filesystem            Size  Used Avail Use% Mounted on
 /dev/mapper/vg_cloud-LogVol00
                       16G   16G   41M 100% /home
[[email protected] ~]# vgdisplay vg_cloud
   --- Volume group ---
 VG Name                           vg_cloud
 System ID
 Format                            lvm2
 Metadata Areas                    1
 Metadata Sequence No              8
 VG Access                         read/write
 VG Status                         resizable
 MAX LV                            0
 Cur LV                            3
 Open LV                           3
 Max PV                            0
 Cur PV                            1
 Act PV                            1
 VG Size                           27.01 GiB
 PE Size                           4.00 MiB
 Total PE                          6915
 Alloc PE / Size                   6915 / 27.01 GiB
  Free  PE / Size                  0 / 0   
 VG UUID                           1R89GB-mIP2-7Hgu-zEVR-5H02-7GdB-Ufj7R4

Step:1  Create Physical Volume on new disk

Check the new disk using ‘ fdisk -l ‘ command and create the physical volume, in my case new disk is ‘/dev/sdb’

[email protected] ~]# pvcreate /dev/sdb
          Physical volume "/dev/sdb" successfully created

Step:2 Now extend the Size of Volume Group using vgextend.

[[email protected] ~]# vgextend vg_cloud /dev/sdb
    Volume group "vg_cloud" successfully extended

Step:3 Verify the size of Volume Group.

[[email protected] ~]# vgdisplay vg_cloud
   --- Volume group ---
 VG Name                           vg_cloud
 System ID
 Format                            lvm2
 Metadata Areas                    2
 Metadata Sequence No              9
 VG Access                         read/write
 VG Status                         resizable
 MAX LV                            0
 Cur LV                            3
 Open LV                           3
 Max PV                            0
 Cur PV                            2
 Act PV                            2
 VG Size                           37.04 GiB
 PE Size                           4.00 MiB
 Total PE                          9481
 Alloc PE / Size                   6915 / 27.01 GiB
 Free  PE / Size                   2566 / 10.02 GiB
 VG UUID                           1R89GB-mIP2-7Hgu-zEVR-5H02-7GdB-Ufj7R4

Note: As you can see Available or Free PE / size is 10.02 GB

Step:4 Extend lvm partition size with lvextend command

[[email protected] ~]# lvextend -L +5G /dev/mapper/vg_cloud-LogVol00
     Extending logical volume LogVol00 to 21.25 GiB
 Logical volume LogVol00 successfully resized

Step:5 Run resize2fs command

 [[email protected] ~]# resize2fs /dev/mapper/vg_cloud-LogVol00
 resize2fs 1.41.12 (17-May-2010)
 Filesystem at /dev/mapper/vg_cloud-LogVol00 is mounted on /home; on-line resizing required
 old desc_blocks = 2, new_desc_blocks = 2
 Performing an on-line resize of /dev/mapper/vg_cloud-LogVol00 to 5569536 (4k) blocks.
 The filesystem on /dev/mapper/vg_cloud-LogVol00 is now 5569536 blocks long.

Step:6 Verify the file system size

[[email protected] ~]# df -h /home/
 Filesystem            Size  Used Avail Use% Mounted on
 /dev/mapper/vg_cloud-LogVol00
                        21G   16G  4.8G  77% /home

3 Responses

  1. Siddharth Rana says:

    Thanks for the post …Better way to extend LVM paritions online without unmounting .

  1. June 24, 2014

    […] There are some cases when we want to extend the size of LVM partition but if there is no free space available in the Volume group , then first we have to extend the volume group , to extend the volume group add new disks in volume group using vgextend command. …Read More […]

  2. June 24, 2014

    […] Extend LVM partition size when there is no free space in the Volume Group […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest