Increase logical volume in Ubuntu 18.04

When installing a new Ubuntu 18.04 server, I opted to use LVM instead of a standard partition layout.
When the installation completed, I noticed that the logical volume was only 4GB, whereas it should have been 50GB.

The output from pvdisplay, showed that the physical volume and the volume group (vgdisplay) were ~49GB:

sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <49.00 GiB / not usable 0
Allocatable yes
PE Size 4.00 MiB
Total PE 12543
Free PE 11519
Allocated PE 1024
PV UUID vfrbv2-Ndig-Fmse-eK5l-9ft6-lCwc-8237V8

And vgdisplay:

sudo vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <49.00 GiB
PE Size 4.00 MiB
Total PE 12543
Alloc PE / Size 1024 / 4.00 GiB
Free PE / Size 11519 / <45.00 GiB
VG UUID cDWTI6-wWDo-nI6T-nemp-sxmT-uV0X-DoUPb9

However, “lvdisplay” shows only 4GB available:

sudo lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID fiBYaN-2Ei5-JSHv-bBiO-Wy42-CGie-sQAqsr
LV Write Access read/write
LV Creation host, time ubuntu-server, 2020-03-23 10:41:16 +0000
LV Status available
# open 1
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

I only had to increase the logical volume:

sudo lvextend -l+100%free /dev/ubuntu-vg/ubuntu-lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 4.00 GiB (1024 extents) to <49.00 GiB (12543 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

And extend the file system:

sudo 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 = 7
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 12844032 (4k) blocks long.

That’s it!

Leave a Reply

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