Installing VirtualBox 6.1 on Fedora 33
Tags: virtualbox, fedora, tutorial, linux
Published: 2021-01-16 11:45:37

I recently changed Centos 8 for Fedora due some issues my Server has with Storage drivers (my old Dell Raid drivers are not longer supported in Centos 8, so any update was a bit of a nightmare...)

Since I wanted to try to use Vagrant with VirtualBox, I tried to install it without checking much, until I realised there is not VirtualBox support for Fedora 33 yet.

I found couple of guides to get it done though:
[VirtualBox 6.1 on Fedora 33/32, CentOS/RHEL 8.2/7.8](https://www.if-not-true-then-false.com/2010/install-virtualbox-with-yum-on-fedora-centos-red-hat-rhel/) 
[Install VirtualBox 6.1 on Fedora 33](https://kifarunix.com/install-virtualbox-6-1-on-fedora/)

Both of them are very similar, and in both of them, you need to modify the RPM in order to change the default Python VirtualBox try to use.

However, that is not the only issue you could face, so I decided to post this in order for me to remember for next time, but I'm sure next time I try to install VirtualBox, we will have Fedora 33 support :)

The first I need to do is to disable libvirt to avoid any conflict and Update all packages (this was actually "a mistake" in my case, but nothing that can not be resolved)
```bash
|=| server in ~ ○ → sudo systemctl stop libvirtd-admin.socket
|=| server in ~ ○ → sudo systemctl stop libvirtd.socket
|=| server in ~ ○ → sudo systemctl stop libvirtd-ro.socket
|=| server in ~ ○ → sudo systemctl stop libvirtd
|=| server in ~ ○ → sudo systemctl disable libvirtd

|=| server in ~ ○ → sudo su -
[root@server ~]# dnf update
Last metadata expiration check: 0:20:58 ago on Fri 15 Jan 2021 15:49:20 GMT.
Dependencies resolved.
Nothing to do.
Complete!
```
Following the Guides mentioned earlier, we can get the VirtualBox RPM modified for Fedora 33 and ready to work
```bash
[root@server ~]# dnf install rpmrebuild
[....]
[root@server ~]# cd /tmp && wget http://download.virtualbox.org/virtualbox/rpm/fedora/32/x86_64/VirtualBox-6.1-6.1.16_140961_fedora32-1.x86_64.rpm
--2021-01-15 16:12:37--  http://download.virtualbox.org/virtualbox/rpm/fedora/32/x86_64/VirtualBox-6.1-6.1.16_140961_fedora32-1.x86_64.rpm
Resolving download.virtualbox.org (download.virtualbox.org)... 23.217.4.135
[....]
[root@server tmp]# rpmrebuild --change-spec-preamble='sed -e "s/6.1.16_140961_fedora32/6.1.16_140961_fedora33/"' --change-spec-requires='sed -e "s/python(abi) = 3.8/python(abi) >= 3.8/"' --package VirtualBox-6.1-6.1.16_140961_fedora32-1.x86_64.rpm
(GenRpmQf) remove tag line ENHANCESFLAGS
(GenRpmQf) remove tag line ENHANCESNAME
[....]
[root@server tmp]# dnf install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms qt5-qtx11extras libxkbcommon
[....]
[root@server tmp]# dnf install ~/rpmbuild/RPMS/x86_64/VirtualBox-6.1-6.1.16_140961_fedora33-1.x86_64.rpm
[....]
[root@server tmp]# usermod -a -G vboxusers solifugo
[root@server tmp]# su - solifugo
|=| server in ~ ○ → sudo reboot
```
After VirtualBox was installed and I rebooted the system, I found the following errors when tried to build the Kernel Modules in my current Kernel ***5.10.6-200.fc33.x86_64*** (the new Kernel was one of the consequences of "dnf update" execution I did earlier)
```bash
|=| server in ~ ○ → VirtualBox
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (5.10.6-200.fc33.x86_64) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /sbin/vboxconfig

         You will not be able to start VMs until this problem is fixed.
Qt WARNING: could not connect to display
Qt FATAL: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted (core dumped)

|=| server in ~ ○ →

|=| server in ~ ○ → sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: Look at /var/log/vbox-setup.log to find out what went wrong.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.  If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.

|=| server in ~ ○ →

```
The Log file was not very helpful to me, and reading around, and since VirtualBox has not support for Fedora 33 yet, I figured there is not support for new Kernel either
```bash
## Log file
Building the main VirtualBox module.
Error building the module:
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/5.10.6-200.fc33.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j24 modules
make[1]: warning: -j24 forced in submake: resetting jobserver mode.
make -f ./scripts/Makefile.build obj=/tmp/vbox.0 \

```

At the end, I changed the grub2 default kernel and that made possible to get the Kernel modules set for previous version Kernel
```bash
|=| server in ~ ○ → sudo grubby --info=ALL |egrep -i 'index|title'
index=0
title="Fedora (5.10.6-200.fc33.x86_64) 33 (Server Edition)"
index=1
title="Fedora (5.9.16-200.fc33.x86_64) 33 (Server Edition)"
index=2
title="Fedora (5.8.15-301.fc33.x86_64) 33 (Server Edition)"
index=3
title="Fedora (0-rescue-eeb04d2dc1b443f59d24a68f801e7ee6) 33 (Server Edition)"

|=| server in ~ ○ → sudo grubby --default-index
0

|=| server in ~ ○ → sudo grubby --set-default-index=1
The default is /boot/loader/entries/eeb04d2dc1b443f59d24a68f801e7ee6-5.9.16-200.fc33.x86_64.conf with index 1 and kernel /boot/vmlinuz-5.9.16-200.fc33.x86_64



|=| server in ~ ○ → sudo grubby --default-index
1

|=| server in ~ ○ → sudo reboot


|=| server in ~ ○ → uname -a
Linux server.localdomain 5.9.16-200.fc33.x86_64 #1 SMP Mon Dec 21 14:08:22 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

|=| server in ~ ○ → sudo /usr/lib/virtualbox/vboxdrv.sh setup
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.

|=| server in ~ ○ → VirtualBox

|=| server in ~ ○ →
```

![VirtualBox Running](https://dev-to-uploads.s3.amazonaws.com/i/y6atg52be6imewmpr7xn.png)

Like I mentioned, I'm sure new VirtualBox version will start supporting Fedora 33 and latest Kernel versions, but until then, make sure you check compatibility before migrating to new Linux Distributions :)