LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   rc.modules looks to need a little attention. (http://www.linuxquestions.org/questions/slackware-14/rc-modules-looks-to-need-a-little-attention-4175483641/)

GazL 11-06-2013 04:32 PM

rc.modules looks to need a little attention.
 
While I was reviewing the rc.* files I noticed that rc.modules seems a little outdated. I suspect this has been wrong for quite a while.

Code:

RELEASE=$(uname -r)

### Update module dependencies ###
# If /usr is mounted and we have 'find', we can try to take a shortcut:
if [ -x /usr/bin/find -a -e /lib/modules/$RELEASE/modules.dep \
    -a /lib/modules/$RELEASE/modules.dep -nt /etc/modules.conf ]; then
  NEWMODS="$(/usr/bin/find /lib/modules/$RELEASE -mindepth 2 -type f -newer /lib
/modules/$RELEASE/modules.dep)"
  # Only rebuild dependencies if new module(s) are found:
  if [ ! "" = "$NEWMODS" ]; then
    echo "Updating module dependencies for Linux $RELEASE:"
    /sbin/depmod -a
  else
    echo "Module dependencies up to date (no new kernel modules found)."
  fi
else # we don't have find, or there is no existing modules.dep, or it is out of
date.
  echo "Updating module dependencies for Linux $RELEASE:"
  /sbin/depmod -A
fi

Firstly, there isn't a /etc/modules.conf anymore.

Secondly, the -a and -A options seem to have been reversed. According to the man pages, depmod -a will probe for all modules, where as -A will just process new ones.

All that stuff with find looks a little tortured too. I'm thinking that this section should probably be changed to a simple:
Code:


### Update module dependencies #########################################

# Determine the version of the running kernel:
RELEASE=$(uname -r)

if [ -e /lib/modules/$RELEASE/modules.dep ]; then
  echo "Updating $RELEASE module dependencies for NEW modules (if any)."
  /sbin/depmod -A
else
  echo "Updating $RELEASE module dependencies for ALL modules."
  /sbin/depmod -a
fi

########################################################################


Also, IMO all the lines in this file that modprobe various modules should reviewed for suitability and potentially commented out. For example, why would I want "/sbin/modprobe e_powersaver 2>/dev/null" or "/sbin/modprobe longrun 2>/dev/null" running on my X86_64?

ReaperX7 11-06-2013 04:36 PM

It's mostly for systems I suppose that will be ran without udev and still use those individual modprobes for devices. The rc.modules file still works, but it's just very unused on a majority of systems because of what it's intended for.

GazL 11-06-2013 04:43 PM

I think my point was that "# Enhanced PowerSaver driver for VIA C7 CPUs" isn't much use in the rc.modules-3.10.17 shipped with the X86_64 kernel. I know the 2>/dev/null is going to hide the failures, but it just seems untidy.

Anyway, my main reason for posting was to draw attention to the depmod stuff, which I believe to be wrong.

qweasd 11-10-2014 07:45 PM

What's the decree on this one? Can rc.modules be simply removed on systems with 3.* kernel?

bobzilla 11-10-2014 08:13 PM

Quote:

Originally Posted by qweasd (Post 5267853)
What's the decree on this one? Can rc.modules be simply removed on systems with 3.* kernel?

Doesn't have much to do with a kernel version. It's there for people not wanting to use udev (as Reaper pointed out before me). That makes sense in some uses (for example closed or rarely changing systems) and it would be nice to keep it possible.

Depmod thing, if correct, is an issue though. Everything else Gazl commented on can be fixed manually.

ReaperX7 11-10-2014 10:13 PM

The script and listing of modules does need to be updated badly, but Patrick probably hasn't had time yet.

If you wish to update it and share it, that would be helpful as well.

GazL 11-11-2014 07:03 AM

I've also emailed him about the depmod -a/-A switcharoo, so he should already be aware. Didn't get a response, but you sometimes don't with Pat unless he has a specific point to make or discuss with you.


FWIW, since I posted this thread, I've been using this as a /etc/rc.d/rc.modules.local:
Code:

#!/bin/sh
# /etc/rc.d/rc.modules.local
#
# This file loads extra drivers into the Linux kernel.


### Update module dependencies #########################################

# Determine the version of the running kernel:
RELEASE=$(uname -r)

if [ -e "/lib/modules/$RELEASE/modules.dep" ]; then
  echo "Updating module dependency list for $RELEASE:"
  /sbin/depmod --quick
else
  echo "Creating module dependency list for $RELEASE:"
  /sbin/depmod --all
fi

########################################################################

/sbin/modprobe sg            # Generic SCSI support for SATA DVD-RW
/sbin/modprobe loop          # loop block device

########################################################################

(It's pretty much the same as the one at the top of this thread, except I decided to use the long options for added clarity)

IMO there's no point maintaining a complete list of commented out modules as that information is available in the kernel documentation and Pat has better things to do with his time than maintain a list of kernel modules/descriptions that people could just look up elsewhere if they need to.

qweasd 11-11-2014 11:04 AM

Thanks, GazL. I found this thread because I was rewriting build scripts for kernel, modules, and firmware, and I couldn't figure out what, if anything, rc.modules does. I like your depmod fix.

ReaperX7 11-11-2014 02:21 PM

True. Perhaps a document might be better for listing modules and purpose?

rworkman 11-11-2014 09:36 PM

I like it. I'd suggest a couple of minor changes, making it look something like this:
Code:

#!/bin/sh
# /etc/rc.d/rc.modules.local
#
# This file loads extra drivers into the Linux kernel.


### Update module dependencies #########################################

# Determine the version of the running kernel:
RELEASE=$(uname -r)

if [ -e "/lib/modules/$RELEASE/modules.dep" ]; then
  echo "Updating module dependency list for $RELEASE:"
  /sbin/depmod --quick
else
  echo "Creating module dependency list for $RELEASE:"
  /sbin/depmod --all
fi

# Almost all necessary modules are automatically loaded when needed,
# but there are a few exceptions. Here's a (not all-inclusive) list:

########################################################################

#/sbin/modprobe tun            # Universal TUN/TAP device driver
#/sbin/modprobe sg            # Generic SCSI support for SATA DVD-RW

########################################################################

Note that loop was removed, as there's /etc/rc.d/rc.loop for that. I don't like it, but it's there.

rkelsen 11-11-2014 10:36 PM

Quote:

Originally Posted by GazL (Post 5268117)
IMO there's no point maintaining a complete list of commented out modules as that information is available in the kernel documentation and Pat has better things to do with his time than maintain a list of kernel modules/descriptions that people could just look up elsewhere if they need to.

Just on that point, would it be worth creating a separate list of modules which is referenced by the rc.modules script when it looks for modules to load?

It'd keep the script nice and neat, and you could simply add module names to it as necessary.

Edit: Further to Robbie's point about extraneous rc scripts which only load one module (such as rc.loop and rc.netdevice), you could simply add the modules to this list during installation.

qweasd 11-11-2014 10:44 PM

Robby, are you guys saying everything else in that script is not needed?

rworkman 11-12-2014 12:12 AM

qweasd: pretty much, yes :-)
rkelson: I don't think there are enough non-autoloaded modules remaining to make it worth doing that.

ReaperX7 11-12-2014 02:29 AM

A simplified script would be beneficial, however having a known-list would be helpful to system admins.

Didier Spaier 11-12-2014 04:24 AM

Quote:

Originally Posted by ReaperX7 (Post 5268560)
A simplified script would be beneficial, however having a known-list would be helpful to system admins.

Feel free to provide one and maintain it.


All times are GMT -5. The time now is 06:20 AM.