Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#18421 - [initscripts] [udev] [mkinitcpio] Streamlined blacklisting (patches included)

Attached to Project: Arch Linux
Opened by Benjamin Richter (Waldteufel) - Sunday, 21 February 2010, 18:58 GMT
Last edited by Tom Gundersen (tomegun) - Saturday, 04 June 2011, 18:11 GMT
Task Type Feature Request
Category Arch Projects
Status Closed
Assigned To Tobias Powalowski (tpowa)
Aaron Griffin (phrakture)
Thomas Bächler (brain0)
Tom Gundersen (tomegun)
Architecture All
Severity High
Priority High
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Hello.

Here are three patches for streamlining blacklisting.

For every blacklisted module

install ${module} /bin/false

is written to a modprobe configuration file.

This effectively prevents ${module} from being loaded.
Thus, load-modules.sh is no longer needed.

initscripts.patch is for http://projects.archlinux.org/initscripts.git/
mkinitcpio.patch is for http://projects.archlinux.org/mkinitcpio.git/
udev.patch is for http://repos.archlinux.org/wsvn/packages/udev/

Kind regards,
Waldteufel
This task depends upon

Closed by  Tom Gundersen (tomegun)
Saturday, 04 June 2011, 18:11 GMT
Reason for closing:  Implemented
Additional comments about closing:  Changed a lot from the original proposal, but an equivalent implementation is now in testing.
Comment by Aaron Griffin (phrakture) - Friday, 30 April 2010, 17:20 GMT
Why create the blacklist in /dev like that, only to have it symlinked repeatedly if it doesn't exist. Wouldn't it make more sense to create it directly in /etc/modprobe.d/ ?

Also, this is going to parse the kernel cmdline twice. Not sure of a good way around that, though, except to just skip it in rc.sysinit... but then if someone does not use mkinitcpio, they don't get that feature.

And a third point: we should put big "### DO NOT EDIT THIS FILE" type guards on that autogenerated thing.

All in all, I like this. It should make boot faster, and it makes more sense now that modprobe can handle things like this.
Comment by Benjamin Richter (Waldteufel) - Friday, 30 April 2010, 18:54 GMT
/etc/modprobe.d could be readonly (e.g. in rc.sysinit before fsck was run), but /dev is always writeable, because it's on tmpfs.
Comment by Tom Gundersen (tomegun) - Friday, 08 October 2010, 17:33 GMT
Hi, I don't know if you guys are still working on this, but in case you are, I have a question/suggestion:
Is there any reason why the generation of the blacklisting file can not be done at shutdown rather than at boot? That would avoid having to create files in /dev. Furthermore, one could also create a file in /etc/modules.d/ for the modules that should be loaded, in order to avoid parsing the MODULES array at boot.
Any thoughts?
Comment by Benjamin Richter (Waldteufel) - Friday, 08 October 2010, 23:13 GMT
A very simple solution would be: Place a hand-written blacklist file in /etc/modprobe.d and use MODULES only for loading modules, not for blacklisting them.
Comment by Tom Gundersen (tomegun) - Wednesday, 01 December 2010, 22:52 GMT
@Waldteufel:

I used your idea in systemd's Arch support (but at shutdown rather than at boot) <https://github.com/teg/initscripts-systemd/commit/1e0b6aec1e4e8729336338bb5805156f9f5c9de6>. Seems to be working well. Killing /lib/udev/load-modules.sh speeds up boot considerably.

Is there anything in particular preventing these patches being applied? If there is interest, I could prepare patches to avoid generating files in /dev (by writing them at shutdown instead).
Comment by Tom Gundersen (tomegun) - Thursday, 05 May 2011, 17:01 GMT
I have an updated version of the original patch that I want to push to initscripts. That is, the blacklist file is created in /run/initscripts/ (which is always rw) and a symlink is placed in /etc/mod-probe.d/ to the autogenerated file.

Before I push this, I'd like to know if this truly would make load-modules.sh obsolete? Is the blacklisting we get by adding an install line to mod-probe.conf equivalent to blacklisting a module in rc.conf?
Comment by Thomas Bächler (brain0) - Thursday, 05 May 2011, 18:10 GMT
Okay, this is what I think:

1) Make sure we have a config file in /etc/modprobe.d/ that has an include statement for /run/initscripts/blacklist.conf
2) Make sure we regenerate the blacklist after we moved from mkinitcpio to initscripts.
3) Make sure udev uses modprobe -b!

This should take care of everything. Can you update the mkinitcpio packages as well.

Note: This is possible now because a) we don't have /etc/modprobe.conf anymore, only /etc/modprobe.d, b) we have /run. In this context, I like this idea much more than before.
Comment by Benjamin Richter (Waldteufel) - Thursday, 05 May 2011, 18:33 GMT
As far as I understand the manpage, with the -b switch "blacklist foo" should be sufficient instead of "install foo /bin/false".
Comment by Tom Gundersen (tomegun) - Thursday, 05 May 2011, 21:41 GMT
@Thomas,Benjamin: Thanks for the input (I did not know about the "modprobe -b"/blacklist combo).

I suggest adding the attached file to udev (/lib/udev/arch-blacklist-modules) and then patch mkinitcpio and initscripts to call this before starting udev. I would also add a symlink to the udev package /etc/modprobe.d/arch-modules-blacklist.conf -> /run/initscripts/modules-blacklist.conf.

I have quite some patches for our udev package (including this one), where is the best place to post them for review? <arch-projects@archlinux.org>?
Comment by Thomas Bächler (brain0) - Thursday, 05 May 2011, 21:52 GMT
1) udev uses modprobe -b by default these days. load-modules.sh should actually emulate that behaviour right now.
2) Haven't looked at the blacklist stuff, but it must be different in initramfs than in initscripts: initscripts has rc.conf and uses bash, busybox ash doesn't have rc.conf and doesn't understand array syntax.
3) Symlink vs. config file with include statement - does any have an advantage over the other?
4) About udev - you should talk to tpowa, maybe you could even take over udev maintenance. I think tpowa wouldn't mind if his workload was reduced.
Comment by Tom Gundersen (tomegun) - Thursday, 05 May 2011, 22:03 GMT
1) yes, this is the default, so it works out really well.
2) doh', yes you are right I forgot about the difference. might as well include this in initscripts straight away then, would make coordination easier.
3) what is the include syntax? i guess it will not make a difference one way or the other, I just could not find the include syntax in the modprobe.d man page.
4) I'd be happy to take over udev if tpowa doesn't want it, I'll talk to him about it.
Comment by Tom Gundersen (tomegun) - Thursday, 19 May 2011, 13:12 GMT
The initscripts part is now in git.

It uses the "blacklist <module>" syntax and only reads the MODULES array in rc.conf.

Allowing blacklisting via kernel parameters is useful if you are unable to boot your system due to a module. However, it should be enough to support this in mkinitcpio as this should allow you to edit your rc.conf and blacklist the module there.
Comment by Thomas Bächler (brain0) - Thursday, 19 May 2011, 13:30 GMT
Could you please also add the kernel command line code? This doesn't take much time in bash and may solve real problems.
Comment by Tom Gundersen (tomegun) - Thursday, 19 May 2011, 13:59 GMT
@brain0: We could do. I am looking into it now (trying to see what others are doing and asking on #udev).

The reason I didn't is that I'm struggling to understand the use-case. If your system is unbootable after an upgrade, then you'll have to somehow access your system to be able to figure out what module causes the problem. This can be done by booting with "init=/bin/bash", in which case udev will not be run. We should probably also fix single-user mode to not start udev, in which case that could also be used. Either way, you'll need to log on to your box, and once you are there you can just add the offending module to rc.conf, rather than rebooting and adding it to your kernel parameters.

My concern is that this code path would be so seldomly used that bugs could easily creep in.

(I'm routinely messing up my modprobe/udev/initscripts to make my system unbootable, but have never used anything but "init=/bin/bash" to fix it).

That said, I'm not strongly opposed to adding it, so will do if you think it is needed.
Comment by Thomas Bächler (brain0) - Thursday, 19 May 2011, 14:08 GMT
If a module stalls at boot, you can easily just add the disablemodules= statement and omit it.

It is also important for consistency between early and late userspace: If I blacklist a module using disablemodules=, I except that it is not loaded. When you ignore this setting, it will just be loaded later.
Comment by Tom Gundersen (tomegun) - Thursday, 19 May 2011, 14:50 GMT
@brain0: yeah, it makes sense. I think there is a nicer way to do it though (after discussing on #udev). This could and should be added upstream to module-init-tools.

The functionality would then be something like this:
modprobe.blacklist=mod1,mod2,...

Also, it would make sense for modprobe to read the autogenerated files in /run rather than having a symlink.

I'm waiting for the maintainer to tell me if he would accept these kind of patches, if so, I'll submit them.

In the meantime (as I guess it could take some time), I'll add this to the modprobe-blacklist generator script as you suggested.

Loading...