How to increase ubuntu — vg volume size lvm

If you want to increase the logical volume size of Ubuntu after installation or whenever you need you can do it by the following;

First Type below command

lsblk

In my case it got the below information

NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0                       7:0    0  44.3M  1 loop /snap/snapd/23258
loop1                       7:1    0  73.9M  1 loop /snap/core22/1722
loop2                       7:2    0 139.6M  1 loop /snap/docker/2963
sda                         8:0    0    32G  0 disk
├─sda1                      8:1    0     1M  0 part
├─sda2                      8:2    0     2G  0 part /boot
└─sda3                      8:3    0    30G  0 part
  └─ubuntu--vg-ubuntu--lv 252:0    0    15G  0 lvm  /

Now suppose you want to increase the size of Ubuntu ubuntu–vg-ubuntu–lv, which is currently 15 GB. Which is inside sda 3, sda3 is a partition within the sda and has 30GB as total size. I have now two options either to utilize 100% of free space from sda3 or add some part of it. Both is possible through below commands.

First we will check the path of the logical volume to do that you will use below command

df -h

You will get bleow result

Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              1.4G  1.1M  1.4G   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   15G   11G  3.2G  78% /
tmpfs                              6.7G     0  6.7G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G   95M  1.7G   6% /boot
tmpfs                              1.4G   12K  1.4G   1% /run/user/1000

In my case the path of ubuntu–vg is /dev/mapper/ubuntu–vg-ubuntu–lv just make sure to change the and use one of the below options.

Options to Extend the Volume Size

I am giving you 2 options

Option1 : Use 100% Avaialble Size

If you want to use 100% available of sd3 then use below command

sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

Option2 : Add a specified size

If you want to add specified size use below command for example I want to add addtional 5GB then i will use below

sudo lvextend -L+5G /dev/mapper/ubuntu--vg-ubuntu--lv

Final Step

Now depending upon your file system you can use below comamnd

for ext4

sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

for xfs

sudo xfs_growfs /dev/mapper/ubuntu--vg-ubuntu--lv

Leave a Comment