Increase VirtualBox disk size

Let’s introduce how to increase the disk size of your Virtualbox virtual machine. That way, we can save our virtual machine if we need more space to install applications and our virtual machine has already reached its maximum disk utilization. 

I often hear questions like: 

My virtual machine is full, do I have to create a new virtual machine? 

The answer is no, you can increase the size of the virtual disk. 

Increasing VirtualBox Virtual Disk 

 New versions of VirtualBox have a feature called Virtual Media Manager. This functionality allows you to increase the size of the virtual disk in a simple and direct way. 

To do this, let’s access VirtualBox’s main screen and click on File. After that, let’s click on Virtual Media Manager, as shown in the figures below. 

Click File
Click File
 Select Virtual Media Manager
Select Virtual Media Manager

Now, let’s select the virtual machine disk that we want to grow. In this example, we are going to increase the size of the virtual disk of the “suricataIPStest” machine. We can see that the original size of the virtual disk was 10GB.

Select your virtual disk
Select your virtual disk

Now let’s increase the size of the virtual disk to 20GB.

Select the new size for the disk
Select the new size for the disk

If we start the virtual machine and check the disk size, we will verify that nothing has changed. That’s because, we still need to increase the size of the disk partition in order to be recognized. To check the size of the disk we are using the command “df -h”. However, we can use any other way of checking disk size.

Below we have the command to check the disk size and we can see that nothing has changed.

df -h

 Checking disk size inside virtual machine
Checking disk size inside virtual machine

Increasing disk partition

Now let’s shut down the virtual machine and download gparted. In this way, we are going to use gparted to increase our disk partition to be able to occupy the 20 GB.

First of all let’s go to the gparted website below and download the ISO.

https://gparted.org/download.php

 Select GParted .iso
Select GParted .iso

Adding Gparted ISO as Optical Disk

Now let’s add the gparted ISO image we just downloaded. To do this, we will access the virtual machine and click on Storage. In this way we will verify that there is a symbol of a CD ROM, let’s click on this symbol as shown in the figure below.

Click to select optical disk
Click to select optical disk

Now we have a screen to add the ISO we downloaded earlier. So let’s specify where the ISO is.

Click Add
Click Add
Select the gparted iso
Select the gparted iso

After choosing the ISO, let’s click on choose as shown in the figure below.

Select Choose
Select Choose

We can see that now the name of Gparted appears as one of the storage devices.

gparted.iso has been added
gparted.iso has been added

Starting the virtual machine

Now, let’s start the virtual machine.

Note. If necessary, press F12 to change the boot order of the virtual machine.

Select GParted Live
Select GParted Live
Keep kernel keymap
Keep kernel keymap

The figure below shows that we can specify the keyboard we want.

Keyboard language
Keyboard language
Select 0
Select 0

Increasing virtual disk partition

Next we will click on GParted and we will see the screen below. On this screen we have the disks of the virtual machine. In this way, we can observe that we have two divisions:

A partition of sda1 with fat32.

A partition of sda2 with (sda5 with ext4) and an unallocated part. Our goal is to increase the ext4 partition where our Linux system files are.

However, we need to use the amount of memory that has not yet been allocated. For this we will increase the size of the sda2 partition.

Our virtual disk
Our virtual disk

So, let’s right-click on the disk you want to increase in size. In our example the disk (sda2). Next, we’ll right-click and select the option to modify the size or move “Resize/Move”. 

Select the entire partition and click resize/move
Select the entire partition and click resize/move

Now we have a partition size configuration screen. Let’s pull the top bar until it occupies the full size of the partition. That way the new partition will now be 20486 in size. Next, let’s click on change the size “Resize/Move”. 

Choose the new size
Choose the new size

Now, let’s click on the icon in the figure below for the change to take place.

Apply the changes
Apply the changes

gparted will ask for our confirmation to continue performing the task. So, let’s confirm by clicking on apply “Apply”.

Confirm changes
Confirm changes
Operation completed
Operation completed

Increasing the file partition

Now, let’s enlarge the partition where our operating system files are. To do this, we’ll right-click on sda5 and click on modify size “Resize/Move”.

Resize the files partition
Resize the files partition

Again, we will have a screen similar to the one we saw before. And let’s pull the top bar to occupy the total available memory.

Details of the file partition
Details of the file partition

Now after increasing the size, let’s click on change size “Resize/Move”.

Select the new size for the file partition
Select the new size for the file partition

Again, let’s click on the icon in the figure below for the change to take place. And then we will confirm the operation by clicking “Apply”.

Click apply
Click apply
Confirm apply
Confirm apply

We can see that the operation took place satisfactorily as shown in the figure below.

Operation completed
Operation completed

Now we can exit gparted. Let’s click on the icon in the figure below.

 Quit GParted
Quit GParted

Deleting gparted disk from virtual machine

Now that we’ve done the procedure, we no longer need to keep the gparted disk attached to the virtual machine. Therefore, we can disconnect by clicking on the “gparted-live” disk and then clicking on the icon shown in the figure below.

Remove GParted. iso from VirtualBox
Remove GParted.iso from VirtualBox

After that, we will have a confirmation message and we will click on remove and then OK.

 Confirm Remove
Confirm Remove
 Click OK
Click OK

Testing the virtual machine size

Now let’s restart the virtual machine and check the disk size. If you are using Linux in the virtual machine, we can use the command below to check the new size of your disk.

df -h

 Check the new size
Check the new size

We can see in the figure above that our sda5 disk is now 20GB in size. Therefore, we concluded the operation satisfactorily. Therefore, we end this tutorial here.

Did you like the tutorial? Comment on our channel.

Other tutorials:

Juliana Mascarenhas

Data Scientist and Master in Computer Modeling by LNCC.
Computer Engineer