How to Set Up VirtualBox on Arch Linux

How to Set Up VirtualBox on Arch Linux

VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product that allows users to run multiple operating systems simultaneously on a single physical machine. For developers, testers, and Linux enthusiasts, it is a vital tool. While Arch Linux is a rolling release distribution and not officially supported by Oracle, setting up VirtualBox on Arch is still quite straightforward with a bit of attention to detail. This guide will walk you through installing and configuring VirtualBox on Arch Linux, covering common pitfalls and providing useful tips along the way.


1. Prerequisites

Before diving into the installation process, ensure you have the following:

  • A working Arch Linux system (fully updated).
  • sudo access or root privileges.
  • Linux kernel headers installed for your running kernel.
  • Secure Boot disabled (VirtualBox modules aren’t signed by default).
  • CPU virtualization (VT-x or AMD-V) enabled in BIOS/UEFI.

You can verify virtualization support with:

lscpu | grep Virtualization

If the output shows VT-x or AMD-V, you’re good to go.


2. Install Required Packages

VirtualBox is available in the official Arch Linux repositories. Depending on your kernel, you need to install appropriate modules.

Step 1: Update your system

sudo pacman -Syu

Step 2: Install Linux headers

For the default Arch kernel:

sudo pacman -S linux-headers

If you are using a different kernel (e.g., linux-lts), install the corresponding headers:

sudo pacman -S linux-lts-headers

Step 3: Install VirtualBox and modules

sudo pacman -S virtualbox virtualbox-host-modules-arch

Note: If you use a kernel other than the default (linux), replace virtualbox-host-modules-arch with virtualbox-host-dkms. For example:

sudo pacman -S virtualbox virtualbox-host-dkms

This will compile the necessary modules for your current kernel.


3. Load VirtualBox Kernel Modules

After installation, the kernel modules must be loaded for VirtualBox to function.

Step 1: Load modules manually

sudo modprobe vboxdrv
sudo modprobe vboxnetadp
sudo modprobe vboxnetflt

You can verify that the modules are loaded using:

lsmod | grep vbox

Step 2: Load modules at boot (optional)

To make sure the modules are loaded automatically on boot:

sudo nano /etc/modules-load.d/virtualbox.conf

Add the following lines:

vboxdrv
vboxnetadp
vboxnetflt

Save and exit (Ctrl+O, Enter, Ctrl+X).


4. Add Your User to the vboxusers Group

To run VirtualBox and access USB devices in guest systems, your user must be part of the vboxusers group.

sudo usermod -aG vboxusers $USER

Log out and log back in to apply the group membership.


5. Enable and Start VirtualBox Services (Optional)

For certain features like host-only networking or bridged networking, starting the VirtualBox services may be necessary.

Host-only networking service

sudo systemctl enable vboxweb.service
sudo systemctl start vboxweb.service

This service is especially useful if you’re managing VMs remotely via the web interface.


6. Install the Extension Pack (Optional)

The VirtualBox Extension Pack adds features such as USB 2.0/3.0 support, RDP, disk encryption, and NVMe support.

Since the official Oracle Extension Pack is not in the Arch repositories (due to licensing), you need to download and install it manually.

Step 1: Download the Extension Pack

Visit the Oracle VirtualBox Download Page and download the extension pack that matches your VirtualBox version.

Step 2: Install the Extension Pack

sudo VBoxManage extpack install ~/Downloads/Oracle_VM_VirtualBox_Extension_Pack-*.vbox-extpack

Accept the license when prompted.

To check that the extension is installed:

VBoxManage list extpacks

7. Create and Manage Virtual Machines

Once installed, you can launch VirtualBox from your application menu or via terminal:

virtualbox

Steps to create a VM

  1. Click “New”.
  2. Name your VM and select the OS type (e.g., Ubuntu, Windows, etc.).
  3. Allocate memory (RAM) size.
  4. Create a virtual hard disk (VDI, VMDK, etc.).
  5. Configure CPU, graphics, and network settings under Settings before starting the VM.

You can also manage VMs from the command line using VBoxManage. For example:

VBoxManage createvm --name "UbuntuTest" --register
VBoxManage modifyvm "UbuntuTest" --memory 2048 --acpi on --boot1 dvd --nic1 nat

8. Troubleshooting Common Issues

VirtualBox fails to start a VM with VERR_VM_DRIVER_NOT_INSTALLED

  • This usually means the kernel modules are not loaded. Load them manually:
sudo modprobe vboxdrv

Or, if using DKMS:

sudo dkms autoinstall

USB Devices not recognized in guest

  • Ensure the Extension Pack is installed.
  • Add your user to the vboxusers group.
  • Enable USB support under the VM’s Settings > USB.

Kernel update broke VirtualBox

If you recently updated the kernel, you may need to rebuild the VirtualBox kernel modules:

sudo dkms autoinstall

Or reinstall the virtualbox-host-modules-arch package.


9. Tips for Better Performance

  • Enable VT-x/AMD-V and Nested Paging in the VM settings.
  • Install Guest Additions on your guest OS to enable better graphics, clipboard sharing, and drag-and-drop.
  • Use Fixed-size virtual disks instead of dynamically allocated for better I/O performance.
  • Allocate enough CPU cores and RAM without starving your host system.
  • Use Bridged Adapter for networking if you want the VM to appear as a separate device on the LAN.
  • Enable 3D Acceleration for better graphics performance in guest systems.

10. Conclusion

Setting up VirtualBox on Arch Linux is a relatively simple process, especially when you understand the role of kernel modules and user permissions. Thanks to the Arch User Repository (AUR) and the official repos, you can access not only the main VirtualBox application but also important extensions and DKMS support for custom kernels. Whether you’re testing operating systems, building isolated dev environments, or learning about networking, VirtualBox offers a flexible and powerful solution.

Always keep your system updated and remember to recompile modules if you update your kernel. With careful setup and maintenance, VirtualBox on Arch Linux can be a dependable tool for your daily virtualization needs.