2020-12-08 09:28:23

by Paul Menzel

[permalink] [raw]
Subject: Pass modules to Linux kernel without initrd

Dear Linux folks,


Trying to reduce the boot time of standard distributions, I would like
to get rid of the initrd. The initrd is for mounting the root file
system and on most end user systems with standard distributions that
means loading the bus driver for the drive and the file system driver.
Everyone could build their own Linux kernel and build the drivers into
the Linux kernel, but most users enjoy using the distribution Linux
kernel, which build the drivers as modules to support a lot of systems.
(I think Fedora builds the default file system driver (of the installer)
into the Linux kernel.)

A custom minimal initrd init script only loading the modules would also
work, but as libkmod depends on libcrypto, which as a shared library is
already three megabytes in size. Building libkmod statically would mean
for distributions, that you need hooks to rebuild libkmod each time
OpenSSL is updated (to get the changes).

Similar to passing firmware and microcode update files to Linux or
building these into the Linux kernel image, would it be possible to
append the required modules to the Linux kernel image, and Linux would
load these?

Probably you are going to say, that is not how it works, but maybe I am
lucky and you know a solution, or could point me to the right direction
how such a think could be implemented.


Kind regards,

Paul


Subject: Re: Pass modules to Linux kernel without initrd

On 08.12.20 10:24, Paul Menzel wrote:

> Similar to passing firmware and microcode update files to Linux or
> building these into the Linux kernel image, would it be possible to
> append the required modules to the Linux kernel image, and Linux would
> load these?

Indeed, yes it does. Just set the corresponding CONFIG_ symbols to 'y'
instead of 'm'. If you don't need to dynamically load any modules
(already have everything you need compiled-in), you can completely
disable module support via disabling CONFIG_MODULES.

For embedded systems, this is quite common. I'm also using it for
trimmed down virtualized workloads that don't ever need to dynamically
load modules.

--mtx

--
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
[email protected] -- +49-151-27565287

2020-12-08 11:02:27

by Paul Menzel

[permalink] [raw]
Subject: Re: Pass modules to Linux kernel without initrd

Dear Enrico,


Am 08.12.20 um 10:38 schrieb Enrico Weigelt, metux IT consult:
> On 08.12.20 10:24, Paul Menzel wrote:
>
>> Similar to passing firmware and microcode update files to Linux or
>> building these into the Linux kernel image, would it be possible to
>> append the required modules to the Linux kernel image, and Linux would
>> load these?
>
> Indeed, yes it does. Just set the corresponding CONFIG_ symbols to 'y'
> instead of 'm'. If you don't need to dynamically load any modules
> (already have everything you need compiled-in), you can completely
> disable module support via disabling CONFIG_MODULES.

[…]

Thank you. I know this and do it myself. But, the requirement is to use
the distribution Linux kernel (package). I am sorry for being unclear.


Kind regards,

Paul

2020-12-08 20:29:15

by Ben Hutchings

[permalink] [raw]
Subject: Re: Pass modules to Linux kernel without initrd

On Tue, 2020-12-08 at 10:24 +0100, Paul Menzel wrote:
Dear Linux folks,


Trying to reduce the boot time of standard distributions, I would like
to get rid of the initrd. The initrd is for mounting the root file
system and on most end user systems with standard distributions that
means loading the bus driver for the drive and the file system driver.
[...]

I would expect most end user systems to use at least one of LVM and
cryptsetup, which need user-space to configure them.

Debian has the "tiny-initramfs" package that covers the simple cases
you're targetting, and can be used instead of initramfs-tools or
dracut. The upstream of that is:
<https://github.com/chris-se/tiny-initramfs/>.

But I don't anticipate that we would change the default initramfs
builder any time soon.

Ben.

--
Ben Hutchings
The world is coming to an end. Please log off.


Attachments:
signature.asc (849.00 B)
This is a digitally signed message part

2020-12-08 20:57:52

by Theodore Ts'o

[permalink] [raw]
Subject: Re: Pass modules to Linux kernel without initrd

On Tue, Dec 08, 2020 at 10:24:08AM +0100, Paul Menzel wrote:
> Dear Linux folks,
>
> Trying to reduce the boot time of standard distributions, I would like to
> get rid of the initrd. The initrd is for mounting the root file system and
> on most end user systems with standard distributions that means loading the
> bus driver for the drive and the file system driver. Everyone could build
> their own Linux kernel and build the drivers into the Linux kernel, but most
> users enjoy using the distribution Linux kernel, which build the drivers as
> modules to support a lot of systems. (I think Fedora builds the default file
> system driver (of the installer) into the Linux kernel.)

It's unclear what you are trying to speed up by replacing the initrd
with "appending the required modules to the Linux kernel image". Why
do you think this will speed things up? What do you think is
currently slow with using an initrd?

If what you are concerned about is the speed to load an initrd which
has all of the kernel modules shipped by the distribution, including
those not needed by a particular hardware platform, there are
distributions which can be configured to automatically include only
those kernel modules needed for a particular system.

There are also some shell scripts which some people have written that
will automatically create a kernel config file which only has the
device drivers needed for a particular system. Creating a system
which used such a script, and then compiled a custom kernel image
would also not be hard.

You seem to be assuming that building a custom kernel image ish
hard(tm), and so no user would want to do this. If this were
automated, what is your objection to such an approach?

Without a clear understanding what part of the boot process you think
is slow, and which you are trying to optimize, and what precisely your
constraints are, or at least, what you *think* your constraints are,
and why you think things have to be that way, it's going to be hard to
comment further.

Cheers,

- Ted

Subject: Re: Pass modules to Linux kernel without initrd

On 08.12.20 11:58, Paul Menzel wrote:

> Thank you. I know this and do it myself. But, the requirement is to use
> the distribution Linux kernel (package). I am sorry for being unclear.

What about rebuilding the distro package ?

Actually, I wonder why using a generic (bloated) full-blown distro
when resources are that scarce.


--mtx

--
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
[email protected] -- +49-151-27565287