# How to prevent module auto-loading?

## xandris

Since upgrading to udev-089-r2, udev and the kernel (2.6.16-r2) collude to automatically load modules for every detected piece of hardware on my system.  This is overkill, as I really only need about half of what it loads at any given time.  How can I stop this?  I only want to make devices for modules that I specified in /etc/modules.autoload.d or have loaded myself.

----------

## itsmegawtf

```

cd /usr/src/linux;make menuconfig

```

and just turn off 'force module loading', etc.

----------

## xandris

Is there anything in between?  With module autoloading off in the kernel, mounting filesystems becomes a pain.  I don't need udev loading every module under the sun, but not having the kernel autoload anything is too spartan for me.

----------

## dsd

the latest baselayout allows you to configure this in /etc/conf.d/rc. it is called coldplugging.

----------

## nephros

I have the latest ( 1.12.0_pre19-r2) baselayout, have turned everything related to cold/hotplugging set to off in conf.d/rc and still almost every module I have compiled does get autoloaded.

I think it's udev, and haven't found a way to prevent him from doing that, not even through listing stuff in /etc/hotplug/blacklist or /etc/hotplug/blacklist.d.

It's very annoying because I simply don't want every single USB device I happen to have plugged in to activate and generally dislike the whole automatic stuff udev/hotplug/dbus/hal etc are doing.

[EDIT:] Discussion is already happening here.

----------

## nephros

 *dsd wrote:*   

> the latest baselayout allows you to configure this in /etc/conf.d/rc. it is called coldplugging.

 

Oh and if I read the comments in conf.d/rc correctly they don't do anything related to module loading at all, but control the starting of init scripts triggered by any hotplug/coldplug events:

 *Quote:*   

> # Dynamic /dev managers can trigger coldplug events which cause services to
> 
> # start before we are ready for them. If this happens, we can defer these
> 
> # services to start in the boot runlevel. Set RC_COLDPLUG="no" if you don't
> ...

 

----------

## dsd

thats correct, i read the original post too quickly. sorry for the misinformation.

----------

## eNTi

actually, i have a similar problem. at the moment i've a sata pci controller card and a module for it, that i don't want loaded at startup. i don't need the harddrive that's on that controller most of the time.

the real pain is, that if i start my machine, with my external harddrive switched on, it gets /dev/hdc1, if i switch it on, some time during the day (i don't need my external hdd powerd on all time either), it will be /dev/hdd1. i've no idea, how to tell fstab to get that right. obviously the loading order of my two harddrives depend on wether i've switched my external usb drive on or off. that's really annoying, as i have to change the entry in my fstab all the time.

----------

## Headrush

 *eNTi wrote:*   

> actually, i have a similar problem. at the moment i've a sata pci controller card and a module for it, that i don't want loaded at startup. i don't need the harddrive that's on that controller most of the time.
> 
> the real pain is, that if i start my machine, with my external harddrive switched on, it gets /dev/hdc1, if i switch it on, some time during the day (i don't need my external hdd powerd on all time either), it will be /dev/hdd1. i've no idea, how to tell fstab to get that right. obviously the loading order of my two harddrives depend on wether i've switched my external usb drive on or off. that's really annoying, as i have to change the entry in my fstab all the time.

 

Simple. Use custom udev rules so you have a static /dev/ node to reference.

Here's an example for my USB hard drive:

```
BUS="usb", SYSFS{idVendor}="067b", SYSFS{idProduct}="3507", NAME="External_USB_HD%n", SYMLINK="%k"
```

You can use lsusb to find the Vendor and Product IDs.

You could leave NAME="%k", and the SYMLINK= as the name you want. I switched the order because older versions of pmount had problems with symlinks.

----------

## eNTi

 *Headrush wrote:*   

>  *eNTi wrote:*   actually, i have a similar problem. at the moment i've a sata pci controller card and a module for it, that i don't want loaded at startup. i don't need the harddrive that's on that controller most of the time.
> 
> the real pain is, that if i start my machine, with my external harddrive switched on, it gets /dev/hdc1, if i switch it on, some time during the day (i don't need my external hdd powerd on all time either), it will be /dev/hdd1. i've no idea, how to tell fstab to get that right. obviously the loading order of my two harddrives depend on wether i've switched my external usb drive on or off. that's really annoying, as i have to change the entry in my fstab all the time. 
> 
> Simple. Use custom udev rules so you have a static /dev/ node to reference.
> ...

 

thx for the tip. where do i put that? should i create a new file for that, or do i have to comment out another part of 50-udev-rules for that?

----------

## Headrush

Usually you add them to /etc/udev/rules.d/10-local.rules

You can make any file in /etc/udev/rules.d/ you want, just use the same format. (#-name.rules)

Remember the number is important. Files are processed lowest to highest and the first rule found for a device is used no matter what rule may be parsed later.

----------

## eNTi

 *Headrush wrote:*   

> 
> 
> You can use lsusb to find the Vendor and Product IDs.
> 
> You could leave NAME="%k", and the SYMLINK= as the name you want. I switched the order because older versions of pmount had problems with symlinks.

 

lsusb gives me that:

```
Bus 001 Device 004: ID 04fc:0c15 Sunplus Technology Co., Ltd
```

what is vendor and what is product id? i guess 04fc is vendor and 0c15 product?

----------

## Headrush

 *eNTi wrote:*   

> 
> 
> ```
> Bus 001 Device 004: ID 04fc:0c15 Sunplus Technology Co., Ltd
> ```
> ...

 

Correct.

----------

## eNTi

thank you.

----------

## eNTi

i've tried it out and well... it does not work. i ask myself how it should work anyhow, because it can't register my usb hdd if it's turned off during reboot anyways. so it still changes between hdc and hdd, depending if my drive is turned on or off. isn't there no simple solution? like blocking a module from being loaded? i'm not even mounting the harddrive on promise pci controller. i don't want that module loaded. only if i need it.

----------

## Headrush

 *eNTi wrote:*   

> i've tried it out and well... it does not work. i ask myself how it should work anyhow, because it can't register my usb hdd if it's turned off during reboot anyways. so it still changes between hdc and hdd, depending if my drive is turned on or off. isn't there no simple solution? like blocking a module from being loaded? i'm not even mounting the harddrive on promise pci controller. i don't want that module loaded. only if i need it.

 

Post the udev rule you made. Did you restart udev?

```
udevstart
```

It doesn't matter that it changes between hdc and hdd. The custom udev rule will create the symlink that always point to the correct one. You use the symlink, not hdc or hdd. (Unless you just use a custom name and no symlink, same idea though)

----------

## eNTi

 *Headrush wrote:*   

>  *eNTi wrote:*   i've tried it out and well... it does not work. i ask myself how it should work anyhow, because it can't register my usb hdd if it's turned off during reboot anyways. so it still changes between hdc and hdd, depending if my drive is turned on or off. isn't there no simple solution? like blocking a module from being loaded? i'm not even mounting the harddrive on promise pci controller. i don't want that module loaded. only if i need it. 
> 
> Post the udev rule you made. Did you restart udev?
> 
> ```
> ...

 

oh man i'm so stupid. i just didn't READ right. of course it's creating a symlink. it's working fine. thank you again.

----------

