Journal

Extend the free space on LVM

Reading Time: < 1 minute

I had to reinstall my ubuntu 20.04 server because a boot issue became impossible to fix. After installing the OS, I found that df -lh only give me about 200 GB of space. I had more hard drive. With a little search around, I found that the disk is mounted, but I meant to extended to be more flexible. I just want all the space there.

This post gave a pretty good description of the problem and what to do, but here is commands I used specifically. This post showed how to extend all the free space, without specifying the exact amount of space.

sudo vgs

  VG        #PV #LV #SN Attr   VSize  VFree
  ubuntu-vg   1   1   0 wz--n- <2.73t 2.53t

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

  Size of logical volume ubuntu-vg/ubuntu-lv changed from <2.15 TiB (563200 extents) to <2.73 TiB (714879 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resize

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

resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 275, new_desc_blocks = 350
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 732036096 (4k) blocks long.

df -lh
/dev/mapper/ubuntu--vg-ubuntu--lv  2.7T   11G  2.6T   1% /