How to improve Linux performance in a VirtualBox VM
VirtualBox virtual machines are slow, thanks to the default VM configuration. If you use VirtualBox to run Linux, you may notice that performance isn’t great, and are looking for ways to improve it.
It is possible to improve your Linux VM’s performance by tweaking settings in VirtualBox. Follow along in this guide as we show you how to make your VirtualBox VM run better!
Looking for an alternative to VirtualBox? We’ve got a few suggestions.
Install Guest Additions
The first thing to do if you’re experiencing a slow VirtualBox virtual machine is to install Guest Additions. The reason? Guest Additions come with several VirtualBox enhancements, drivers, and improvements which can significantly improve the speed and responsiveness of your VM.
To get Guest Additions installed, start by launching your virtual machine and load it up into the operating system that is installed on it. Then, when the OS is running, press the Right Ctrl button to gain access to the Virtualbox VM controls.
Once you’ve pressed the Right Ctrl button, find the “Devices” menu and click on it with the mouse. From there, look for the “Insert Guest Additions CD image” and click it. Virtualbox will automatically download the Guest Additions ISO file, and insert it to your VM.
Note: if Virtualbox fails to download your ISO automatically, grab this ISO image and insert it into the VM by clicking on the CD icon, and selecting the “Choose disk image” button.
After inserting the Guest Additions ISO file, return to your Virtualbox VM, and open up a terminal window. To launch a terminal window in a Linux VM, press Left Ctrl + Shift + T or Left Ctrl + Alt + T. Then, with the terminal window open, use the CD command below.
cd /media/$USER/VBox_*
Or
cd /media/cdrom
Run the “autorun.sh” shell script in the Guest Additions directory.
sudo sh autorun.sh
Let the script install the VirtualBox Guest Additions into your VM. When the process is done, reboot the VM.
Increase cores in VM
Casual virtual box users who set up a Linux VM do not think about CPU cores. They go with the default setting of one core and then wonder why their VM is so slow. If you want to make it a little faster, change how many cores your VM can use.
To start, determine how many cores your host CPU has. You can find out this information by looking at your computer or CPU manual.
After determining how many cores you have on your host machine, read the list below to learn how many cores to give your VirtualBox VM.
- Host CPUs with 4 cores should use 2 cores.
- Host CPUs with 6 cores should use 2-4 cores.
- Host CPUs with 8-12 cores should use 4 cores or more.
Once you’ve determined how many cores to use, power down the VirtualBox VM, then, select it in the VirtualBox UI, right-click on it, and select the “Settings” option.
Inside of “Settings,” look for the “System” option and click on it with the mouse. After that, find the Processor tab.
Find the “Processor(s)” area, and drag the slider to the desired amount of cores. Click the “OK” button to save the settings.
Increase video memory allocation
The default video setting for VirtualBox is low. It only allows the Guest Operating system about 16 MB of video memory. If you’d like to improve the speed of the VM, increasing the video memory allocation is key.
To change the video memory allocation in a VirtualBox VM, do the following. First, shut off your VM. Then, right-click on it in the VirtualBox UI, bring up the right-click menu, and select the “Settings” option.
Inside settings, find “Display” and click on it with the mouse. Locate the “Video Memory” slider and set it to 128 MB. Then, click the “OK” button to apply the changes to your VM.
Increase virtual RAM
The amount of RAM selected by default on VirtualBox is pretty small. Roughly about 1024 MB. This amount is enough to run a basic Linux distribution, but if you want to do any serious work, the amount of RAM needs to be increased.
To increase virtual RAM in the VirtualBox app, close your VM and power it down. Then, right-click on it in the VBox UI, and select “Settings” in the right-click menu.
Inside of the “Settings” window, click on “System.” Then, locate the “Motherboard” tab and click it. From there, find “Base Memory” and drag the slider to your desired amount of RAM (at least 2-3GB).
After setting the virtual machine’s RAM to a higher amount, click the “OK” button to apply the changes.
Use a lightweight desktop in the VM
There are a lot of hardware changes to the VirtualBox that will improve the performance of your VM, and we’ve covered that in this article today. However, if your Linux VM is running slow, you should also consider the desktop environment you are running on it.
Out of the box, most Linux distributions use Gnome Shell or KDE Plasma. These desktops are very heavy, and not great for virtualization. Instead, consider installing a more lightweight desktop environment that uses much less system resources, and is more responsive in a VM, such as LXQt, XFCE4, Mate, or Enlightenment.