I was playing around with initramfs generation and kernel modules. I thought a fun thing to do would be to prevent modules from loading to turn off my laptop's devices. And that worked for some modules, r592 for example. But when I blacklisted, e.g., sr_mod (cdrom drive) and sdhci_pci (SD reader) modules, they still loaded at boot. Mkinitcpio -v adds them in initramfs, journalctl says nothing of them being blacklisted, and lsmod doesn't list them as 'Used By' any other modules, which would be a reason for them being loaded although they're blacklisted.
I didn't notice any errors being reported.
Does somebody have an idea of what could be the cause of this?
In mkinitcpio.conf I add just nouveau under MODULES and don't add BINARIES or FILES. My hooks are:
HOOKS="base udev autodetect modconf block filesystems keymap fsck"
forgot to post mkinitcpio.conf and blacklist.conf
Last edited by Neven (2014-08-27 21:17:19)
Can you just rmmod them with a script during startup? Check with mkinitcpio --automods what modules are added to the init image.
Last edited by Pse (2014-08-27 03:05:34)
Well --automods is the same as -M (the output of which I posted), but that just shows which modules were detected, it doesn't take blacklisting into account. But according to mkinitcpio -v the modules are added to initramfs image.
After a few boots blacklisting works fine. I still don't know why. Maybe the 'rmmod sr_mod' "unfreezed" module handling or something like that?
Last edited by Neven (2014-08-27 03:55:49)
I am not sure about this (I should check the source), but I think mkinitcpio uses the list of loaded and active modules to determine which modules to add to the image. If that were the case, it would explain why you were able to keep it from adding the module by manually removing it before running mkinitcpio. Perhaps an Arch dev could confirm this.
Last edited by Pse (2014-08-27 04:18:21)
@Pse: I thought of that too, but that doesn't wholly explain it - I manually removed just sr_mod, I did not rmmod sdhci_pci; but now they're all missing as they should be.
I realized I wrongly assumed mkinitcpio module installation hooks take modprobe configuration files in account (blacklist.conf), and so half my first post was a redundant mess. I'm sorry for that.
The proper procedure for preventing modules from being included in the initramfs image is then probably to remove the hook which adds them, and manually specifying them for inclusion in the image by putting their names to the MODULES variable.
I guess, since the blacklisting now works properly, I'll mark this as solved.
The modules loaded although blacklisted, but they wouldn't have been blacklisted in the initial ramdisk environment if I had forgotten to update it with mkinitcpio, which is quite possible. So that's probably the reason why blacklisting didn't work.
Last edited by Neven (2014-08-27 23:16:24)