#!/bin/bash
set +o posix
# Determine the major sub system names that the loaded set of modules
# are using.
# This helps trim down the size of the os initrd and installer.

function find_kmods() {
[ -f /proc/modules ] && {
   while read mod; do
      echo ${mod#*/*/*/*/}
   done< <( while read module; do modinfo "${module}" | grep -E '^filename:' ; done< <( awk '{print $1}' /proc/modules ) | awk '{print $2}' ) ;}
}
find_kmods # | sort | uniq #| cut -d/ -f5-

#( awk '{print $1}' /proc/modules| while read mod ; do
#   mfile=$( modinfo "${mod}" | grep -E '^filename:' | awk '{print $2}' )
#   echo ${mfile%/*}
#  done ) | sort | uniq | cut -d/ -f5- > /tmp/WOOP

