Recently I installed an Ubuntu Server 20.04 LTS in a virtual machine on VM Workstation Player 17.
For some reason, while I did create a 20 GB disk, I quickly got a warning that my disk space was nearly full. Having used Ubuntu for a while, I was surprised to see my 20 GB would already be full on this fresh install.
So I verified using the commands below. As you can see, it did detect that my physical volume was slightly short of 20 GB.
root@ubuntu01:/opt# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <18.23 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 4665
Free PE 2105
Allocated PE 2560
PV UUID bsAlMw-TKc1-hMOx-8tdy-fjKR-NwW6-uMG5fg
But my volume group was a different story. The volume group size (VG Size) was close to what the output of the physical volume told us. However, only 10 GB was allocated; and 8.22 GiB was for some reason not allocated. Probably an oversight on my side.
root@ubuntu01:/opt# 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 18.22 GiB
PE Size 4.00 MiB
Total PE 4665
Alloc PE / Size 2560 / 10.00 GiB
Free PE / Size 2105 / 8.22 GiB
VG UUID sYknqJ-0ZCm-9Cqc-qXp2-yU80-IC7N-eM75Jb
lvdisplay confirms this:
root@ubuntu01:/opt# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID YAs7Vb-5luh-TBOs-IVOH-cxiT-s4zX-OhFinf
LV Write Access read/write
LV Creation host, time ubuntu-server, 2024-01-28 08:44:17 +0000
LV Status available
# open 1
LV Size 10.00 GiB
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
Now, let’s make sure this logical volume group uses all the available space.
Above, we see the LV Path, which is what we need to run our next command.
root@ubuntu01:/opt# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 10.00 GiB (2560 extents) to 18.22 GiB (4665 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
If like me you forgot to add “-r” in the command above, check the type of file system.
# Check sizes
root@ubuntu01:~# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 388M 1.9M 386M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 18G 9.3G 7.8G 55% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
/dev/sda2 1.8G 136M 1.5G 9% /boot
tmpfs 388M 132K 388M 1% /run/user/1000
# Check file system
root@ubuntu01:~# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
tmpfs tmpfs 397092 1984 395108 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4 18696940 9680488 8109936 55% /
tmpfs tmpfs 1985444 0 1985444 0% /dev/shm
tmpfs tmpfs 5120 4 5116 1% /run/lock
/dev/sda2 ext4 1790136 138800 1542076 9% /boot
tmpfs tmpfs 397088 140 396948 1% /run/user/1000
In my case, I needed /dev/mapper/ubuntu–vg-ubuntu–lv which is an ext4 file system. My final step:
root@ubuntu01:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv