:: Re: [DNG] /lib/modules on separate …
Page principale
Supprimer ce message
Répondre à ce message
Auteur: Marc Shapiro
Date:  
À: dng
Anciens-sujets: Re: [DNG] /lib/modules on separate partition? (MOSTLY SOLVED)
Sujet: Re: [DNG] /lib/modules on separate partition? (COMPLETELY SOLVED)

On 11/21/22 21:28, Marc Shapiro wrote:
>
> On 11/21/22 07:54, Marc Shapiro wrote:
>>
>> On 11/20/22 21:01, Steve Litt wrote:
>>> Marc Shapiro via Dng said on Sun, 20 Nov 2022 19:14:15 -0800
>>>
>>>> On 11/20/22 17:48, Gregory Nowak wrote:
>>>>> On Sun, Nov 20, 2022 at 03:44:46PM -0800, Marc Shapiro via Dng
>>>>> wrote:
>>>>>> On 11/20/22 14:31, Gregory Nowak wrote:
>>>>>>> On Sat, Nov 19, 2022 at 08:55:06PM -0800, Marc Shapiro via Dng
>>>>>>> wrote:
>>>>>>>> Is there a way to have the system mount /lib/modules immediately
>>>>>>>> after mounting / and before loading the remaining kernel modules?
>>>>>>>> Or even better, is there a way to have all modules that should be
>>>>>>>> loaded during the boot process come from the initrd?
>>>>>>> You already got the answer on how to include all needed modules in
>>>>>>> the initrd. As for mounting /lib/modules right after /, add a line
>>>>>>> similar to the following in /etc/fstab right below the entry for /:
>>>>>>>
>>>>>>> /dev/group-lvm  /lib/modules  ext4  defaults  0 1
>>>>>>>
>>>>>>> This should cause /lib/modules to be mounted right after /. Replace
>>>>>>> /dev/group-lvm with the volume containing /lib/modules. Also adjust
>>>>>>> the file system type to whatever fs you're using.
>>>>>> That was the first thing that I tried, since it would be the
>>>>>> easiest and not required any additional steps when a new kernel is
>>>>>> installed. Unfortunately, /lib/modules still mounts along with all
>>>>>> the rest of my partitions, after the modules are loaded.
>>>>> So almost certainly, the modules are being loaded and the root fs is
>>>>> being mounted in the initrd, before /etc/fstab gets read. Including
>>>>> all the modules in the initrd maybe your only option then.
>>>>>
>>>>> Greg
>>>> I found another way, which works on Debian Stretch, but not on Devuan
>>>> Beowulf:
>>>>
>>>> I got the list of modules, as Tito suggested, but instead of updating
>>>> the initrd, I put the list of modules into /etc/modules. In Stretch,
>>>> this causes them to load after /lib/modules is mounted and everything
>>>> works as it should.  For some reason, though, it does not work for
>>>> Beowulf.
>>> That's an excellent idea. It might be easy to find out why it doesn't
>>> work with Devuan, and then either the distro fixes it or you provide
>>> some sort of solution or workaround.
>>>
>>> Also, it seems to me that you could provide, either as a sysvinit start
>>> script or an addition to the runit stage 1 script, a loop that
>>> modprobes
>>> everything in /etc/modules.
>>>
>>> Personally, I wouldn't mess with an initrd if you paid me. It's a black
>>> box very hard to understand or troubleshoot. Your solution seems a
>>> whole lot better.
>>>
>>> SteveT
>>
>> Yeah, messing with the initrd is just something I don't think I want
>> to do.  If you have any ideas as to why putting the module name is
>> /etc/modules doesn't work, or how to figure it out, I would continue
>> playing around with that, but, otherwise, I think I'm done.
>>
>> Marc
>
> Looking at the init scripts in /etc/init.d, I found kmod, which does a
> modprobe on the modules listed in /etc/modules.  The link to
> /etc/init.d/kmod is in /etc/rcS.d.  Unfortunately, it is just BEFORE
> the link to /etc/init.d/mountall.  So it attempts to install the
> modules just before it mounts the filesystem that contains /lib/modules.
>
> I have tried, unsuccessfully, to find a way to reorder the links so
> that the call to kmod would come just after the call to mountall.
>
> However, once I logon as myself, I can use sudo to run
> /etc/init.d/kmod and it seems to run without errors and X starts up
> without errors.
>
> Looks like time for another bash alias that will run this for me. Then
> I just need to run one command once the system is booted and I'm good
> for weeks, or months.  Basically, I'm good until another new kernel
> gets installed.  I don't reboot the system too often.
>
>
> Marc


I found the way to change the order of the init script for kmod, so that
it runs AFTER mountall.  It turns out to be easier than I had expected.

Each of the scripts in /etc/init.d contains a header of just under a
dozen lines.  These control the placement and order of the links to
these scripts within the /etc/rc?.d/directories.  One of the lines is "#
Required-Start:" which, by default, is blank for kmod.  This line
controls what other init scripts have to have already run | be active
when kmod runs.  Since it is blank, nothing else is required prior to
running it.  By changing this line to "# Required-Start:   
mountall-bootclean" it forces the command "update-rc.d kmod defaults" to
place the link to it AFTER the link to mountall-bootclean.sh (which runs
after the link to mountall.sh).  In this way, all local filesystems are
mounted prior to running kmod, and the kernel modules in /etc/modules
get properly loaded.

The only better solution that I can think of would be to find a way to
mount /lib/modules at the same time as /, before the system loads kernel
mods.  This would eliminate the need to determine which modules are not
getting loaded and placing their names in /etc/modules.  This solution,
however, has eluded me.

The only problem that I can see with my current solution is that it
might have problems if new, or different, hardware are attached to the
system, as this might change the required modules, and, hence, the list
required in /etc/modules.

I have also made /boot into a separate partition mounted from
/etc/fstab, but that, as I expected, caused no issues.  I will probably
place the 'modules' file in /boot and symlink to it from /etc/modules. 
That way, only a single copy of the file needs to be maintained.


Marc