On Tue, May 10, 2011 at 10:02:07AM +0200, Tom Gundersen wrote: > Hi guys, > > This is in regards to FS#18421. > > I am looking at ways to move our udev package closer to upstream. The > biggest difference is currently our load-modules.sh script which > filters out what modules to load. This adds significant overhead to > boot, so I think it is the first thing that should go. > > The below patch generate a blacklist file at boot from rc.conf, which > should be linked to by a softlink in /etc/modprobe.d/. This allows > udev to figure out blacklisting by itself. > > Once this is in initscripts and a similar patch is in mkinitcpio, then > we can ditch load-modules.sh. > > One thing to note: the attached patch does "blacklist <module>" (which > allows modules to be pulled in as dependencies). We could also do > "install <module> /bin/false" (which has the same effect as deleting > the module altogether), if that is necessary. I chose to use blacklist > as it looks to be the recommended way. > > Thoughts? > > Cheers, > > Tom
I'm going to argue that we should be going the install /bin/false route, as it more accurately mimics what we currently do with load-modules.sh. This does have the drawback that if a user really does in fact want to install a given module, they need to run modprobe with -i. I don't recall if load-modules.sh allows explicit installation of a "blacklisted" module. Important: for your patchwork to be effective, we need to alter the udev rules that reference load-modules.sh. If this isn't done for the initcpio, you will almost assuredly be dumped to a rescue shell. Other than alteration of the rules, this should be an easy win in the initcpio, as we have a writeable filesystem from the start. And (correct me if im wrong), the only reason we ever need to write a blacklist file is if disablemodules= is specified on the kernel cmdline. /etc/rc.conf is verboten in early userspace because it uses arrays. As I mentioned to you on your GH pull request, I'm still a bit weary of starting up a symlink farming business in /run. I would love to see module-init-tools support for reading from /run/modprobe.d, but perhaps that's a bit of an exotic request. With the FHS revived and gearing up for a release, it seems likely that /run will be standardized, but I'm not sure if that has any clout here. semi-random aside: does anyone other than systemd support /etc/modules-load.d? d (uggh, way longer than i wanted this to be) > > From 56e6e5684d40b66d810a3d7d424b5aabec6d660e Mon Sep 17 00:00:00 2001 > From: Tom Gundersen <[email protected]> > Date: Mon, 9 May 2011 22:15:43 +0200 > Subject: [PATCH] udev: generate blacklist on boot > > udev will read /etc/modprobe.d/*.conf and blacklist all modules that > are listed as > > blacklist <module> > > We parse rc.conf at boot and generate such a .conf file. It cannot be > written to /etc this early, so we save it to /run. A symlink exists in > /etc to get the desired functionality. > > While we are at it we also write the list of autoloaded. This is > useful in case we ever want to move to using > /etc/modules-load.d/*.conf for loading modules. > > With this patch load-modules.sh can be removed from the udev package > without loss of functionality. > > Original-idea-by: Benjamen Richer <[email protected]> > Based-on-patch-by: David Reisner <[email protected]> > Signed-off-by: Tom Gundersen <[email protected]> > --- > Makefile | 4 +++- > rc.gen-module-lists | 32 ++++++++++++++++++++++++++++++++ > rc.sysinit | 3 +++ > 3 files changed, 38 insertions(+), 1 deletions(-) > create mode 100755 rc.gen-module-lists > > diff --git a/Makefile b/Makefile > index d3a1824..dfb2ff0 100644 > --- a/Makefile > +++ b/Makefile > @@ -1,5 +1,5 @@ > VER := $(shell git describe) > -DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin > +DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly > /sbin /etc/modprobe.d /etc/module-load.d > > minilogd: minilogd.o > > @@ -13,6 +13,8 @@ install: minilogd installdirs > install -m755 -t $(DESTDIR)/etc/cron.hourly adjtime > install -m755 -t $(DESTDIR)/etc/rc.d functions hwclock network netfs > install -m755 -t $(DESTDIR)/sbin minilogd rc > + ln -s /run/initscripts/modules-blacklist.conf > $(DESTDIR)/etc/modprobe.d/arch-blacklist.conf > + ln -s /run/initscripts/modules-load.conf > $(DESTDIR)/etc/modules-load.d/arch-modules.conf > > clean: > rm -f minilogd minilogd.o > diff --git a/rc.gen-module-lists b/rc.gen-module-lists > new file mode 100755 > index 0000000..14f9619 > --- /dev/null > +++ b/rc.gen-module-lists > @@ -0,0 +1,32 @@ > +#!/bin/bash > +# > +# /etc/rc.gen-modules-list > +# > + > +. /etc/rc.conf > + > +declare -a modules blacklist > +for mod in "${MODULES[@]}"; do > + case $mod in > + !*) blacklist+=("${mod:1}") ;; > + *) modules+=("$mod") ;; > + esac > +done > + > +# create new module blacklist in /run/initscripts, there should be a > symlink in /etc/modprobe.d/ pointing here > +if [[ $blacklist ]]; then > + /bin/mkdir -p /run/initscripts > + echo "# Autogenerated from rc.conf at boot, do not edit" > > /run/initscripts/modules-blacklist.conf > + (( ${#blacklist[@]} )) && printf 'blacklist %s\n' "${blacklist[@]}" > >> /run/initscripts/modules-blacklist.conf > +fi > + > +# create new module list in /run/initscripts, there should be a > symlink in /etc/modules-load.d/ pointing here > +if [[ $modules ]]; then > + /bin/mkdir -p /run/initscripts > + echo "# Autogenerated from rc.conf at boot, do not edit" > > /run/initscripts/modules-load.conf > + printf '%s\n' "${modules[@]}" >> /run/initscripts/modules-load.conf > +fi > + > +unset blacklist modules > + > +# vim: set noet ts=2 sw=2: > diff --git a/rc.sysinit b/rc.sysinit > index 1521299..4e45d7c 100755 > --- a/rc.sysinit > +++ b/rc.sysinit > @@ -83,6 +83,9 @@ if [[ $HWCLOCK_PARAMS ]]; then > fi > fi > > +# parse rc.conf and create the blacklist file for use by udev > +status "Creating UDev blacklist" /etc/rc.gen-module-lists > + > status "Starting UDev Daemon" /sbin/udevd --daemon > > run_hook sysinit_udevlaunched > -- > 1.7.5.1
