OpenWrt Forum Archive

Topic: module-init-tools package

The content of this topic has been archived on 1 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have a 100% untested module-init-tools (insmod, modprobe, depmod, etc) package.  It is ONLY for 2.6 kernels.  2.4 kernels use modutils.

package/module-init-tools/Makefile

include $(TOPDIR)/rules.mk

PKG_NAME:=module-init-tools
PKG_VERSION:=3.2
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/
PKG_MD5SUM:=87e8f8681dd53cbc41375a91c595c907

include $(INCLUDE_DIR)/package.mk

define Package/module-init-tools
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=Linux module utilities
  URL:=http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/
  DEPENDS:=
endef

define Package/module-init-tools/install
        install -m0755 -d $(1)/sbin
        install -m0755 $(PKG_BUILD_DIR)/depmod $(1)/sbin/
        install -m0755 $(PKG_BUILD_DIR)/lsmod $(1)/sbin/
        install -m0755 $(PKG_BUILD_DIR)/rmmod $(1)/sbin/
        install -m0755 $(PKG_BUILD_DIR)/insmod $(1)/sbin/
        install -m0755 $(PKG_BUILD_DIR)/modinfo $(1)/sbin/
        install -m0755 $(PKG_BUILD_DIR)/modprobe $(1)/sbin/
        install -m0755 $(PKG_BUILD_DIR)/depcomp $(1)/sbin/
endef

$(eval $(call BuildPackage,module-init-tools))

SINCE THIS IS A MAKEFILE, LOTS OF SPACES MUST BE A TAB.

To use it, check out OpenWRT and put it in here: package/module-init-tools.

Maybe a developer will add it.

The binaries seem to work, but the ones busybox provides need to be omitted.

depmod (with no parameters) should be run on completion.

Since you'll probably use modprobe with this, /etc/modules needs to be created, and in init script is needed.

Based off the Debian script:
/etc/init.d/module-init-tools
/etc/rc.d/S11module-init-tools -> /etc/init.d/module-init-tools

#!/bin/sh /etc/rc.common

#Modules are typically loaded at 10
START=11

start() {
    # Silently exit if the kernel does not support modules or needs modutils.
    [ -f /proc/modules ] || exit 0
    
    # ksyms on 2.4, not 2.6
    [ ! -f /proc/ksyms ] || exit 0
    [ -x /sbin/modprobe  ] || exit 0
    
    PATH="/sbin:/bin"
    
    KVER=$(uname -r)
    KMAJ=${KVER%${KVER#*.*[^.]}}
    KMAJ=${KMAJ%.}
    
    if [ -e /etc/modules-$KVER ]; then
      MODULES_FILE=/etc/modules-$KVER
    elif [ -e /etc/modules-$KMAJ ]; then
      MODULES_FILE=/etc/modules-$KMAJ
    else
      MODULES_FILE=/etc/modules
    fi
    
    load_module() {
      local module args
      module="$1"
      args="$2"
    
      echo "Loading kernel module $module"
      modprobe $module $args || true
    }
    
    echo 'Loading kernel modules'
    
    # Loop over every line in /etc/modules.
    grep '^[^#]' $MODULES_FILE | \
    while read module args; do
      [ "$module" ] || continue
      load_module "$module" "$args"
    done
}

stop () {
  exit 0
}

(Last edited by exobyte on 29 Jan 2008, 08:58)

And...

Since you have modprobe, now, make sure "automatic modules loading" (CONFIG_KMOD=y) is enabled in your kernel.  If you're building a new image, this shouldn't be a problem.  If you're not, you'll *probably* have to extract the kernel from the image and manually install it.  Automatic module loading isn't available as a module.

The discussion might have continued from here.