#!/bin/sh TARGET=$1 ROOTFS=$2 VERSION=$3 if [ ! -d "$TARGET" -o ! -d "$ROOTFS" ]; then echo "Usage: $0 " exit 255 fi add_module() { for kmod in $(modprobe --dirname=${ROOTFS} --set-version="$VERSION" --ignore-install --quiet --show-depends "$1" | awk '/^insmod/ { print $2 }'); do path=$(realpath --relative-to ${ROOTFS} ${kmod}) if [ -e $TARGET/$path ]; then continue fi mkdir -p $TARGET/$(dirname $path) cp $kmod $TARGET/$(dirname $path) done } echo "Loading modules..." for i in loop squashfs overlay; do add_module $i done