[SOLVED] How to configure a cloned VM to automatically grow its root partition when the disk is extended?

Momedo

Member
Dec 7, 2021
6
0
6
Hello,

I am running a Proxmox VE server with pre-made Templates at minimal disk sizes. I have scripts that create VMs by cloning a template and extending its disk. The problem is that the extended space is not allocated to any mount point. For example, the following template has initially a disk of 12GB and the created VM has 70GB:
Code:
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   70G  0 disk
├─sda1   8:1    0  9.8G  0 part /
├─sda2   8:2    0  1.2G  0 part [SWAP]
└─sda3   8:3    0    1G  0 part /boot
sr0     11:0    1    4M  0 rom

I tried using Cloud-Init by adding the following snippet to my configuration but it doesn't seem to be doing anything:
Code:
growpart:
  mode: auto
  devices: ['/']
  ignore_growroot_disabled: false

Am I missing something? Is there a way to make the "/" mount point automatically grow to use the full available storage?

Thank you.
 
Temporary (?) Solution:
After multiple desperate tries, I managed to grow the root partition when it has the last sector. In my case it had to be sda3.

I'll mark this as solved but if anyone can confirm this or can provide a better solution that doesn't require a specific partitions' order, it would be greatly appreciated.
 
Is there any other proper solution.
@Momedo, what exactly steps you used here ?

PS: I realize its old thread but I am looking something exactly like this.