Skip to content

Increase VM Storage 💾

Expanding your storage of your Debian 12 VM requires resizing both the volume and the filesystem. This guide provides step-by-step instructions.

Prerequisites

  • Proxmox VE access with permissions to manage VMs.
  • VM running Debian 12 (documentation for other OS would be useful later on as well)
  • Root or sudo access inside the VM.
  • [recommended] Backup your VM or take a Proxmox snapshot.

1. Resize the Volume in Proxmox 🛠️

Follow these steps to increase the virtual machine's storage volume:

  1. Turn off the VM.
  2. Open Proxmox, and select your VM.
  3. Navigate to Hardware.
  4. Select Hard Disk.
  5. Click Disk actions → Resize.
  6. Enter the size increment, then click Resize disk.
  7. Turn on the VM.

2. Resize Storage Within the VM 🧩

Once the disk has been resized in Proxmox, additional steps are required inside the VM.

2.1 Modify the Partition Using cfdisk 🧱

  1. Open cfdisk:

    • Run the following command to see the free space allocated.
      sudo cfdisk
      
  2. Resize your main storage partition:

    • Select your storage partition (take note of the name, e.g. on my case it's /dev/sda3).
    • Select Resize (Set it to the TOTAL storage capacity you want, it should default to the max available storage).
    • Press Enter.
    • Select Write, type yes, and press Enter.
    • If you see The partition table has been altered, the process was successful.
    • Press q to exit cfdisk.

2.2 Resize the Physical Volume (pvresize) 📦

  1. Use pvresize to expand the partition.

    Storage Partition Path

    Storage partition paths vary; in this guide, we use /dev/sda3.

    Templated Command:

    sudo pvresize <partition-path>
    

    Example:

    sudo pvresize /dev/sda3
    

  2. Verify the changes:

    sudo vgdisplay
    

    • The Free PE / Size row should reflect the increased storage.

2.3 Extend the Logical Volume (lvextend) 🧮

  1. Find your <lv-path>:

    sudo lvdisplay
    

    • Look for LV Path, e.g., /dev/debian-test-vg/root.
  2. Extend the Logical Volume using lvextend.

    Logical Volume Path

    Logical Volume paths vary; in this guide, we use /dev/debian-test-vg/root.

    Templated Command:

    sudo lvextend -l +100%FREE <lv-path>
    

    Example:

    sudo lvextend -l +100%FREE /dev/debian-test-vg/root
    

  3. Verify the change:

    sudo lvdisplay
    

    • The LV Size should now reflect the increased storage.

2.4 Resize the Root Filesystem 🧬

  1. Identify the Logical Volume:

    sudo df -h
    

    • Look for your mounted logical volume, e.g., /dev/mapper/debian--test--vg-root.
  2. Resize the root filesystem:

    Logical Volume Path

    Logical Volume paths vary; in this guide, we use /dev/mapper/debian--test--vg-root.

    Templated Command:

    sudo resize2fs <logical-volume-path>
    

    Example:

    sudo resize2fs /dev/mapper/debian--test--vg-root
    

  3. Verify the new storage size:

    sudo df -h
    

    • The available storage should now be increased.

Awwww yeah!

🎉 Congratulations! 🎉

Your Debian 12 VM should now have successfully resized storage! 🚀