Re: Initramfs Scripts

"Pierre Labastie" ([email protected] via blfs-dev Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.beyond.devel
Message-ID <[email protected]>
Hi,
Comments in the text, and attached propositions for both files
On Thu, 2025-06-05 at 17:34 -0400, Rahul Chandra wrote:
> On Thu, Jun 5, 2025 at 4:03 PM Joe Locash
> <[email protected]> wrote:
> > 
> > On 6/5/25 1:39 PM, Rahul Chandra ([email protected] via blfs-
> > dev
> > Mailing List) wrote:
> > > Currently the initramfs scripts in BLFS are entirely broken,
> > > meaning
> > > even the limited subset of features we say to use an initramfs
> > > for
> > > (drive encryption, network boot, and LVM) don't function. Here is
> > > a
> > > list of the issues
> > > 
> > > 1. /etc/group missing -- The default 50-default-udev rule
> > > requires the
> > > base groups from LFS in order to load properly

Since we use --resolve-names=never, group and user names are never
resolved, so /etc/group is not needed.

> > > 2. Missing libkmod.so files, udev (at least on systemd) can't
> > > load
> > > modules without a library link to kmod

systemd udev use dlopen to load libkmod.so. This means this library is
not shown when running ldd. It has to be included manually.

> > > 3. Missing cgroup mount -- Control groups are almost required
> > > nowadays
> > > to load modules properly, we need to add a control group mount in
> > > /sys/fs/cgroup to fix this

I've been able to run the initrd without mounting cgroup, but I guess
it needs further testing. I've removed the mount command.

> > > 4. udevadm trigger command. I don't know when this changed but
> > > udevadm
> > > trigger doesn't load modules anymore, you need to add the --
> > > action=add
> > > flag for it to actually load the modules
> > > 

Nope --action=add does not mean to load the modules, it means to
trigger "add" events instead of "change" events. I've kept it since it
seems to work ok.


> > > Other fixes I did a long time ago
> > > 
> > > 5. This is an issue I had fixed a few years ago in my homebrewed
> > > version of the initramfs scripts -- The initramfs scripts
> > > currently
> > > pick a subset of modules on the system. In this version, it
> > > dynamically finds the modules currently loaded and adds them to
> > > the
> > > initramfs

Actually no. It looks for modules in more subdirectories than
previously. Note that finding currently loaded modules imposes an
already running kernel, but if you are making a initrd for a new
kernel, you cannot use this method...
I've added a few more subdirectories, that seemed needed for loading
all modules on which needed modules depend...

> > > 6. Firmware -- Loading firmware in the initramfs (required for
> > > some
> > > RAID cards and network cards) was not supported with the old
> > > scripts.

That's not true, Previous version blindly copied all firmware in
/usr/lib/firmware...

> > > These one's copy the firmware based on the modules that are
> > > currently
> > > loaded.

Same problem as above, this prevent making an initrd for a new
kernel... I've moved the commands to copy firmware so that they copy
only firmware for modules included in the initrd.
> > > 
> > > Other nice to haves  in this version
> > > 7. Forceful early module load -- I added a /etc/early-modules-
> > > load.conf file
> > > cat > /etc/early-modules-load.conf << EOF
> > > # This file is for loading modules in the early boot stages in
> > > the initramfs
> > > EARLY_LOAD_MODULES=""
> > > EOF
> > > To allow for loading modules that aren't required for the system
> > > (e.g
> > > vfio or kvmgt for gvt-g/iommu)

I've simplified the sed command a bit, and included the commands in an
if ... fi block to not run it when early_modules_load.conf is not
present.

> > > 8. Modprobe.d support -- to support the last point, config files
> > > in
> > > /etc/modprobe.d are obeyed.

Ok, not changed...
> > > 
> > > If someone could test this on sysv and let me know how it goes I
> > > can
> > > push this to the book and file an errata.

All my tests are on sysv, but I think there is no difference with
systemd, since systemd is not run in early environment (only udev,
which is the same for sysv and sysd).

Regards
Pierre

-- 
http://lists.linuxfromscratch.org/sympa/info/blfs-dev
Unsubscribe: See the above information page
init.in (application/x-shellscript, 3.4 KB) - not displayed
mkinitramfs (application/x-shellscript, 7.8 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.