#1355 Issue closed: 'modprobe --show-depends' insufficient to get all needed modules

Labels: enhancement, cleanup, discuss / RFC, fixed / solved / done, minor bug

jsmeix opened issue at 2017-05-10 13:19:

This is related to
https://github.com/rear/rear/issues/1202

The ResolveModules function (in linux-functions.sh) basically runs

modprobe --show-depends $module

to get the other modules that are needed to use $module
but that is insufficient in general because I found
a counter-example that seems to fail basically everywhere:

On my SLES12-like openSUSE Leap 42.1 system:

# lsmod | egrep '^parport|^ppdev|^lp'
[no output]

# modprobe --show-depends lp
insmod /lib/modules/4.1.15-8-default/kernel/drivers/parport/parport.ko 
insmod /lib/modules/4.1.15-8-default/kernel/drivers/char/lp.ko

# modprobe -v lp
insmod /lib/modules/4.1.15-8-default/kernel/drivers/parport/parport.ko 
insmod /lib/modules/4.1.15-8-default/kernel/drivers/char/lp.ko

# lsmod | egrep '^parport|^ppdev|^lp'
ppdev                  20480  0 
parport_pc             49152  0 
lp                     20480  0 
parport                49152  3 lp,ppdev,parport_pc

On my SLES11 system:

# lsmod | egrep '^parport|^ppdev|^lp'
[no output]

# modprobe --show-depends lp
insmod /lib/modules/3.0.101-0.47.71-pae/kernel/drivers/parport/parport.ko 
insmod /lib/modules/3.0.101-0.47.71-pae/kernel/drivers/char/lp.ko 

# modprobe -v lp
insmod /lib/modules/3.0.101-0.47.71-pae/kernel/drivers/parport/parport.ko 
insmod /lib/modules/3.0.101-0.47.71-pae/kernel/drivers/char/lp.ko

# lsmod | egrep '^parport|^ppdev|^lp'
ppdev                  17454  0 
parport_pc             40651  1 
lp                     13351  0 
parport                40847  3 ppdev,parport_pc,lp

On my SLES10 system:

# lsmod | egrep '^parport|^ppdev|^lp'
[no output]

# modprobe --show-depends lp
insmod /lib/modules/2.6.16.60-0.85.1-default/kernel/drivers/parport/parport.ko 
insmod /lib/modules/2.6.16.60-0.85.1-default/kernel/drivers/char/lp.ko 

# modprobe -v lp
insmod /lib/modules/2.6.16.60-0.85.1-default/kernel/drivers/parport/parport.ko 
insmod /lib/modules/2.6.16.60-0.85.1-default/kernel/drivers/char/lp.ko 

# lsmod | egrep '^parport|^ppdev|^lp'
parport_pc             39528  0 
lp                     13064  0 
parport                39052  2 parport_pc,lp

In all cases "modprobe --show-depends lp" shows that
the 'lp' module only needs the 'parport' module
but nowhere is shown that in practice
at least also 'parport_pc' is needed
to use the parallel port on a PC, cf.
https://en.opensuse.org/SDB:Installing_a_Printer#Parallel_port_printers

Accordingly current ReaR does not copy all modules
that are in practice needed to the recovery system
which is another proof of my experience in
https://github.com/rear/rear/issues/1202#issue-209488396
that in practice there can be any kind of awkward
unexpected failures in the ReaR recovery system
unless all kernel modules had been included.

But when all kernel modules get included
in the ReaR recovery system it contradicts
the current implementation of EXCLUDE_MODULES
which excludes modules from the recovery system.

Perhaps it is better to implement EXCLUDE_MODULES
via /etc/modprobe.d/blacklist in the recovery system
so that still all module files could be available
in the recovery system but EXCLUDE_MODULES
are only blacklisted from being (automatically) loaded?

jsmeix commented at 2017-05-10 14:46:

Furthermore there is special behaviour
whether or not additionally --ignore-install is specified:

On my openSUSE Leap 42.1 system:

# /sbin/modprobe --show-depends ata_piix
install /sbin/modprobe ahci 2>&1 |:; /sbin/modprobe --ignore-install ata_piix 

# /sbin/modprobe --ignore-install --show-depends ata_piix
insmod /lib/modules/4.1.15-8-default/kernel/drivers/ata/ata_piix.ko 

On my SLES12 system:

# /sbin/modprobe --show-depends ata_piix
insmod /lib/modules/4.4.21-69-default/kernel/drivers/scsi/scsi_mod.ko 
insmod /lib/modules/4.4.21-69-default/kernel/drivers/ata/libata.ko 
install /sbin/modprobe ahci 2>&1 |:; /sbin/modprobe --ignore-install ata_piix

# /sbin/modprobe --ignore-install --show-depends ata_piix
insmod /lib/modules/4.4.21-69-default/kernel/drivers/scsi/scsi_mod.ko 
insmod /lib/modules/4.4.21-69-default/kernel/drivers/ata/libata.ko 
insmod /lib/modules/4.4.21-69-default/kernel/drivers/ata/ata_piix.ko

On my SLES11 system:

# /sbin/modprobe --show-depends ata_piix
insmod /lib/modules/3.0.101-0.47.71-pae/kernel/drivers/scsi/scsi_mod.ko 
insmod /lib/modules/3.0.101-0.47.71-pae/kernel/drivers/ata/libata.ko 
install /sbin/modprobe ahci 2>&1 |:; /sbin/modprobe --ignore-install ata_piix

# /sbin/modprobe --ignore-install --show-depends ata_piix
insmod /lib/modules/3.0.101-0.47.71-pae/kernel/drivers/scsi/scsi_mod.ko 
insmod /lib/modules/3.0.101-0.47.71-pae/kernel/drivers/ata/libata.ko 
insmod /lib/modules/3.0.101-0.47.71-pae/kernel/drivers/ata/ata_piix.ko

On my SLES10 system:

# /sbin/modprobe --show-depends ata_piix
insmod /lib/modules/2.6.16.60-0.85.1-default/kernel/drivers/scsi/scsi_mod.ko 
insmod /lib/modules/2.6.16.60-0.85.1-default/kernel/drivers/ata/libata.ko 
install /sbin/modprobe ahci 2>&1 |:; /sbin/modprobe --ignore-install ata_piix

# /sbin/modprobe --ignore-install --show-depends ata_piix
insmod /lib/modules/2.6.16.60-0.85.1-default/kernel/drivers/scsi/scsi_mod.ko 
insmod /lib/modules/2.6.16.60-0.85.1-default/kernel/drivers/ata/libata.ko 
insmod /lib/modules/2.6.16.60-0.85.1-default/kernel/drivers/ata/ata_piix.ko

Currently '^install' output lines are ignored because ReaR calls
"/sbin/modprobe --ignore-install --show-depends"
where only '^insmod' lines appear but the '^install' output lines in
"/sbin/modprobe --show-depends"
seem to indicate that another module could be needed
in this example 'ahci' in addition to ata_piix.

E.g. on my SLES10 system:

# lsmod | egrep 'ata_piix|ahci'
[no output]

# modprobe ata_piix

# lsmod | egrep 'ata_piix|ahci'
ata_piix               18948  0 
ahci                   32904  0

On my SLES12 system it seems both ahci and ata_piix
are needed by default (at least they are loaded by default):

# lsmod | egrep 'ata_piix|ahci'
ata_piix               36864  2 
ahci                   36864  0 
libahci                36864  1 ahci
libata                270336  4 ahci,libahci,ata_generic,ata_piix

# modinfo -F filename ahci
/lib/modules/4.4.21-69-default/kernel/drivers/ata/ahci.ko

# modinfo -F filename ata_piix
/lib/modules/4.4.21-69-default/kernel/drivers/ata/ata_piix.ko

In contrast on my openSUSE Leap 42.1 system
'ahci' is no longer a module, only 'ata_piix' is one:

# modinfo -F filename ata_piix
/lib/modules/4.1.15-8-default/kernel/drivers/ata/ata_piix.ko

# modinfo ahci       
modinfo: ERROR: Module ahci not found.

# cat /lib/modules/$(uname -r)/modules.builtin | grep ahci
kernel/drivers/ata/ahci.ko
kernel/drivers/ata/libahci.ko

From my point of view this is one more proof of my experience in
https://github.com/rear/rear/issues/1202#issue-209488396
that in practice there can be any kind of awkward
unexpected failures in the ReaR recovery system
unless all kernel modules had been included.

jsmeix commented at 2017-05-12 13:14:

With #1359 merged
I consider this issue sufficiently solved via documentation
and via the plain and simple MODULES=( 'all_modules' )
for all cases where "advanced" kernel module dependencies
are needed (see what I described in in default.conf).


[Export of Github issue for rear/rear.]