Skip to content

Commit

Permalink
Always load the /etc/modules even when udevd or systemd has been star…
Browse files Browse the repository at this point in the history
…ted, so that

we always load the modules listed in /etc/modules (set by MODULES_LOAD)
Issue #905
  • Loading branch information
gdha committed Jul 7, 2016
1 parent 127c3fb commit 0ec8716
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -75,3 +75,18 @@ fi

# device mapper gets a special treatment here because there is no dependency to load it
modprobe -q dm-mod

# When udevd or systemd is in place then out /etc/modules content is skipped, however, we
# might need it for e.g. loading fuse which was added to the MODULES_LOAD array
# There might be other kernel modules added by the user on demand, therefore, we always
# load the modules found in /etc/modules
if test -s /etc/modules ; then
while read module options ; do
case "$module" in
(\#*|"") ;;
(*) modprobe -v $module $options;;
esac
done </etc/modules
fi


3 comments on commit 0ec8716

@jsmeix
Copy link
Member

@jsmeix jsmeix commented on 0ec8716 Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me this does not work:

For a test I have in etc/rear/local.conf

MODULES_LOAD=( "${MODULES_LOAD[@]}" vfat fuse usblp usb_storage )

In the rear recovery system I have:

RESCUE e229:~ # cat /etc/modules
8139cp
ehci_hcd
fuse
uhci_hcd
usb_common
usb_storage
usbcore
usblp
vfat

RESCUE e229:~ # for m in $( cat /etc/modules ) ; do lsmod | grep -q "^$m" && echo $m loaded || echo $m not loaded ; done
8139cp loaded
ehci_hcd loaded
fuse not loaded
uhci_hcd loaded
usb_common loaded
usb_storage not loaded
usbcore loaded
usblp not loaded
vfat not loaded

RESCUE e229:~ # modprobe vfat

RESCUE e229:~ # modprobe usblp

RESCUE e229:~ # modprobe usb_storage

RESCUE e229:~ # modprobe fuse       

RESCUE e229:~ # for m in $( cat /etc/modules ) ; do lsmod | grep -q "^$m" && echo $m loaded || echo $m not loaded ; done
8139cp loaded
ehci_hcd loaded
fuse loaded
uhci_hcd loaded
usb_common loaded
usb_storage loaded
usbcore loaded
usblp loaded
vfat loaded

RESCUE e229:~ # rmmod vfat

RESCUE e229:~ # rmmod fuse

RESCUE e229:~ # rmmod usb_storage
rmmod: ERROR: Module usb_storage is in use by: uas

RESCUE e229:~ # rmmod usblp      

RESCUE e229:~ # tail /etc/scripts/system-setup.d/40-start-udev-or-load-modules.sh
if test -s /etc/modules ; then
    while read module options ; do
    case "$module" in
        (\#*|"") ;;
        (*) modprobe -v $module $options;;
    esac
    done </etc/modules
fi

RESCUE e229:~ # set -x ; if test -s /etc/modules ; then while read module options ; do case "$module" in (\#*|"") ;; (*) modprobe -v $module $options;; esac ; done </etc/modules ; set +x
 fi
+ test -s /etc/modules
+ read module options
+ case "$module" in
+ modprobe -v 8139cp
+ read module options
+ case "$module" in
+ modprobe -v ehci_hcd
+ read module options
+ case "$module" in
+ modprobe -v fuse
insmod /lib/modules/3.12.49-11-default/kernel/fs/fuse/fuse.ko 
+ read module options
+ case "$module" in
+ modprobe -v uhci_hcd
+ read module options
+ case "$module" in
+ modprobe -v usb_common
+ read module options
+ case "$module" in
+ modprobe -v usb_storage
+ read module options
+ case "$module" in
+ modprobe -v usbcore
+ read module options
+ case "$module" in
+ modprobe -v usblp
insmod /lib/modules/3.12.49-11-default/kernel/drivers/usb/class/usblp.ko 
+ read module options
+ case "$module" in
+ modprobe -v vfat
insmod /lib/modules/3.12.49-11-default/kernel/fs/fat/vfat.ko 
+ read module options
+ set +x

RESCUE e229:~ # for m in $( cat /etc/modules ) ; do lsmod | grep -q "^$m" && echo $m loaded || echo $m not loaded ; done
8139cp loaded
ehci_hcd loaded
fuse loaded
uhci_hcd loaded
usb_common loaded
usb_storage loaded
usbcore loaded
usblp loaded
vfat loaded

@jsmeix
Copy link
Member

@jsmeix jsmeix commented on 0ec8716 Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Launching the rear recovery system with added "debug"
kernel command line parameter shows that while
/etc/scripts/system-setup.d/40-start-udev-or-load-modules.sh
is run it seems the code above is never reached
because of an early "return" in that script.
The only "return" in that script is here

    # systemd-udevd case: systemd-udevd is started by systemd
    ps ax | grep -v grep | grep -q systemd-udevd && { # check if daemon is actually running
        my_udevtrigger
        echo -n "Waiting for udev ... "
        sleep 1
        my_udevsettle
        echo "done."
        return
    }

I will try to fix it so that the code above is always run...

@jsmeix
Copy link
Member

@jsmeix jsmeix commented on 0ec8716 Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With #909
I triy to fix it so that the code that always loads
modules in /etc/modules is always run.

Please sign in to comment.