Skip to main content

Expanding VM Filesystem Size

If the VM hits the size limit, but there is more space allocated, or you allocated the space. These steps will help with expanding the size of the volume.

Checking the Size

  1. Check Disk Usage to see which disk is affected
df -h
  1. Check volume group for free space
sudo vgdisplay

If there is no space, you will need to allocate more trough Hypervisor

Expanding filesystem roof

  1. Extend logical volume
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

This will add remaining space to the root system

  1. Resize filesystem
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
  1. Verify disk size and usage
df -h /

Fix GPT/ Partition Table

If you run into problem where even after expanding filesystem roof it still stays at original number we might need to fix gpt/ partition table. Usually after running command below we would get following message.

  1. Check Disk size vs Partition Size
sudo fdisk -l /dev/sda


GPT PMBR size mismatch (67108863 != 134217727) will be corrected by write.
The backup GPT table is not on the end of the device

  1. Fix GPT/ Partition Table
sudo gdisk /dev/sda
# Press 'v' to verify, then 'w' to write fixes
  1. Resize the partition
sudo parted /dev/sda
(parted) resizepart 3 100%
(parted) quit
  1. Reload partition table
sudo partprobe /dev/sda
  1. Resize physical volume
sudo pvresize /dev/sda3
  1. Check VG Free Space
sudo vgdisplay
  1. Expand Logical Volume
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  1. Resize Filesystem
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

At the end verify to make sure its actually resized

df -h /