:: Re: [DNG] What is an init system?
Startseite
Nachricht löschen
Nachricht beantworten
Autor: Ralph Ronnquist
Datum:  
To: dng
Betreff: Re: [DNG] What is an init system?
On Fri, May 31, 2024 at 11:12:08AM +0200, Didier Kryn wrote:
> Le 30/05/2024 à 20:15, karl@??? a écrit :
> > Kevin Chadwick:
> > ...
> > > Likely not much help but OpenBSD has static dev files and their
> > > hotplugd listens to events from the kernel on /dev/hotplug
> > You can have basically the same in linuxland, use a static /dev and
> > do (excerpt from https://git.busybox.net/busybox/tree/docs/mdev.txt):
> >
> > Here's a typical code snippet from the init script:
> > [0] mount -t proc proc /proc
> > [1] mount -t sysfs sysfs /sys
> > [2] echo /sbin/mdev > /proc/sys/kernel/hotplug
> >
> > and possible add mdev -s to fill /dev.
> >
>     'mdev -s' is typicaly what you do in the Busybox-based "pre"-init, the
> init which is run out of initramfs.
>
>     I do not call this static /dev.
>
>     A static /dev is when all the devices files in /dev are ready made and
> present in /dev before boot, and never change. Another thing is to have /dev
> just not mounted on tmpfs and populating it during the early init.
>
>     Karl, since you seem to have a pretty good understanding of this matter,
> may be a little tutorial would be welcome.


Afaict, mdev, udev and vdev are all "just" different rule interpreters
by which to define what to do upon discovery of hardware elements. But
none of them contain the actual rules. Therefore e.g. "mdev -s"
doesn't do anything; it would if I had a good /etc/mdev.conf and
that's where it stops for me.

At the moment I instead use a simple traversal of /sys to load modules
as suggested in readable modalias files, and repeat that while new
modules happen to be loaded. I believe this is a fairly "standard"
approach:

    find /sys/ -name modalias -perm /u=r -print0 | \
        xargs -0 cat | tr '\012' '\000' | \
    xargs -0 modprobe -abq 2>/dev/null


Doing so brings in the device driver foundation of modules that is
apprioriate for the hardware at hand but it doesn't load transmission
layer modules like "usb-storage" or "mmc-block", or even disk type
modules like "iso9660" or "exfat". That's because I don't have rules
that would translate the media detection to the additional modules
needed for accessing it.

For the installer's hybrid boot image there is only some few Mb to
play with as it also includes the kernel and (pruned) module tree. At
the moment the /sys/ traversal is augmented with force loading of
those additional modules, which relies on that any modules that don't
have its required hardware support either refuse to load, or stay
quietly loaded. (But there are a couple of oldish scsi drive modules
that cause system failure if their hardware is missing)

udev with it's "standard" rule collection would do the job but is too
large; and likewise for full vdev (from gnuinos). I don't now yet
about mdev: how large is the baggage of rules and support programs and
where are they?

Ralph.