Resize VM images in proxmox

When you really need to resize a VM disk image ( and free space to be allocated into partitions inside the vm) you might want to read this:

Step-by-step guide

  1. Poweroff you VM from proxmox
  2. Grow the disk allocation from proxmox GUIresize-proxmox
  3. Open a shell to proxmox and use parted to resize the partitions ( for qcow you might need to mount it first on nbd )
    root@proxmox:~# qemu-nbd -c /dev/nbd0 /mnt/pve/gogu/images/108/vm-108-disk-1.qcow2
    root@proxmox:~# parted /dev/nbd0
    (parted) p
    Model: Unknown (unknown)
    Disk /dev/nbd0: 82.9GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:
    Number  Start   End     Size    Type     File system  Flags
     1      1049kB  525MB   524MB   primary  ext4         boot
     2      525MB   42.9GB  42.4GB  primary               lvm
    (parted) resizepart 2 82.8G
    root@proxmox:~# nbd-client -d /dev/nbd0
  4. Power on the VM and login to it. Time to put the free space to good use.
    pvdisplay
    pvresize /dev/vda2
    lvextend -l +100%FREE /dev/mapper/vg_webtest01-lv_root
    resize2fs /dev/mapper/vg_webtest01-lv_root
    # In case of xfs use:
    # xfs_growfs /dev/mapper/centos_template-root
  5. Job done . Enjoy

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.