# How to prevent autoloading modules?

## jimmij

I have several modules (eg. uvcvideo, wl) which I do not want to be loaded on startup.

The problem is that they are loading anyway and I cannot figure out who to blame.

They are pulled from /lib/modules, but not all modules from there are loaded, eg. vboxdrv, vboxnetflt behaves normally.

I'm confused.

/etc/conf.d/modules is empty

Perhaps some init script calls them?

```

$> rc-update show

            alsasound | boot                                          

             bootmisc | boot                                          

          consolefont | boot                                          

                 dbus |      default                                  

                devfs |                                        sysinit

        device-mapper | boot                                          

               dhcpcd | boot                                          

                dmesg |                                        sysinit

                 fsck | boot                                          

                  gpm |      default                                  

             hostname | boot                                          

              hwclock | boot                                          

              keymaps | boot                                          

            killprocs |                        shutdown               

           lm_sensors |      default                                  

                local |      default nonetwork                        

           localmount | boot                                          

              modules | boot                                          

             mount-ro |                        shutdown               

                 mtab | boot                                          

             net.eth0 |      default                                  

               net.lo | boot                                          

               procfs | boot                                          

                 root | boot                                          

            savecache |                        shutdown               

                 swap | boot                                          

               sysctl | boot                                          

            syslog-ng |      default                                  

         termencoding | boot                      
```

kernel: 3.3.8-gentoo

----------

## khayyam

jimmij ...

simply add the modules to /etc/modprobe.d/blacklist.conf eg:

```
blacklist bluetooth
```

best ... khay

----------

## jimmij

Yes... this is some solution, but I would prefer to understand what is going on.  :Rolling Eyes: 

----------

## Gusar

It's the magic of hardware detection. The kernel knows you have a webcam, so it loads the appropriate module. Well, it's actually udev that loads the module, but because the kernel has told it a webcam is there. Now, before you ask why virtualbox modules aren't loaded automatically... well, virtualbox isn't a hardware device, so the kernel/udev combo that works for those can't work for virtualbox.

----------

## khayyam

 *jimmij wrote:*   

> Yes... this is some solution, but I would prefer to understand what is going on.

 

jimmij ... you didn't ask for a tutorial but "how to prevent autoloading modules" and I answered that question, so "eyerolls".

khay

----------

## jimmij

 *Gusar wrote:*   

> It's the magic of hardware detection. The kernel knows you have a webcam, so it loads the appropriate module. Well, it's actually udev that loads the module, but because the kernel has told it a webcam is there.

 

Oh, I see, that makes sense...

So another question: how can I politely ask udev and/or kernel to not load any modules without my explicit order?

I hope there is better (more general) rule than adding them one by one to the blacklist.

----------

## Gusar

 *jimmij wrote:*   

> So another question: how can I politely ask udev and/or kernel to not load any modules without my explicit order?

 

I'm not aware of anything, as that's kinda the point of udev. You could not use udev, but honestly, that's way more hassle than simply creating a few blacklist entries.

----------

## mv

 *Gusar wrote:*   

> that's way more hassle than simply creating a few blacklist entries.

 

I suppose that blacklist entries will prevent you from loading the module later manually.

I think the clean way is to put your own udev rule for the corresponding device in /etc/udev/rules.d which does nothing but to stop the later rules from being run. (I do not remember without reading the udev documentation how this is done, but I remember that this is possible)

----------

## olek

@mv

You are able to load them manually, blacklisted modules just don't get auto-loaded.

----------

