Article: DKMS, systemd & Virtual Box - How to get Dynamic Kernel Module Support to work in openSUSE 12.3

I was trying to get **Dynamic Kernel Module Support **(DKMS) in openSUSE 12.3 to automatically run, reinstalling kernel modules each time you change the Linux kernel and could not get it to work properly. I have found out that in openSUSE 12.3, some startup scripts do not operate due to the usage of systemd. systemd really speeds up system startup by running the many startup processes in parallel and avoids the usage of shell scripts altogether. That is is good for speed, but not good if you are in need of running something in openSUSE as root when the system is restarted. You need to consider using this procedure if the following are true:

  1. You have installed openSUSE 12.3 and use systemd, the default.
  2. You have installed VirtualBox, any present version.
  3. You have (or want to) installed DKMS to auto update the VirtualBox kernel Modules.
  4. DKMS does not seem to be working for you when you reboot your PC after loading a new kernel.

DKMS should work with VirtualBox. reinstalling its kernel modules each time you update your kernel version and this works well in openSUSE 11.4. DKMS can be setup to work with other programs that also need to compile a kernel module against the present running kernel. You can install DKMS from YaST if you have added in the Packman repository. The problem with using DKMS in openSUSE 12.3, is that after it has been installed, the dkms_autoinstaller service is not being run at startup, apparently due to the usage of systemd. The dkms_autoinstaller bash script normally resides in the /etc/init.d folder and from the YaST / System / Run Level services, symbolic links are created in rcx folders, that represent the different run levels you want the service to use. However, DKMS was just not working, at least for me, so I have come up with a new plan of attack to get DKMS running properly in openSUSE 12.3 and the basics are as follows:

  1. I Disabled the /etc/init.d/dkms_autoinstaller in the system runlevel control (removes all symbolic links)
  2. Moved the dkms_autoinstaller bash script file to the /usr/sbin folder where the dkms binary file is located.
  3. Created a systemd service file called run_dkms.service in the folder /lib/systemd/system
  4. Ran the command systemctl enable /lib/systemd/system/run_dkms.service (which puts a symbolic link in /etc/systemd something)

So, if it sounds like you need to get DKMS working because it is installed and you are using VirtualBox, then continue reading on…

  1. First, we need to disable the dkms_autoinstaller runlevel service. Open up terminal and run the following command:
**sudo /sbin/chkconfig -d dkms_autoinstaller**
  1. Second, we need to move the dkms_autoinstaller script to its new location were the dkms binary file gets installed:
**sudo mv /etc/init.d/dkms_autoinstaller /usr/sbin/dkms_autoinstaller**
  1. Third we need to create the text file run_dkms.service (shown below) in the folder /lib/systemd/system as root:
 In KDE Alt-F2: **kdesu kwrite /lib/systemd/system/run_dkms.service**


 In GNOME Alt-F2: **gnomesu gedit /lib/systemd/system/run_dkms.service**

This is what you put into this file and save it:

#  This file is part of systemd.
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

Description=Update kernel modules

ExecStart=/usr/sbin/dkms_autoinstaller start


  1. Forth, we need to add the run_dkms.service to systemd. Open up a terminal session and run the following command:
**sudo systemctl enable /lib/systemd/system/run_dkms.service**
  1. Fifth, I have written the run_dkms.service file to look for and run a second bash script first, before the dkms_autoinstaller gets ran. I called this script userfix and placed it in the folder /usr/local/bin. To create this file, do the following:
 In KDE Alt-F2: **kdesu kwrite /usr/local/bin/userfix**


 In GNOME Alt-F2: **gnomesu gedit /usr/local/bin/userfix**

This is what you put into this file and save it:


#: Title       : /usr/local/bin/userfix
#: Date Created: 2-22-12
#: Last Edit   : 2-22-12
#: Author      : James D. McDaniel
#: Version     : 1.00
#: Description : Run User Pre-dkms Compile Commands
#: Options     : None

echo "User Fix File was Executed ..." 

# Place your user code here, to be run before dkms is run

exit 0

# End Of Script

  1. You need to make the /usr/local/bin/userfix bash script executable. Open up terminal and run the following command:
**sudo chmod +x /usr/local/bin/userfix**

The text editor commands shown here assume you are using either KDE, which is the default in openSUSE, or the GNOME desktop. The rest are assumed to be run in a terminal session. The sudo command is required to edit or create text files owned by root. You may not need to enter the root password every time depending on how quickly you proceed. Please let me know if you have any questions about using this procedure.

I Have incorporated my run_dkms & userfix scripts into the SASI (SuSE Automated Script Installer) which will automatically install the run_dkms & userfix scripts for you. Just copy and paste the following command into a terminal session:

**wget -nc -O  ~/bin/make-dkms-installer ; chmod +x ~/bin/make-dkms-installer ;  make-dkms-installer**

You can run the make-dkms-installer once and you will need to enter the root user password once as well. All steps listed above will be performed for you.

So who might want to install DKMS in openSUSE 12.3 and why? Again, DKMS is used to reinstall kernel modules, that must be compiled against the present running kernel. VirtualBox is one such example. Without DKMS or other such means, if you upgrade or replace your working kernel, VirtualBox will stop running until you run the command: sudo /etc/init.d/vboxdrv setup, but this step is not required if you have installed DKMS and of course my DKMS fix here.

Please let me know if you have any questions or problems.

Thank You,

For some strange reason, the “wget …” command only worked after the second invocation. Still, great job, James. Does this do the job for the NVIDIA driver too? If yes, how?

Yes it does. You have go and look at my SANDI bash script. wget is just a way to get the bash script from SuSE Paste, but it has seemed to work OK for me. Here is the article on SANDI:

And the Blog is here:, though they should be the same:

S.A.N.D.I. - SuSE Automated NVIDIA Driver Installer - Version 1.46 - Blogs - openSUSE Forums

I spent a lot of time working on this script. Now, with the nVIDIA driver 295.53 which will load into any kernel, up to 3.4, automatically. Now I always compile my own kernel and don’t spend that much time with standard kernels, but it should work if you have downloaded the kernel source files.

Thank You,

Thanks for the fix. Would be great if Packman would include it, as on 12.2 systemd is even more standard.
A question: What is your reason for including an “userfix” script?

At the time I made this dkms fix, you needed to copy some files in the kernel source files from one folder to another to allow the proprietary nVIDIA video driver to be compiled by dkms. Since there could be duties that need to be run before the dkms service is run, I added the userfix file and its a way to perform those needed tasks in front of running dkms at system startup time. By default, it does nothing but report it was run.

Since this would be a change to how the dkms package gets installed, it seems those that actually maintain dkms should make such a change, but I don’t claim to be the expert on that one. It is not a bug in dkms per say but an incompatibility with systemd in my estimation and whose fault is that really?.

Thank You,

Congrats on your thread, it’s the most explainable and complete I’ve found in the Internet so far, but the thing is, as an OpenSuse 12.3 user, even after following your step-by-step solution, I’m still receiving the “Kernel driver not installed (rc=-1908)” message whenever I try to run the Virtualbox. I’m actually trying to run in on a 64bit AMD Samsung notebook. Is there anything else I could do about it? Thanx

So you can run this terminal command to see what VirtualBox version is loaded:

rpm -q --all | grep "VirtualBox"

If VirtuaBox is installed, you can run this command to try and install the driver.

sudo /etc/init.d/vboxdrv setup

I would like to see the response to each command posted into a message here.

Thank You,

07:38 PM root:/etc/init.d/>rpm -q --all | grep "virtualbox"
07:39 PM root:/etc/init.d/>/etc/init.d/vboxdrv setup
Recompiling VirtualBox kernel module, NOT. It has been packaged.                                                                                      done
07:39 PM root:/etc/init.d/>uname -a
Linux 3.9.7-1.gfccf19c-desktop #1 SMP PREEMPT Thu Jun 20 19:39:05 UTC 2013 (fccf19c) x86_64 x86_64 x86_64 GNU/Linux
07:40 PM root:/etc/init.d/>modprobe vboxdrv
FATAL: Module vboxdrv not found.

that’s what I get - no dice, I suppose. (Running kernel from kernel-stable)

What should I be installing? Awesome thread and help, btw, thanks!

I installed the virtualbox from Oracle, stuff works fine now :wink:

Looks like that was simply what I missed… tnx!

Happy to help.

Thank You,