Here’s the scenario you may come across sooner or later.
You installed one or more operating systems in VirtualBox. While creating those virtual operating systems, you also created virtual hard disks for them in VirtualBox.
You specified the maximum size of the virtual disk to say 15 or 20 GB but now after using it for some time, you realize that your virtual machine is running out of space.
While there are ways to free up disk space on Ubuntu and other operating systems, a more robust way of handling the situation is to increase the disk size of your virtual machines created in VirtualBox.
Yes, you can enlarge the virtual hard disk in VirtualBox even after creation. Although this is a safe and tested procedure, it is highly recommended to create a backup of your virtual machine before you perform such an action.
How to enlarge VirtualBox disk size

I will show you how to resize disk in VirtualBox graphically and via command line (for Linux geeks). Both methods are easy and straightforward.
Method 1: Using the Virtual Media Manager in VirtualBox
VirtualBox 6 added a graphical option for resizing virtual disks. You can find it at the file tab of VirtualBox home page.
Go to File->Virtual Media Manager:

Select one of your virtual machines in the list and use the “Size” slider or type the size value that you need. Once done click “Apply”.

Keep in mind that though you increased the size of your virtual disk, the actual partition size remains the same if your space is dynamically allocated.
Method 2: Increase VirtualBox disk space using Linux command line
If you are using a Linux operating system as a host, open the terminal and type the following command to resize VDI:
VBoxManage modifymedium "/path_to_vdi_file" --resize <megabytes>
The resize process should finish right after you click the enter button to execute the command.
Note
The commands modifyvdi and modifyhd of earlier versions of VirtualBox commands are also supported and mapped internally to the modifymedium command.

If you are not sure where your virtual machines are saved, you can find the default location from the VirtualBox home page by clicking on Files -> Preferences or by using the keyboard shortcut Ctrl+G.

Conclusion
Personally, I prefer to use the terminal on every Linux distribution that I use for expanding disk, the graphical option is a very handy addition to the latest VirtualBox release.
This is an easy and quick tip but a great addition to VirtualBox fundamentals. If you find this tip useful, check out a few features of VirtualBox guest additions.
Basically the same problem as most of the comments mentioned. Increasing the available space doesn’t change the space available in the partition, and I can’t find a way to resize the partition while it is in use. This webpage is about the first part, which was easy enough to figure out even before I found the webpage.
The second part struggle was where I finally figured out that “disks” really means “gnome-disks” and also seems to be where everyone else is stuck. You cannot resize the active partition. So I’m looking for the easiest solution that is compatible with VirtualBox… The easiest I could imagine would be a version of the partition utility that creates a batch file that can run at boot time, unmounting the partition, resizing it, and remounting it. All of the other solution approaches would be some variation on accessing the VirtualBox virtual disk from somewhere else so that it can be resized…
I’ll look into it and see if the problem with the second part you mentioned can be fixed.
“Keep in mind that though you increased the size of your virtual disk, the actual partition size remains the same if your space is dynamically allocated.”
Well, that is my problem; cannot install software in guest OS because installation is checking remaining free disk space.
I did it using this tutorial: https://www.howtogeek.com/312456/how-to-convert-between-fixed-and-dynamic-disks-in-virtualbox/
Worked for me.
But in Linux it still appears to be the same size :-(
hi chris, I am facing same problem, do you got some solution?