InformationReferenceVirtualizationStorageUbuntuProxmoxVMWare

Expanding Ubuntu VM Storage

A quick reference guide for expanding the storage of an Ubuntu virtual machine using Proxmox or VMWare ESXi.

2 minute read ยท 328 words

Over the past 5 years, I have used Proxmox and VMWare ESXi to run my virtual machines. Every time I needed to expand the storage of a VM, I often find myself looking up a version of these steps. So I decided to write them down here for future reference.

This guide is less of a tutorial and more of a quick reference for myself.

Steps to Expand VM Storage

  1. Shutdown the VM: Ensure that the virtual machine is powered off before making any changes to the disk size.
  2. Increase Disk Size:
    • In Proxmox, go to the VM's hardware settings and increase the disk size.
    • In VMWare, right-click on the VM, select "Edit Settings," and adjust the disk size accordingly.
  3. Boot the VM: Start the virtual machine after resizing the disk.
  4. Open up the console to the VM. (or SSH into it)
  5. Check the current file system: df -h

Resize the Partition

  • parted is a useful tool for managing disk partitions. If it's not installed, you can install it using:

    sudo apt-get install parted
  • Start parted on the disk you want to resize (e.g., /dev/sda):

    parted /dev/sda
  • Use the print command to see the current partitions:

    (parted) print
  • Resize the partition to fill the new disk size. For example, if you want to resize partition 1:

    (parted) resizepart <main_partition> 100%

    Replace <main_partition> with the partition number you want to resize (e.g., 1 for /dev/sda1).

  • After resizing, exit parted:

    (parted) quit

Resize the "physical volume"

If you're using LVM, you'll need to resize the physical volume after resizing the partition. First, check the physical volumes:

sudo pvdisplay
  • Resize the physical volume:

    sudo pvresize /dev/sda3
  • Replace /dev/sda3 with the appropriate partition if different.

Resize the Logical Volume

  • Check the logical volumes:

    sudo lvdisplay
  • Resize the logical volume to use the available space:

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

    Replace /dev/ubuntu-vg/ubuntu-lv with your logical volume path.

Resize the File System

Finally, resize the file system to use the new space. For ext4 file systems, use:

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

Verify the Changes

Once all steps are completed, verify that the file system has been resized successfully:

df -h

You should see the increased size reflected in the output.