Skip to content

Instantly share code, notes, and snippets.

@Sy3Omda
Created November 9, 2024 18:02
Show Gist options
  • Save Sy3Omda/14addfe48feb75fe99a827a0fead0f43 to your computer and use it in GitHub Desktop.
Save Sy3Omda/14addfe48feb75fe99a827a0fead0f43 to your computer and use it in GitHub Desktop.

Create a Systemd Service File:

sudo nano /etc/systemd/system/vboxconfig.service
[Unit]
Description=VirtualBox Kernel Modules Setup
After=network.target

[Service]
ExecStart=/sbin/vboxconfig
Type=oneshot
RemainAfterExit=true

[Install]
WantedBy=multi-user.target

Enable and Start the Service:

sudo systemctl enable --now vboxconfig.service

OR

Run vboxconfig at Startup Using Cron

sudo crontab -e

@reboot /sbin/vboxconfig
sudo nano /etc/init.d/vboxconfig

#!/bin/sh
### BEGIN INIT INFO
# Provides:          vboxconfig
# Required-Start:    $network
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Run vboxconfig on startup
### END INIT INFO

/sbin/vboxconfig

OR

Use an Init Script (if init.d is Available)

sudo nano /etc/init.d/vboxconfig

#!/bin/sh
### BEGIN INIT INFO
# Provides:          vboxconfig
# Required-Start:    $network
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Run vboxconfig on startup
### END INIT INFO

/sbin/vboxconfig
sudo chmod +x /etc/init.d/vboxconfig
sudo update-rc.d vboxconfig defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment