Skip to content

Commit

Permalink
added documentation for setting up vbox on fedora
Browse files Browse the repository at this point in the history
  • Loading branch information
olwalkey committed Aug 22, 2024
1 parent 422f9f8 commit 08e028b
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions VirtualBoxSetup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# How to Setup VirtualBox on Different Systems

> [!IMPORTANT]
> If you Know how to setup virtualbox on A system that isn't in this list
> please make a pr with steps on how to

## Fedora 40

There are multiple options when it comes to Installing Vbox on Fedora,

- Option 1: Disable Secure Boot

If you go with Option 1, all you have to do is reboot your computer,
go into the bios and disable secure boot

- Option 2: Self Sign Certificates

Option 2 Is a little more involved, it will also require you run a
script after each major system update.

- Make sure you system is up to date
`sudo dnf update`

- Install mokutil
`sudo dnf install mokutil`

- Create RSA key in new folder
``` bash
sudo -i
mkdir /root/signed-modules
cd /root/signed-modules
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"
chmod 600 MOK.priv
```
- Initialize mokutil
This command will ask for a pasword, make sure it's something you know
as you will be asked it the next time you reboot your system
> [!IMPORTANT]
> It only asks on the next boot after this command is run, no other times
`sudo mokutil --import MOK.der`

- Reboot System
> [!IMPORTANT]
> Once you reboot your system you will get
> a blue screen where it asks if you want to initialize mok
> Click it then go to `Enroll mok`->`continue`->`Input Password`
> The password will be whatever you set it to in the last step
- Make a new bash script so that you can run these commands after a major update
```bash
#!/bin/bash

sudo -i
mkdir /root/signed-modules
cd /root/signed-modules
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"
chmod 600 MOK.priv

sudo mokutil --import MOK.der
```

- Create a Script to sign Certificates
`cd /root/signed-modules`
Using whatever code editor you use, go to the following file
`nvim sign-virtual-box`

```bash
#!/bin/bash

for modfile in $(dirname $(modinfo -n vboxdrv))/*.ko; do
echo "Signing $modfile"
/usr/src/kernels/$(uname -r)/scripts/sign-file sha256 \
/root/signed-modules/MOK.priv \
/root/signed-modules/MOK.der "$modfile"
done
```

> [!TIP]
> Should this script fail when you run it, you can use the following command
> to ensure file paths are correct
> `find /usr/src -name sign-file`
- Run file
We're going to add exec permissions to the file and run it
`chmod 700 sign-virtual-box`
`./sign-virtual-box`
- Launch Virtualbox
`modprobe vboxdrv`

And that should be it, you should have virtualbox on your system, in order to tell vagrant to use virtuablbox though,
you need to go to your enviroment file which is located at `~/.bashrc` if your using bash or `~/.zshrc` if your using zsh
and add this

`export VAGRANT_DEFAULT_PROVIDER=virtualbox`

0 comments on commit 08e028b

Please sign in to comment.