VirtualBox: How to solve the issue with low disk space

“Low Disk Space on Filesystem root” – this message turned up on my virtual machine of Ubuntu 20.04 that runs in VirtualBox 6.1 on Windows 10 host. This blog post contains a step-by-step guide how you can solve the issue with low disk space.

“Low Disk Space on Filesystem root” – message on Ubuntu 20.04

The problem with the low disc space occurred some days after I had installed Ubuntu 20.04 with some applications in VirtualBox and had done several upgrades. Unfortunately, 10 GB storage was too little. [1]

Tasks on the host system / VirtualBox

1. Create a backup of your virtual machine and/or maybe a clone because something can go wrong while enlarging the virtual disk image (vdi).

2. If you have snapshots, merge them by deleting or creating a clone of the current snapshot. Do the next steps with the cloned snapshot. This is the easiest way to only work on a virtual machine without any snapshots. If you want to face the snapshot challenge, you will find some blog posts about it. [2]

VirtualBox: Handle snapshots
VirtualBox: Handle snapshots

3. Open the Virtual Media Manager “File > Virtual Media Manager” and select the machine that size you want to enlarge. You can use the size slider to enlarge the size or the input field to change the value.

VirtualBox: Virtual Media Manager
VirtualBox: Virtual Media Manager and vdi-Location

4. Open the command line, e.g., Windows Command Prompt (enter “cmd” in the search) or Terminal (Linux, MacOS).

a. Set the path to VBoxManage to avoid the message “‘VBoxManage’ is not recognized as an internal or external command, operable program or batch file.” [3]

# Set path on Windows 10
# Unfortunately, I do not know whether you need 
# a similar command on other operating systems than Windows.
set PATH=%PATH%;"C:\Program Files\Oracle\VirtualBox"

b. Next, you need the folder path where your machine is stored which size you want to enlarge. You find the path in the Virtual Media Manager (see above), e.g. on Windows: “C:\Users…\Ubuntu 20.04 Clone\Ubuntu 20.04 Clone-disk1.vdi“.

c. Enter the following command in the command prompt or terminal to resize the vdi-file. [4]

# "VBoxManage modifymedium disk" is the command
# "20480" means 20.480 MB which are 20 GB [5]
VBoxManage modifymedium disk “your path” --resize 20480 
Windows Command Prompt
Windows Command Prompt: Set path and execute VBoxManage

Tasks on the guest system / VirtualBox

5. After that, you need to change the partition of Ubuntu 20.04 so that the system uses the free space. Therefore, you start the virtual machine and install “gparted“. [5]

sudo apt update
sudo apt install gparted

a. Start gparted, choose the light blue (outer) rectangle of the partition that you want to enlarge (here: /dev/sda2), click on the icon “resize/move“, and a popup appears. Resize the partition by using the slider or entering a value. Press the button “resize/move“.

b. Next, resize the dark blue (inner) rectangle of the partition (here /dev/sda5) in the same way.

gparted: Adjust the partitions
gparted: Adjust the partitions

6. Apply the changes, restart the virtual machine.

7. Check the result with “df -k“. As you can see around 50% of “/dev/sda5” is used because the vdi-size has been doubled.

Ubuntu: Check disk size
Ubuntu: Check disk size

Further information
[1] How To Enlarge a Virtual Machine’s Disk in VirtualBox or VMware
[2] VirtualBox: resize hard disk – with modifyhd and snapshots
[3] Solved: VBoxManage is not recognized
[4] Chapter 8. VBoxManage
[5] Gigabytes Conversion
[6] Install GParted in Ubuntu 20.04 LTS

Leave a Reply