Resizing the virtual disk on Proxmox
22 Nov 2024 - 3 min read![Resizing the virtual disk on Proxmox](/_image?href=https%3A%2F%2Fs3.thinhhv.com%2Fthinhhv-blog%2Fuploads%2Fresizing-the-virtual-disk-on-proxmox.jpg&w=768&h=432&f=webp)
Extending the volume on a virtual machine running Linux on Proxmox involves several steps. The process requires resizing the virtual disk on Proxmox, making the disk space available to the operating system, and then extending the logical volume.
Table of Contents
- Overview
- Step 1: Resize the Virtual Disk on Proxmox
- Step 2: Rescan the Disk in VM
- Step 3: Resize the Physical Volume
- Step 4: Extend the Logical Volume
- Step 5: Resize the Filesystem
- Optional: Verify Everything
- Summary
Overview
- First, resize disk on Proxmox.
- On VM, running the commands:
# Make the partition see the space (/dev/sda3, Resize, Write, quit)sudo cfdisk
# Extend the physical volume from the partitionsudo pvresize /dev/sda3
# Extend LV to use up all space from VGsudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
# Resize file systemsudo resize2fs /dev/ubuntu-vg/ubuntu-lv
# Check can see the space on filesystemdf -h
Remember change
/dev/sda3
to your partition name
Step 1: Resize the Virtual Disk on Proxmox
- Log in to the Proxmox web interface.
- Navigate to the VM whose disk you want to resize.
- Go to the Hardware tab.
- Select the virtual disk and click Disk Action > Resize.
- Specify the amount of space to add (e.g., 10 for 10 GB) and click Resize.
Step 2: Rescan the Disk in VM
SSH into your Ubuntu VM.
Use the lsblk command to verify the disk structure.
lsblk
- (Optional) Rescan the disk to detect the new size:
echo 1 > /sys/class/block/sda/device/rescan
Replace sda with the correct device name (e.g., vda for VirtIO disks).
- Verify the disk size has increased using:
fdisk -l
Step 3: Resize the Physical Volume
- Check the current volume group and logical volume structure:
vgdisplaylvdisplay
- Extend the physical volume to include the newly resized space:
pvresize /dev/sdaX
Replace /dev/sdaX
with the appropriate partition name.
Step 4: Extend the Logical Volume
- Use lvextend to extend the logical volume:
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
This command allocates all available free space to the logical volume.
Step 5: Resize the Filesystem
- Resize the filesystem to use the newly allocated space:
- For ext4:
resize2fs /dev/ubuntu-vg/ubuntu-lv
- For XFS:
xfs_growfs /dev/ubuntu-vg/ubuntu-lv
- Confirm the new size:
df -h
Optional: Verify Everything
- Check the logical volume and filesystem size:
lvdisplaydf -h
- Ensure the system is running without issues.
Summary
This procedure assumes that you are using Logical Volume Manager (LVM). If any step fails, please provide the error message below in the comments section.