Discussion:
[gentoo-user] Loading modules prevents shutdown
(too old to reply)
dhk
2023-05-23 20:00:02 UTC
Permalink
After a new install on an HP EliteBook with an Intel I7 core, when the
iwlwifi module is loaded the system fails to complete shutdown and power
off.

The install is mostly a standard openrc install for a personal use
laptop.  The usual partitions were created and only /var, /opt and /home
are on lvm2; one non-standard partition configuration is /usr/src and
/lib/modules are on their own partition.  The /usr/src partition should
be benign since it is only used when building the kernel; however, the
/lib/modules partition was the cause of one issue that has already been
resolved and may be the cause of the other.

First, the resolved issue.
On boot, the iwlwifi module was not found and the following message was
displayed.
  * Loading kernel modules ...
   modprobe: FATAL: Module iwlwifi not found in directory
/lib/modules/6.1.19-gentoo-x86_64
This was puzzling, since once logged in a find command found it where it
should be and the module could be added on the command line without any
problem.  This issue caused me to reboot and shutdown many times until
noticing that modprobe was trying to load the iwlwifi module before
/lib/modules was mounted.  This was easily fixed by adding a
"/lib/modules" line to the /etc/initramfs.mounts file.  The one thing
noticed from all the shutdowns and reboots was, when the iwlwifi module
was not loaded the system shutdown fine and when it was loaded the
system failed to shutdown and power off completely.

Second, Loading modules prevents shutdown,
The issue was discovered with iwlwifi, but occurs when any module from
the /lib/modules/6.1.19-gentoo-x86_64 directory is tried instead and
deleting the module before the "shutdown -h -P now" does not make a
difference.

To get a better look at what is going on, the rc_logger variable was set
to "YES" in /etc/rc.conf (rc_logger="YES").


Now the difference between the console display and /var/log/rc.log file
on a clean shutdown and one with a module loaded preventing a clean
shutdown.

Whether a module is loaded or not, the console and /var/log/rc.log match
up to and including "Stopping the Logical Volume Manager" and then
things start to deviate.

 * Stopping syslog-ng ...  [ ok
]                                                      <= console and
/var/log/rc.log match.
 * Unmounting loop devices * Unmounting filesystems
 *   Unmounting /var ...  [ ok ]
 *   Unmounting /opt ...  [ ok ]
 *   Unmounting /home ...  [ ok ]
 *   Unmounting /usr/src ...  [ ok ]
 *   Unmounting /tmp ...  [ ok ]
 *   Unmounting /lib/modules ...  [ ok ]
 *   Unmounting /boot ...  [ ok ]
 * Deactivating swap devices ...  [ ok
]                                           <= console and
/var/log/rc.log match.
 * Stopping the Logical Volume Manager ...        <= When a module is
loaded, this is the last line on the console.
  0 logical volume(s) in volume group "vg1" now active
  0 logical volume(s) in volume group "vg0" now active [ ok ] <= When a
module is loaded, this is the last line in /var/log/rc.log.
 * Setting hardware clock using the system clock [UTC] ...  [ ok ] <=
When no module is loaded, this is on the console and in /var/log/rc.log.
 * Stopping udev ...  [ ok ] <= When no module is loaded, this is on
the console and in /var/log/rc.log.
 rc shutdown logging stopped at Thu May 18 05:44:09 2023 <= When no
module is loaded, this is the last line in /var/log/rc.log.
 * Terminating remaining processes ...  [ ok ] <= When no module is
loaded, this is on the console (See: /etc/init.d/killprocs).
 * Killing remaining processes ...  [ ok ]                            
<= When no module is loaded, this is on the console (See: 
/etc/init.d/killprocs).
 * Saving dependency cache ...  [ ok ] <= When no module is loaded,
this is on the console (See: /etc/init.d/savecache).
 * Remounting remaining filesystems read-only ...  [ ok ] <= When no
module is loaded, this is on the console (See: /etc/init.d/mount-ro).
 *   Remounting / read only ...  [ ok ]                                
<= When no module is loaded, this is on the console.
reboot:  Power
down                                                         <= When no
module is loaded, this is on the console.


In short, it looks like the LVM was stopped correctly and everything was
good up to that point; however, when a module is loaded it looks like
nothing in /etc/runlevels/shutdown/ gets kicked off and the system is
waiting.

My preference is to have this work while keeping the /lib/modules
partition.  How it can be fixed?

FYI: Answering may be slow since my emails are received weekly through
the digest.

Thank you.
Jigme Datse
2023-05-23 20:40:01 UTC
Permalink
On Tue, 23 May 2023 15:58:34 -0400
Post by dhk
After a new install on an HP EliteBook with an Intel I7 core, when
the iwlwifi module is loaded the system fails to complete shutdown
and power off.
The install is mostly a standard openrc install for a personal use
laptop.  The usual partitions were created and only /var, /opt and
/home are on lvm2; one non-standard partition configuration is
/usr/src and /lib/modules are on their own partition.  The /usr/src
partition should be benign since it is only used when building the
kernel; however, the /lib/modules partition was the cause of one
issue that has already been resolved and may be the cause of the
other.
/lib should be in your root partition, I know you are saying
/lib/modules, but I think it applies to directories under /lib *except*
in cases when that directory should be under /var /opt or /usr more
accurately.
Post by dhk
First, the resolved issue.
On boot, the iwlwifi module was not found and the following message
was displayed.
  * Loading kernel modules ...
   modprobe: FATAL: Module iwlwifi not found in directory
/lib/modules/6.1.19-gentoo-x86_64
This was puzzling, since once logged in a find command found it where
it should be and the module could be added on the command line
without any problem.  This issue caused me to reboot and shutdown
many times until noticing that modprobe was trying to load the
iwlwifi module before /lib/modules was mounted.  This was easily
fixed by adding a "/lib/modules" line to the /etc/initramfs.mounts
file.  The one thing noticed from all the shutdowns and reboots was,
when the iwlwifi module was not loaded the system shutdown fine and
when it was loaded the system failed to shutdown and power off
completely.
Second, Loading modules prevents shutdown,
The issue was discovered with iwlwifi, but occurs when any module
from the /lib/modules/6.1.19-gentoo-x86_64 directory is tried instead
and deleting the module before the "shutdown -h -P now" does not make
a difference.
To get a better look at what is going on, the rc_logger variable was
set to "YES" in /etc/rc.conf (rc_logger="YES").
Now the difference between the console display and /var/log/rc.log
file on a clean shutdown and one with a module loaded preventing a
clean shutdown.
Whether a module is loaded or not, the console and /var/log/rc.log
match up to and including "Stopping the Logical Volume Manager" and
then things start to deviate.
 * Stopping syslog-ng ...  [ ok
]                                                      <= console and
/var/log/rc.log match.
 * Unmounting loop devices * Unmounting filesystems
 *   Unmounting /var ...  [ ok ]
 *   Unmounting /opt ...  [ ok ]
 *   Unmounting /home ...  [ ok ]
 *   Unmounting /usr/src ...  [ ok ]
 *   Unmounting /tmp ...  [ ok ]
 *   Unmounting /lib/modules ...  [ ok ]
 *   Unmounting /boot ...  [ ok ]
 * Deactivating swap devices ...  [ ok
]                                           <= console and
/var/log/rc.log match.
 * Stopping the Logical Volume Manager ...        <= When a module
is loaded, this is the last line on the console.
  0 logical volume(s) in volume group "vg1" now active
  0 logical volume(s) in volume group "vg0" now active [ ok ] <=
When a module is loaded, this is the last line in /var/log/rc.log.
 * Setting hardware clock using the system clock [UTC] ...  [ ok ]
<= When no module is loaded, this is on the console and in
/var/log/rc.log.
 * Stopping udev ...  [ ok ] <= When no module is loaded, this is on
the console and in /var/log/rc.log.
 rc shutdown logging stopped at Thu May 18 05:44:09 2023 <= When no
module is loaded, this is the last line in /var/log/rc.log.
 * Terminating remaining processes ...  [ ok ] <= When no module is
loaded, this is on the console (See: /etc/init.d/killprocs).
 * Killing remaining processes ...  [ ok ]
<= When no module is loaded, this is on the console (See: 
/etc/init.d/killprocs).
 * Saving dependency cache ...  [ ok ] <= When no module is loaded,
this is on the console (See: /etc/init.d/savecache).
 * Remounting remaining filesystems read-only ...  [ ok ] <= When no
module is loaded, this is on the console (See: /etc/init.d/mount-ro).
 *   Remounting / read only ...  [ ok ]
<= When no module is loaded, this is on the console.
reboot:  Power
down                                                         <= When
no module is loaded, this is on the console.
I feel the issue is indeed the mounting /var/modules ... Because you
`umount` it before you unload the modules... Your usage is very much,
"non-standard" and just changing that *likely* would fix it.
Post by dhk
In short, it looks like the LVM was stopped correctly and everything
was good up to that point; however, when a module is loaded it looks
like nothing in /etc/runlevels/shutdown/ gets kicked off and the
system is waiting.
My preference is to have this work while keeping the /lib/modules
partition.  How it can be fixed?
I think that may be literally impossible... Or at least not even,
"non-trivial". The *trivial* solution, is to have /lib/modules on your
root partition.
Post by dhk
FYI: Answering may be slow since my emails are received weekly
through the digest.
If that's fine, it's fine by me...
dhk
2023-06-17 12:00:02 UTC
Permalink
Thanks for the tips.  After spending a lot of time on and off for a few
weeks trying to keep /lib/modules on its own partition, it just did not
work right; the system was scrapped and rebuilt per the trivial solution
with /lib/modules on the root partition.  Now it works as expected.

A good explanation as to why /lib/modules cannot be a separate partition
would be nice, but after learning learning the hard way again it stays
on the root partition going forward.
Post by dhk
After a new install on an HP EliteBook with an Intel I7 core, when the
iwlwifi module is loaded the system fails to complete shutdown and
power off.
The install is mostly a standard openrc install for a personal use
laptop.  The usual partitions were created and only /var, /opt and
/home are on lvm2; one non-standard partition configuration is
/usr/src and /lib/modules are on their own partition.  The /usr/src
partition should be benign since it is only used when building the
kernel; however, the /lib/modules partition was the cause of one issue
that has already been resolved and may be the cause of the other.
First, the resolved issue.
On boot, the iwlwifi module was not found and the following message
was displayed.
  * Loading kernel modules ...
   modprobe: FATAL: Module iwlwifi not found in directory
/lib/modules/6.1.19-gentoo-x86_64
This was puzzling, since once logged in a find command found it where
it should be and the module could be added on the command line without
any problem.  This issue caused me to reboot and shutdown many times
until noticing that modprobe was trying to load the iwlwifi module
before /lib/modules was mounted.  This was easily fixed by adding a
"/lib/modules" line to the /etc/initramfs.mounts file.  The one thing
noticed from all the shutdowns and reboots was, when the iwlwifi
module was not loaded the system shutdown fine and when it was loaded
the system failed to shutdown and power off completely.
Second, Loading modules prevents shutdown,
The issue was discovered with iwlwifi, but occurs when any module from
the /lib/modules/6.1.19-gentoo-x86_64 directory is tried instead and
deleting the module before the "shutdown -h -P now" does not make a
difference.
To get a better look at what is going on, the rc_logger variable was
set to "YES" in /etc/rc.conf (rc_logger="YES").
Now the difference between the console display and /var/log/rc.log
file on a clean shutdown and one with a module loaded preventing a
clean shutdown.
Whether a module is loaded or not, the console and /var/log/rc.log
match up to and including "Stopping the Logical Volume Manager" and
then things start to deviate.
 * Stopping syslog-ng ...  [ ok
]                                                      <= console and
/var/log/rc.log match.
 * Unmounting loop devices * Unmounting filesystems
 *   Unmounting /var ...  [ ok ]
 *   Unmounting /opt ...  [ ok ]
 *   Unmounting /home ...  [ ok ]
 *   Unmounting /usr/src ...  [ ok ]
 *   Unmounting /tmp ...  [ ok ]
 *   Unmounting /lib/modules ...  [ ok ]
 *   Unmounting /boot ...  [ ok ]
 * Deactivating swap devices ...  [ ok
]                                           <= console and
/var/log/rc.log match.
 * Stopping the Logical Volume Manager ...        <= When a module is
loaded, this is the last line on the console.
  0 logical volume(s) in volume group "vg1" now active
  0 logical volume(s) in volume group "vg0" now active [ ok ] <= When
a module is loaded, this is the last line in /var/log/rc.log.
 * Setting hardware clock using the system clock [UTC] ...  [ ok ] <=
When no module is loaded, this is on the console and in /var/log/rc.log.
 * Stopping udev ...  [ ok ] <= When no module is loaded, this is on
the console and in /var/log/rc.log.
 rc shutdown logging stopped at Thu May 18 05:44:09 2023 <= When no
module is loaded, this is the last line in /var/log/rc.log.
 * Terminating remaining processes ...  [ ok ] <= When no module is
loaded, this is on the console (See: /etc/init.d/killprocs).
 * Killing remaining processes ...  [ ok ]                            
<= When no module is loaded, this is on the console (See: 
/etc/init.d/killprocs).
 * Saving dependency cache ...  [ ok ] <= When no module is loaded,
this is on the console (See: /etc/init.d/savecache).
 * Remounting remaining filesystems read-only ...  [ ok ] <= When no
module is loaded, this is on the console (See: /etc/init.d/mount-ro).
 *   Remounting / read only ...  [ ok
]                                 <= When no module is loaded, this is
on the console.
reboot:  Power
down                                                         <= When
no module is loaded, this is on the console.
In short, it looks like the LVM was stopped correctly and everything
was good up to that point; however, when a module is loaded it looks
like nothing in /etc/runlevels/shutdown/ gets kicked off and the
system is waiting.
My preference is to have this work while keeping the /lib/modules
partition.  How it can be fixed?
FYI: Answering may be slow since my emails are received weekly through
the digest.
Thank you.
Wols Lists
2023-06-17 15:40:01 UTC
Permalink
Post by dhk
Thanks for the tips.  After spending a lot of time on and off for a few
weeks trying to keep /lib/modules on its own partition, it just did not
work right; the system was scrapped and rebuilt per the trivial solution
with /lib/modules on the root partition.  Now it works as expected.
A good explanation as to why /lib/modules cannot be a separate partition
would be nice, but after learning learning the hard way again it stays
on the root partition going forward.
The kernel needs to load modules to boot fully. If mount hasn't run by
the time the kernel needs a module, you have a problem ...

Even worse, if mount needs the kernel to load a module, you're stuffed ...

Cheers,
Wol

Loading...