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
Shutdown the VM (recommended for safety):
# From Proxmox shell, or use the Web UI qm shutdown <vmid>Navigate to VM Hardware:
- Select your VM in the Proxmox web interface
- Click on the Hardware tab
Select the Hard Disk:
- Click on the disk you want to resize (typically
scsi0orsata0)
- Click on the disk you want to resize (typically
Access Disk Action Menu:
- From the top navigation bar, select Disk Action
- Choose Resize from the dropdown
Enter Size Increase:
- Enter the amount to increase the disk by (e.g.,
20for 20GB) - Note: This is the increment, not the final size
- Click Resize disk
- Enter the amount to increase the disk by (e.g.,
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
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.
SSH into the VM:
ssh user@your-vm-ipCheck current disk usage (before resize):
df -hExample output:
Filesystem Size Used Avail Use% Mounted on /dev/vda2 30G 28G 2G 94% /View current partition layout:
lsblkExample 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
Run cfdisk to resize the partition:
sudo cfdisk /dev/vdaIn 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
yesto confirm - Select Quit to exit
- Use arrow keys to select the partition to resize (usually
Verify partition expansion:
lsblkUpdated 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
Resize the ext4 filesystem:
sudo resize2fs /dev/vda2Example 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.Confirm the changes:
df -hUpdated 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:
Check if using LVM:
sudo lvdisplayIf you see logical volume information, you’re using LVM. If command not found or no output, use Method A instead.
View current LVM layout:
sudo lsblkExample 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 /Expand the physical partition (if needed):
sudo cfdisk /dev/sda- Select the LVM partition (sda3 in example above)
- Choose Resize, then Write, then Quit
Resize the physical volume:
sudo pvresize /dev/sda3Example output:
Physical volume "/dev/sda3" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resizedExtend the logical volume:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lvExample 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.Resize the filesystem:
sudo resize2fs /dev/ubuntu-vg/ubuntu-lvVerify the changes:
df -h
Method C: XFS Filesystem
If you’re using XFS instead of ext4:
Check filesystem type:
df -TLook for
xfsin the Type column.After expanding the partition (using cfdisk or LVM as above), resize with:
sudo xfs_growfs /Note: XFS uses
xfs_growfsinstead ofresize2fs, 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:
- Verify the partition was actually enlarged:
sudo lsblk - You may need to reboot the VM for the kernel to recognize the new partition size
- After reboot, try
resize2fsagain
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:
- Shut down the VM completely
- Resize the disk in Proxmox
- Boot from Ubuntu Live CD/USB
- Resize partition and filesystem while unmounted
- Reboot normally
Verification Checklist
After completing the resize, verify everything worked correctly:
- Run
df -hand confirm available space increased - Run
lsblkand 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:
- Back up all data
- Create a new smaller VM
- 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.
Related Guides
- Creating VM templates in Proxmox
- Setting up LVM for flexible storage management
- Automating Proxmox VM deployments with cloud-init
Last updated: November 2024