rrx

rmmod on Solaris (oh, god!)

Aug 29, 2006 15:45

Hi,
On solaris , when loading a module , you simply run
"modload moduleName". ("modload" is linux insmod parallel, and
"modunload" is something which is partially rmmod parallel, as you
will immediately understand).

On the other hand , you ***cannot*** remove a module by "modunload moduleName".

When trying to unload a module you cannot do "modunload moduleName",
as modunload expects the module number as a parameter.
So when removing a module, you should first run:
"modinfo | grep moduleName" and, after getting the module number
from the result, you should remove it by :
"modunload -i numberOfModule".

As a linux addict I was frustrated by this redundant step,
and since I perform a lot of module unloading on solaris,
I wrote a simple little script which performs rmmod moduleName
as in linux.
Here it is:

#!/bin/sh
if [ $# -ne 1 ] ; then
echo "usage: rmmod moduleName"; exit 1
fi

module=`modinfo | grep $1 | cut -c1-3`

if [ -z "$module" ] ; then
echo "module $1 not found"; exit 1
fi

modunload -i $module
echo "module $1 removed"

Cheers,
RRX
Previous post Next post
Up