disclaimer: answer most likely applicable only for distros using logical volume management like rhel for which the following use case applies:
I have been using the official Red Hat Enterpise 7.2 vagrant box officially provisioned by red hat.
(you will need a rhel developer account which you can create for free)
Upon installation I was troubled by the fact that only 8GB were also available:
sudo df -h
[vagrant@rhel-cdk ~]$ sudo df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-root 8G 2,5G 6,5G 28% /
devtmpfs 234M 0 234M 0% /dev
tmpfs 245M 0 245M 0% /dev/shm
tmpfs 245M 4,3M 241M 2% /run
tmpfs 245M 0 245M 0% /sys/fs/cgroup
/dev/sda2 297M 134M 164M 45% /boot
tmpfs 49M 0 49M 0% /run/user/1000
And as you can see most of the space had already been consumed by the rhel installation.
However I discovered that the volume group corresponding to the /dev/mapper/VolGroup00-root
fileystem did have extra space (which I suppose in terms of virtual box was dynamicaly allocated)
sudo vgdisplay VolGroup00
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 11
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 39,70 GiB
PE Size 4,00 MiB
Total PE 10164
Alloc PE / Size 7872 / 30,75 GiB
Free PE / Size 2292 / 8,95 GiB
VG UUID JBVwpl-13KX-HbQw-FqUa-CA9w-swpF-dF6glm
So the only things remaining to be done were to:
a) Increase the size of our logical volume by say 10G
sudo lvextend -L+10G /dev/VolGroup00/root
and
b) Update your root filesystem so that it becomes aware of this change
sudo xfs_growfs /dev/mapper/VolGroup00-root
(pls note that at least for rhel 7.2 resize2fs
will not work for the this purpose).
After that, additional space was available to my filesystem:
sudo df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-root 18G 2,5G 16G 14% /
devtmpfs 234M 0 234M 0% /dev
tmpfs 245M 0 245M 0% /dev/shm
tmpfs 245M 4,3M 241M 2% /run
tmpfs 245M 0 245M 0% /sys/fs/cgroup
/dev/sda2 297M 134M 164M 45% /boot
tmpfs 49M 0 49M 0% /run/user/1000
... no intervention on virtualbox level