VirtualBox Tips

There is a lot of installation guides and configuration suggestion dedicated to the VirtualBox. There are also many problems solved that can be easily found in your favorite search engine. So I will not make you bored and I not discuss a well-written installation and configuration which you will find in the official documentation. I will summarize instead what should be done after installing VirtualBox so as to avoid basic errors. I will also mention a few solutions that every VirtualBox user is looking for, sooner or later.


I wrote down the following steps to make it easier for myself to work with VirtualBox and not to wonder every time, why something does not work, just because I forgot about a few obvious settings.

Three simple steps

Do this after every Virtual Box installation on Linux host to make sure everything works correctly.

  1. Add user to vboxusers group on host machine and do the same on guest machine

    usermod -aG vboxusers username

    This change need log out and log in.

  2. Install Extension Pack.

  3. Install VirtualBox Guest Additions
    On guest machine install required packages

    sudo apt install build-essential dkms linux-headers-$(uname -r)

    then Insert Guest Additions CD and run as root ./

With above 3 suggestion you should not have any problems with shared folder access, usb devices, copy & paste between host & guest, graphics adjustment.

Reduce .vdi size

After some time, each VDI disk created with dynamically allocated space has the maximum size even though the system does not really occupy the entire virtual surface. It is worth then to compact its size. This method works only for VDI files.


On guest

Cleanup whole empty space by nullify free space:

dd if=/dev/zero of=/var/tmp/bigemptyfile bs=4096k ; rm /var/tmp/bigemptyfile

It can take some time.

On host

Use vboxmanage tool to compact disk

vboxmanage modifyhd /path/to/thedisk.vdi --compact


On guest

Run disk defragmentation.

Once done download SDelete tool and run it from command line with parameter:

sdelete.exe c: -z

replace c: with the drive letter of the VDI

On host

VBoxManage.exe modifyhd c:\path\to\thedisk.vdi --compact

Disk conversion

If you would like to compact your disk but its in VMDK format you can easily covert it to VDI.

VBoxManage clonehd "source.vmdk" "cloned.vdi" --format vdi

Just in case make a copy of drive before conversion.

Resize disk

In case where your virtual disk is out of space you can resize it. This method also works for VDI files only.

VBoxManage modifyhd "disk.vdi" --resize 51200

Resize value should be set to the new size of whole disk, not the amount of new space you want to add.

Next, on guest host resize partition using your favorite partition manager, for example Gparted.