I've been building a couple of Vagrant boxes for the VMware provider this last couple of days. Despite the VMware tools being loaded into the VMs (both RHEL and CentOS) the vmhgfs module wouldn't load at boot, thus Vagrant wouldn't work properly.

There is a correct, and neat, way to load kernel modules persistently on RHEL-based distros - add a file called WHATEVER.modules to /etc/sysconfig/modules/, make it a script, and it will be called by rc.sysinit during boot.

I'd done this, but vmhgfs still wasn't loading, and I couldn't understand why. Then the penny dropped - rc.sysinit is happening very early in the init process, before the filesystems are mounted.

Now, for modules, this shouldn't be an issue - assuming the module is in the initrd, that is. And I don't think vmhgfs is, for the boxes I've built.

So, I came up with a quick hack. Drop the for and test from rc.sysinit into rc.local. Sorted!

# placed because vmhgfs isn't in initrd, so running from rc.sysinit is
# too early
# Load other user-defined modules
for file in /etc/sysconfig/modules/*.modules ; do
  [ -x $file ] && $file


comments powered by Disqus