Resize LVM volume so it fills entire remaining VG space

Quick LV resize to 100% of the space available on VG

Posted by Luke on Thu, 10 Oct 2019 13:29:00

This is a quick one. I have one volume and want to resize it so it will fill entire space that is left on a VG. I know there is plenty. If you want to check the VG use command “vgdisplay”. I want to resize my root volume:

root@ubuntu:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 12G 0 12G 0% /dev
tmpfs 2.4G 908K 2.4G 1% /run
/dev/mapper/ubuntu–vg-ubuntu–lv 3.9G 1.7G 2.1G 45% /
tmpfs 12G 0 12G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 12G 0 12G 0% /sys/fs/cgroup
/dev/sda2 239M 75M 147M 34% /boot
tmpfs 2.4G 0 2.4G 0% /run/user/1000
/dev/loop0 89M 89M 0 100% /snap/core/7270

Let's resize it:

root@ubuntu:~# lvresize -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 4.00 GiB (1024 extents) to <99.00 GiB (25343 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.

Resize underlying filesystem:

root@ubuntu:~# resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 13
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 25951232 (4k) blocks long.

Check actual size of filesystem now:

root@ubuntu:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 12G 0 12G 0% /dev
tmpfs 2.4G 908K 2.4G 1% /run
/dev/mapper/ubuntu–vg-ubuntu–lv 98G 1.7G 92G 2% /
tmpfs 12G 0 12G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 12G 0 12G 0% /sys/fs/cgroup
/dev/sda2 239M 75M 147M 34% /boot
tmpfs 2.4G 0 2.4G 0% /run/user/1000
/dev/loop0 89M 89M 0 100% /snap/core/7270

Done :)