Installing VirtualBox 5.1 on Fedora 257 February 2017 · Filed in Tutorial
Last fall, I wrote a piece about why I had switched to VirtualBox (from VMware Fusion) for my Vagrant needs. As part of my switch to Fedora Linux as my primary laptop OS, I revisited my choice of virtualization provider. I’ll describe that re-assessment in a separate post; the “TL;DR” for this post is that I settled on VirtualBox. As it turns out, though, installing VirtualBox 5.1 on Fedora 25 isn’t as straightforward as one might expect.
After a number of attempts (using a test VM to iron out the “best” procedure), here’s the process I found to be the most straightforward:
dnf upgradeto pick up the latest packages. If a new kernel version is installed, reboot. (I know this sounds contrived, but I’ve run into issues where some kernel-related packages aren’t available for the kernel version you’re actually running.)
Install the RPMFusion repos. You only really need the “free” repository, but you can install the “nonfree” as well if you like (it won’t affect this process). I won’t go through the process for how to do this; it’s really well-documented on the RPMFusion web site and is pretty straightforward.
dnfto install some prerequisite packages (note: On my installation of Fedora 25, almost all of these packages were already installed):
dnf install binutils gcc make patch libgomp glibc-headers glibc-devel
Now you’re going to install some kernel-related packages. I’m listing these separately because you want to pin the packages that get installed to the current kernel version you’re actually running (this sidesteps that issue I mentioned where the available packages don’t match the kernel version you’re running). I would imagine you could combine these into a single command, if you really wanted to. Here’s the additional packages:
dnf install "kernel-devel-`uname -r`" dnf install "kernel-headers-`uname -r`"
Now install the “akmods” package using
dnf install akmods. This will also install a number of dependencies.
Finally, you’re ready to install VirtualBox itself (note the case on these packages, they are case-sensitive):
dnf install VirtualBox akmod-VirtualBox
When this is complete, reboot your system to allow Linux to build and install the VirtualBox kernel modules it needs in order to run correctly. You may note that your next boot takes a bit longer; this is due to the kernel modules getting compiled and installed.
Note that a number of the articles I read on this topic recommended you install the “dkms” package (for dynamically rebuilding kernel modules when the kernel changes), but I found that to be counter-productive. For whatever reason, when you install the “dkms” package, Fedora also installs the debug symbols for the kernel sources. This messes up some paths, and then the kernel modules fail to build. A number of other tutorials recommended using the repository that VirtualBox maintains to distribute VirtualBox, but again I ran into problems with the kernel modules. Using the RPMFusion packages and “akmods” was the most straightforward method I found.
I hope this helps!Tags: CLI · Fedora · Linux · Virtualization Previous Post: Spousetivities at DockerCon 2017 Next Post: The Linux Migration: Virtualization Provider