Introduction

Running out of disk space on a virtual machine is a common scenario as applications grow and data accumulates. Unlike physical servers, virtual machines in Proxmox make it relatively simple to expand disk capacity without downtime or hardware changes.

This guide walks you through safely resizing an Ubuntu VM’s disk in Proxmox, covering both the Proxmox UI configuration and the in-guest partition and filesystem operations needed to make the additional space available to your operating system.

Common use cases for disk resizing:

  • Database storage requirements have grown beyond initial estimates
  • Application logs are consuming more space than anticipated
  • Docker containers and images are filling up the disk
  • User data or media files require additional capacity

Prerequisites

Before beginning the disk resize process, ensure you have:

  • Proxmox VE access with permissions to modify VM hardware
  • SSH or console access to the Ubuntu VM
  • Root or sudo privileges on the Ubuntu VM
  • Current backup of the VM or critical data (see safety warning below)
  • Basic familiarity with Linux command-line tools

Recommended Proxmox versions: This guide works with Proxmox VE 6.x, 7.x, and 8.x

Supported Ubuntu versions: Ubuntu 18.04 LTS, 20.04 LTS, 22.04 LTS, 24.04 LTS


⚠️ Safety Warning

IMPORTANT: Back up your data before resizing disks. While disk resizing is generally safe, any disk operation carries some risk of data loss if something goes wrong (power failure, network interruption, etc.).

Best practices:

  • Create a Proxmox snapshot or backup before starting
  • Test the resize procedure on a non-production VM first
  • Verify you have sufficient free storage in your Proxmox storage pool
  • Shutdown the VM if possible (recommended for safety, though not strictly required for expansion)

Part 1: Resize Disk in Proxmox UI

  1. Shutdown the VM (recommended for safety):

    # From Proxmox shell, or use the Web UI
    qm shutdown <vmid>
    
  2. Navigate to VM Hardware:

    • Select your VM in the Proxmox web interface
    • Click on the Hardware tab
  3. Select the Hard Disk:

    • Click on the disk you want to resize (typically scsi0 or sata0)
  1. Access Disk Action Menu:

    • From the top navigation bar, select Disk Action
    • Choose Resize from the dropdown
  2. Enter Size Increase:

    • Enter the amount to increase the disk by (e.g., 20 for 20GB)
    • Note: This is the increment, not the final size
    • Click Resize disk
  1. Verify the Resize:

    • The new size should be reflected in the Hardware tab immediately
    • Example: If disk was 32GB and you added 20GB, it should now show 52GB
  2. Start the VM:

    qm start <vmid>
    

Expected output from Proxmox logs:

update VM 100: -scsi0 local-lvm:vm-100-disk-0,size=52G

Part 2: Expand Partition and Filesystem (Ubuntu)

After resizing the disk in Proxmox, the VM now has additional unallocated space. You need to expand the partition and filesystem to use this space.

Method A: Standard ext4 Partition (Most Common)

This method applies to standard Ubuntu installations using ext4 filesystems without LVM.

  1. SSH into the VM:

    ssh user@your-vm-ip
    
  2. Check current disk usage (before resize):

    df -h
    

    Example output:

    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda2        30G   28G   2G   94% /
    
  3. View current partition layout:

    lsblk
    

    Example output:

    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    vda      252:0    0   52G  0 disk
    ├─vda1   252:1    0    1M  0 part
    └─vda2   252:2    0   32G  0 part /
    

    Note: Disk shows 52G total, but vda2 partition only uses 32G - we need to expand vda2

  1. Run cfdisk to resize the partition:

    sudo cfdisk /dev/vda
    

    In the cfdisk interface:

    • Use arrow keys to select the partition to resize (usually /dev/vda2)
    • Select Resize and press Enter
    • The new size should auto-fill with maximum available space
    • Select Write and type yes to confirm
    • Select Quit to exit
  1. Verify partition expansion:

    lsblk
    

    Updated output:

    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    vda      252:0    0   52G  0 disk
    ├─vda1   252:1    0    1M  0 part
    └─vda2   252:2    0   52G  0 part /
    

    Now vda2 shows 52G, matching the disk size

  2. Resize the ext4 filesystem:

    sudo resize2fs /dev/vda2
    

    Example output:

    resize2fs 1.46.5 (30-Dec-2021)
    Filesystem at /dev/vda2 is mounted on /; on-line resizing required
    old_desc_blocks = 4, new_desc_blocks = 7
    The filesystem on /dev/vda2 is now 13631488 (4k) blocks long.
    
  3. Confirm the changes:

    df -h
    

    Updated output:

    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda2        51G   28G   21G   58% /
    

    Available space increased from 2G to 21G


Method B: LVM (Logical Volume Manager)

Many Proxmox templates and enterprise Ubuntu installations use LVM. If your system uses LVM, follow these steps instead:

  1. Check if using LVM:

    sudo lvdisplay
    

    If you see logical volume information, you’re using LVM. If command not found or no output, use Method A instead.

  2. View current LVM layout:

    sudo lsblk
    

    Example LVM output:

    NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda                         8:0    0   52G  0 disk
    ├─sda1                      8:1    0    1M  0 part
    ├─sda2                      8:2    0    2G  0 part /boot
    └─sda3                      8:3    0   30G  0 part
      └─ubuntu--vg-ubuntu--lv 253:0    0   30G  0 lvm  /
    
  3. Expand the physical partition (if needed):

    sudo cfdisk /dev/sda
    
    • Select the LVM partition (sda3 in example above)
    • Choose Resize, then Write, then Quit
  4. Resize the physical volume:

    sudo pvresize /dev/sda3
    

    Example output:

    Physical volume "/dev/sda3" changed
    1 physical volume(s) resized or updated / 0 physical volume(s) not resized
    
  5. Extend the logical volume:

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

    Example output:

    Size of logical volume ubuntu-vg/ubuntu-lv changed from 30.00 GiB to 50.00 GiB
    Logical volume ubuntu-vg/ubuntu-lv successfully resized.
    
  6. Resize the filesystem:

    sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
    
  7. Verify the changes:

    df -h
    

Method C: XFS Filesystem

If you’re using XFS instead of ext4:

  1. Check filesystem type:

    df -T
    

    Look for xfs in the Type column.

  2. After expanding the partition (using cfdisk or LVM as above), resize with:

    sudo xfs_growfs /
    

    Note: XFS uses xfs_growfs instead of resize2fs, and operates on the mount point rather than the device.


Troubleshooting

Issue: “The partition is being used” error in cfdisk

Solution: The partition is mounted. For root partitions, this is normal. The filesystem resize (resize2fs) will handle online resizing. Just proceed with writing the partition table.

Issue: resize2fs says “Nothing to do”

Cause: The filesystem is already using all available space on the partition.

Solution:

  1. Verify the partition was actually enlarged: sudo lsblk
  2. You may need to reboot the VM for the kernel to recognize the new partition size
  3. After reboot, try resize2fs again

Issue: Space doesn’t appear in df -h after resize

Cause: You resized the partition but didn’t resize the filesystem.

Solution: Run the appropriate filesystem resize command:

  • ext4: sudo resize2fs /dev/vda2
  • XFS: sudo xfs_growfs /
  • LVM: Follow Method B completely

Issue: Can’t resize boot disk (sda/vda)

Cause: Some systems won’t allow online resizing of boot disks.

Solution:

  1. Shut down the VM completely
  2. Resize the disk in Proxmox
  3. Boot from Ubuntu Live CD/USB
  4. Resize partition and filesystem while unmounted
  5. Reboot normally

Verification Checklist

After completing the resize, verify everything worked correctly:

  • Run df -h and confirm available space increased
  • Run lsblk and verify partition size matches disk size
  • Check application logs for any disk-related errors
  • Test writing a file to confirm the filesystem is working
  • Monitor VM for a few minutes to ensure stability

Test write command:

sudo dd if=/dev/zero of=/test-file bs=1M count=100
sudo rm /test-file

This writes a 100MB test file and removes it, confirming write capability.


Additional Notes

Can I shrink a disk?

Shrinking is much more complex and risky than expanding. Proxmox does not support shrinking disks through the UI. If you must shrink a disk, you’ll need to:

  1. Back up all data
  2. Create a new smaller VM
  3. Restore data to the new VM

What about Windows VMs?

Windows VMs require using Windows Disk Management or diskpart instead of the Linux commands shown here. The Proxmox side (Part 1) is the same.

Live resize vs. shutdown?

Modern Linux kernels support online filesystem resizing for ext4 and XFS. However, shutting down the VM is safer and eliminates the risk of filesystem corruption if something goes wrong during the operation.


  • Creating VM templates in Proxmox
  • Setting up LVM for flexible storage management
  • Automating Proxmox VM deployments with cloud-init

Last updated: November 2024