I installed virtualbox recently, works fine but I have to load three modules before I start it.
I know I could
1. Use rc-update to make them start on boot.
2. make a script to start the modules first (leaning towards this one)

However I am curious of there is a better way to do it. I do not want them to stay in memory when I'm not running VBox. Is there an option with rc-update, or something else to only load them at runtime, and then unload them when the program terminates.

Why wouldn't you just list the modules in /etc/conf.d/modules ? Then they get loaded at the boot runlevel, and will be there whenever you start up VirtualBox.

This is just the recommendation in the VirtualBox ebuild.

I don't doubt it but I like to keep a slim build. My is really fast and I'd rather not slow it down with excess modules. The VBox modules alone occupy nearly three times as much as all my other modules put together.

If nothing else, I guess I'll go with a script. I was hoping there was something already implemented to streamline this.
.

Why wouldn't you just list the modules in /etc/conf.d/modules ? Then they get loaded at the boot

Does not work using init systemd. But I guess this would work (not tried):
/usr/lib/modules-load.d

But we have often heard the years: Sometimes virtualbox modules do have bad quality!
If you have problems with your system, it would be preferable to not have loaded these modules:
You can deny your problems spur from these modules.

As virtualbox is setting up his own group and it is suggested to add a using account to this group, why not add in /etc/sudoers:

Code:

%vboxusers ALL=(ALL) NOPASSWD: /usr/local/sbin/vboxmodules

where these modules are loaded without password when:
sudo /usr/local/sbin/vboxmodules