VirtualBox dynamic disk not expanding to Virtual Size

I fixed my VirtualBox machine by setting the path on Windows 7 host machine to include the VirtualBox install directory (Steps):

  1. click start button
  2. Right click computer
  3. Click Properties
  4. Click Advanced System Settings
  5. On [Advanced] tab click [Environment Variables] button
  6. Under System Variables, scroll down to path and click [Edit]
  7. Add everything in quotes to end of line ";C:\Program Files\Oracle\VirtualBox\"
  8. Click [Ok]

Next move to the directory of the VirtualBox Disk (under username\VirtualBox VMs) taken from (https://forums.virtualbox.org/viewtopic.php?f=7&t=52351)

  1. open cmd and move to the VirtualBox drive
  2. enter this command: VBoxManage showhdinfo
  3. Take note of the UUID of the disk.
  4. enter this command: VBoxManage modifyhd UUID_of_the_VDI_disk --resize 80000 (this makes the disk 80 gigs, adjust to the size you want)

IMPORTANT STEPS START HERE: Next boot the Virtual machine on LiveCD (Install disk) (taken from Extending Ubuntu Partition size with the unallocated space (swap is between these two))

I can't stress this enough:

It is highly recommended to backup any important files before doing resize/move/extend operations.

The way to do it, is by deleting the swap partition, extend the partition that you want, and then re-create the swap partition.

Swap partition can only be deleted after swap is turned off:

SWAP off: sudo /sbin/swapoff -a SWAP on: sudo /sbin/swapon -a

The steps:

  1. Boot from the Ubuntu LiveCD
  2. Open terminal, and turn swap off
  3. Install GParted
  4. Extend the partiton that you want, but leave space for swap
  5. commit the changes
  6. create swap partition
  7. turn swap on

Note: If your swap is not your primary hard drive, then see SwapFaq on how to activate the swap partition

It is highly recommended to backup any important files before doing resize/move/extend operations.


Had the same problem on Ubuntu 15.04 running Ubuntu Gnome 15.04 in a Virtual Machine. It seems that despite it being 'Dynamically allocated storage' VirtuaBox wasn't increasing it and I was down to my last 100MB and it wouldn't let me update via Software Updates. The solution was to perform the update via the terminal.

sudo apt-get upgrade

This seemed to force VirtualBox to create the additional storage, it jumped up to 500MB free as soon as the update started.


VirtualBox Dynamic Disk Not Utilizing Available Free Disk Space to Grow Partition Automatically

This post was written for Ubuntu Server 18.04 Guest OS running on Virtualbox 6.1.6.

I believe that the correct description to this problem should be something along the lines of this:

"Although a 32GB dynamic disk was created, the OS partition hit a "disk full" message at around 4GB and wasn't able to automatically increase its size by utilizing the "free" 28GB from the 32GB dynamic disk."

If this is the problem you encountered, and you had setup the Guest OS using Ubuntu Linux and LVM (and EXT4 filesystem), then the solution to this problem is to use lvextend and resize2fs commands. See my solution and description below:

Start up the VM and login. Once in, open up a terminal.

  1. Display information about allocated disk storage:

    $ df -h

    Filesystem Size Used Avail Use% Mounted on
    udev 966M 0 966M 0% /dev
    tmpfs 200M 1.1M 199M 1% /run
    /dev/mapper/ubuntu--vg-ubuntu--lv 3.9G 2.9G 835M 78% /
    tmpfs 997M 0 997M 0% /dev/shm
    tmpfs 5.0M 0 5.0M 0% /run/lock
    tmpfs 997M 0 997M 0% /sys/fs/cgroup
    /dev/loop0 97M 97M 0 100% /snap/core/9436
    /dev/loop1 97M 97M 0 100% /snap/core/9665
    /dev/sda2 976M 212M 697M 24% /boot
    tmpfs 200M 0 200M 0% /run/user/1000

The output shows the root partition (/) has a size of 3.9G and that 2.9G (78%) is used.

  1. Display information on block devices:

    $ lsblk

    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    loop0 7:0 0 96.5M 1 loop /snap/core/9436
    loop1 7:1 0 97M 1 loop /snap/core/9665
    sda 8:0 0 32G 0 disk
    ├─sda1 8:1 0 1M 0 part
    ├─sda2 8:2 0 1G 0 part /boot
    └─sda3 8:3 0 31G 0 part
    └─ubuntu--vg-ubuntu--lv 253:0 0 4G 0 lvm /
    sr0 11:0 1 1024M 0 rom

The output shows that block device sda has a physical size of 32GB. It contains 3 partitions (sda1, sda2 and sda3). The root partition (/) mounted on the logical volume of sda3 only has 4GB allocated storage. This means that there is still approximately 27GB of unallocated (free) storage that we can use to grow the LVM's logical volume.

  1. Display filesystem information on the block devices:

    $ lsblk --fs

    NAME FSTYPE LABEL UUID MOUNTPOINT
    loop0 squashfs /snap/core/9436
    loop1 squashfs /snap/core/9665
    sda
    ├─sda1
    ├─sda2 ext4 7cafee4a-d300-4b17-957d-c822c73882fc /boot
    └─sda3 LVM2_member GwPZus-EMpD-BgZw-e1Nx-Fd9J-LLeN-XnbvEE └─ubuntu--vg-ubuntu--lv ext4 dcc015b4-b6b8-4e05-9a18-93c263cc05ed /
    sr0

    The output shows that filesystem of the lvm root partition is ext4.

  2. Display information about physical volume:

    $ sudo pvs

    PV VG Fmt Attr PSize PFree
    /dev/sda3 ubuntu-vg lvm2 a-- <31.00g <27.00g

    $ sudo pvdisplay

    --- Physical volume --- PV Name /dev/sda3
    VG Name ubuntu-vg
    PV Size <31.00 GiB / not usable 0
    Allocatable yes
    PE Size 4.00 MiB
    Total PE 7935
    Free PE 6911
    Allocated PE 1024
    PV UUID GwPZus-EMpD-BgZw-e1Nx-Fd9J-LLeN-XnbvEE

    The output provides another perspective on the allocated / unallocated space on LVM PV sda3.

  3. Display information about volume group:

    $ sudo vgs

    VG #PV #LV #SN Attr VSize VFree
    ubuntu-vg 1 1 0 wz--n- <31.00g <27.00g

    $ sudo vgdisplay

    --- Volume group --- VG Name ubuntu-vg
    System ID
    Format lvm2
    Metadata Areas 1
    Metadata Sequence No 2
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 1
    Open LV 1
    Max PV 0
    Cur PV 1
    Act PV 1
    VG Size <31.00 GiB
    PE Size 4.00 MiB
    Total PE 7935
    Alloc PE / Size 1024 / 4.00 GiB
    Free PE / Size 6911 / <27.00 GiB
    VG UUID vBmSeb-VWR8-7A8n-CBSa-UnKd-FmJG-LTtMUG

    The output shows that the VG size is the same as the PV size (31GB), and that it has 27GB of unallocated free storage to grow the logical volume.

  4. Display information about the logical volume:

    $ sudo lvs

    LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
    ubuntu-lv ubuntu-vg -wi-ao---- 4.00g

    $ sudo lvdisplay

    --- Logical volume ---
    LV Path /dev/ubuntu-vg/ubuntu-lv
    LV Name ubuntu-lv
    VG Name ubuntu-vg
    LV UUID pnvBcu-FnfT-c3RY-cYCE-AuMX-f833-57WvYi
    LV Write Access read/write
    LV Creation host, time ubuntu-server, 2020-07-01 00:00:58 +0000
    LV Status available
    #open 1
    LV Size 4.00 GiB
    Current LE 1024
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    -currently set to 256
    Block device 253:0

    The output shows that the LV size is 4GB. Since the VG size is 31GB, we can grow the LV by another 27GB.

7a. To grow the logical volume (ubuntu-lv) by using 50% (13GB) of the free unallocated space, first do:

$ sudo lvextend -l+50%free /dev/ubuntu-vg/ubuntu-lv

Size of logical volume ubuntu-vg/ubuntu-lv changed from 4.00 GiB (1024 extents) to 17.50 GiB (4480 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.


The output shows that the logical volume has grown from 4GB to 17.5GB (approximately 13GB).

7b. Finally, to let the EXT4 filesystem become aware of the expanded storage, run command:

$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 4587520 (4k) blocks long.
  1. Display information about allocated disk storage again to check the new disk storage space:

    $ df -h

    Filesystem Size Used Avail Use% Mounted on
    udev 966M 0 966M 0% /dev
    tmpfs 200M 1.1M 199M 1% /run
    /dev/mapper/ubuntu--vg-ubuntu--lv 18G 2.9G 14G 18% /
    tmpfs 997M 0 997M 0% /dev/shm
    tmpfs 5.0M 0 5.0M 0% /run/lock
    tmpfs 997M 0 997M 0% /sys/fs/cgroup
    /dev/loop0 97M 97M 0 100% /snap/core/9436
    /dev/loop1 97M 97M 0 100% /snap/core/9665
    /dev/sda2 976M 212M 697M 24% /boot
    tmpfs 200M 0 200M 0% /run/user/1000

    The output shows that the size of the logical volume has now grown to 18GB (from its earlier 4GB)


/tmp is going to be a tmpfs - i.e. a filesystem stored in RAM. So unless you assigned you have ~800MB free RAM in your VM, it isn't going to be enough to hold the ISO.

This is probably not what you intended: just save the ISO in a 'real' directory (e.g. /home/<username>) and it should work just fine.