#1941 Issue closed: ReaR breaks on module-less kernels

Labels: enhancement, fixed / solved / done, minor bug

hoffie opened issue at 2018-10-25 19:07:

Relax-and-Recover (ReaR) Issue Template

Fill in the following items before submitting a new issue
(quick response is not guaranteed with free support):

  • ReaR version: Relax-and-Recover 2.4 / Git

  • OS version:

$ cat /etc/rear/os.conf 
OS_VENDOR=Gentoo
OS_VERSION=2.4.1
  • ReaR configuration files:
# grep -vP '^#|^$' /etc/rear/local.conf 
OS_VENDOR=Gentoo
BACKUP=NETFS
BACKUP_URL=file:///mnt/scratch/backup
BACKUP_PROG=rsync
EXCLUDE_MOUNTPOINTS=( "${EXCLUDE_MOUNTPOINTS[@]}" '/mnt/scratch' )
BACKUP_PROG_EXCLUDE=( "${BACKUP_PROG_EXCLUDE[@]}" '/var/cache/*' '/tmp/*' '/var/tmp/*' '/root/.cache/*' '/backups/*' '/mnt/*' '/usr/portage/*' '/usr/src/*' '/var/log/*' '/home/ch/downloads/*' '/var/lib/docker/*')
MODULES=( 'no_modules' )
  • Hardware: KVM VM

  • System architecture: x86_64

  • Firmware: BIOS, GRUB2

  • Storage: local disk

  • Description of the issue (ideally so that others can reproduce it):
    ReaR fails on kernels with no modules support. MODULES=( 'no_modules' ) fails to avoid problems in FindStorageDrivers

$ rear mkrescue
ERROR: FindStorageDrivers called but STORAGE_DRIVERS is empty and no builtin storage modules found
Aborting due to an error, check /var/log/rear/rear-....log for details
Terminated

$ tail /var/log/rear/rear-*.log
2018-10-25 20:57:19.410794285 Including rescue/GNU/Linux/260_storage_drivers.sh
grep: /lib/modules/4.14.65-gentoo/modules.builtin: No such file or directory
2018-10-25 20:57:19.415589510 ERROR: FindStorageDrivers called but STORAGE_DRIVERS is empty and no builtin storage modules found
==== Stack trace ====
Trace 0: /usr/sbin/rear:543 main
Trace 1: /usr/share/rear/lib/mkrescue-workflow.sh:16 WORKFLOW_mkrescue
Trace 2: /usr/share/rear/lib/framework-functions.sh:101 SourceStage
Trace 3: /usr/share/rear/lib/framework-functions.sh:49 Source
Trace 4: /usr/share/rear/rescue/GNU/Linux/260_storage_drivers.sh:4 source
Trace 5: /usr/share/rear/lib/linux-functions.sh:95 FindStorageDrivers
Message: FindStorageDrivers called but STORAGE_DRIVERS is empty and no builtin storage modules found
== End stack trace ==
2018-10-25 20:57:19.426508427 Exiting rear mkrescue (PID 20983) and its descendant processes
2018-10-25 20:57:20.451556279 rear,20983 /usr/sbin/rear mkrescue
  `-rear,22356 /usr/sbin/rear mkrescue
      `-pstree,22357 -Aplau 20983
/usr/share/rear/lib/_input-output-functions.sh: line 157: kill: (22360) - No such process
2018-10-25 20:57:20.463117774 Running exit tasks
2018-10-25 20:57:20.464393097 Finished in 3 seconds
2018-10-25 20:57:20.465513231 Removing build area /tmp/rear.Vh0TRzKXipNxYal
2018-10-25 20:57:20.473928895 End of program reached
  • Workaround, if any:
    The following patch fixes this for me:
--- /usr/share/rear/lib/linux-functions.sh.vanilla      2018-10-25 20:42:33.785336567 +0200
+++ /usr/share/rear/lib/linux-functions.sh      2018-10-25 20:58:12.330375456 +0200
@@ -82,6 +82,14 @@
 # optionally $1 specifies the directory where to search for
 # drivers files
 function FindStorageDrivers () {
+    # The special user setting MODULES=( 'no_modules' ) enforces that
+    # no kernel modules get included in the rescue/recovery system
+    # regardless of what modules are currently loaded.
+    # Test the first MODULES array element because other scripts
+    # in particular rescue/GNU/Linux/240_kernel_modules.sh
+    # already appended other modules to the MODULES array:
+    test "no_modules" = "$MODULES" && return
+
     if (( ${#STORAGE_DRIVERS[@]} == 0 )) ; then
         if ! grep -E 'kernel/drivers/(block|firewire|ide|ata|md|message|scsi|usb/storage)' /lib/modules/$KERNEL_VERSION/modules.builtin ; then
             Error "FindStorageDrivers called but STORAGE_DRIVERS is empty and no builtin storage modules found"

Should I submit this as a PR?

BTW: Thanks for this great project and all the effort you put it!

jsmeix commented at 2018-10-26 07:45:

@hoffie
thank you for the issue report and for your analysis and
for your perfectly explained fix - I like explanatory comments
so much, cf. https://github.com/rear/rear/wiki/Coding-Style

I look forward to your pull request!

FYI:
When I implemented support for MODULES=( 'no_modules' )
via https://github.com/rear/rear/issues/1202
I could not test how ReaR actually behaves on module-less kernels
because I do not use a module-less kernel on my systems.
Therefore I appreciate it very much that now it was actually tested that
current ReaR does not yet behave as intended on module-less kernels.

hoffie commented at 2018-10-28 14:20:

@jsmeix Thanks for the quick reply. Submitted the PR.
Glad you like the comments. However, I just borrowed them from 4a478b55cfd5081630c8c3ae762b4a83a9eb91c6 where some @jsmeix added them initially. :)

jsmeix commented at 2018-10-29 12:45:

With https://github.com/rear/rear/pull/1943 merged
this issue should be fixed (the places where FindStorageDrivers results
are used seem to work safe when FindStorageDrivers returns nothing).

@hoffie
it is my sneaky plan that existing code with explanatory comments
gets borrowed/copied/re-used so that more and more code emerges
that is easy to understand ... ;-)

Thank you for your contribution to ReaR!


[Export of Github issue for rear/rear.]