Skip to content
Home » Linux » How to Increase Logical Volume Size on Linux

How to Increase Logical Volume Size on Linux

Logical volumes (LV) are controlled by the belonging volume group (VG), so there must have some free space in the VG for LVs to increase. If there's no free space in VG, you need to make some. Please feel free to refer the following post for further information.
How to Increase Volume Group Size on Enterprise Linux

According to the information below, we are sure about that there do have free space in VG, so we can proceed to increase the size for LVs.
[root@test ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  VolGroup   2   2   0 wz--n- 239.50g 200.00g
[root@test ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_root
  LV Name                lv_root
  VG Name                VolGroup
  LV UUID                Bnn3r1-tOxw-DrI7-gMnj-bEU7-ML32-JQFIGw
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2014-07-17 19:10:08 +0800
  LV Status              available
  # open                 1
  LV Size                35.63 GiB
  Current LE             9122
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_swap
  LV Name                lv_swap
  VG Name                VolGroup
  LV UUID                ieeYp9-JQXA-FMHq-bfTG-cbCj-Y2EN-JbCEng
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2014-07-17 19:10:12 +0800
  LV Status              available
  # open                 1
  LV Size                3.88 GiB
  Current LE             992
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

There're two kinds of option that you can add space to LV.
  1. Add exact number of GB to the LV. The -L is used for size.
  2. [root@test ~]# lvextend -L +100GB /dev/mapper/VolGroup-lv_root
      Extending logical volume lv_root to 135.63 GiB
      Logical volume lv_root successfully resized

  3. Add all free extents to the LV. The -l is used for extents.
  4. [root@test ~]# lvextend -l +100%FREE /dev/mapper/VolGroup-lv_root
      Extending logical volume lv_root to 235.63 GiB
      Logical volume lv_root successfully resized
Let's check the VG again.
[root@test ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  VolGroup   2   2   0 wz--n- 239.50g    0
[root@test ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_root
  LV Name                lv_root
  VG Name                VolGroup
  LV UUID                Bnn3r1-tOxw-DrI7-gMnj-bEU7-ML32-JQFIGw
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2014-07-17 19:10:08 +0800
  LV Status              available
  # open                 1
  LV Size                235.63 GiB
  Current LE             60321
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_swap
  LV Name                lv_swap
  VG Name                VolGroup
  LV UUID                ieeYp9-JQXA-FMHq-bfTG-cbCj-Y2EN-JbCEng
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2014-07-17 19:10:12 +0800
  LV Status              available
  # open                 1
  LV Size                3.88 GiB
  Current LE             992
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

Have we done yet? No, above actions were all on Volume-level, we still have some works on OS-level.

First, check the space usage in the system.
[root@test ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root   36G   26G  7.5G  78% /
...

Apparently, the added 200GB does not get into it. We can use resize2fs to solve this.
[root@test ~]# resize2fs -p /dev/mapper/VolGroup-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 3, new_desc_blocks = 15
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 61768704 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 61768704 blocks long.

If you're working on xfs file system, you should use xfs_growfs:
[root@test ~]# xfs_growfs /dev/mapper/VolGroup-lv_root
It will grow to the maximum size supported by the device.

Please note that, you don't have to umount the LV before doing resize2fs because this kind of resizing can be done online.

Let's see the final result.
[root@test ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root  232G   26G  195G  12% /
...

The added space can be serviceable now.

Leave a Reply

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