How to resize a VM partition over ssh

I’m trying to increase the size of my VM disk. I’ve only got access to the server and the vm that I want to resize over ssh without display, so I can’t use gparted. All guides point me to using the gparted gui. I’ve resized the vdi in phpvirtualbox, mounted it there. The vm runs fine, but the virtual size is now the desired 30GB, while the actual size is still 8GB. Thus, I should resize the partition, but I don’t know which partition contains the VM, and I cannot run gparted. How can I solve this problem?

I understand that this question is rather broad, but I’m still learning how this works, and will do my absolute best to answer all questions to make sure it boils down to a better question.

Thanks in advance