Gangmax Blog

Increase VirtualBox VDI Size

If you run Ubuntu in a VM hosted by VirtualBox, and you want to increase the disk space used by it, you can follow the instructions below.

  1. On host machine run the following commands to increase the disk file size.
1
2
3
4
#  Increase the disk file size.
VBoxManage modifymedium disk "/path/to/your-disk.vdi" --resize 40960
# Check the updated disk file size.
VBoxManage showmediuminfo "/path/to/your-disk.vdi"
  1. Run the following commands on the guest VM(Ubuntu) to make it use the increased disk.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Check the current disk info.
lsblk
sda 40G
├─sda1 1G
└─sda2 29G

# Install growpart if your Ubuntu OS uses a normal ext4 partition:
sudo apt update
sudo apt install cloud-guest-utils

# Grow the partition and expand the filesystem:
sudo growpart /dev/sda 2
sudo resize2fs /dev/sda2

# Verify.
df -Th

Done.

Comments