# duplicates in "modprobe -c"

## wu-s

Hi there,

the output of "modprobe -c" contains duplicate entries:

```
$ modprobe -c | wc -l

2261

$ modprobe -c | sort -u | wc -l

2097
```

I noticed it, as /etc/init.d/alsasound tries to setup the sound-modules twice:

```
$ /etc/init.d/alsasound start

 * Loading ALSA modules ...

 *   Loading: snd-card-0 ...                                               [ ok ]

 *   Loading: snd-card-1 ...                                               [ ok ]

 *   Loading: snd-card-0 ...                                               [ ok ]

 *   Loading: snd-card-1 ...                                               [ ok ]

 *   Loading: snd-emu10k1-synth ...                                        [ ok ]

 *   Loading: snd-seq-midi ...                                             [ ok ]

 * Restoring Mixer Levels ...                                              [ ok ]
```

To begin with, "update-modules" is up-to-date and has nothing to do:

```
$ update-modules --verbose

 * You have /etc/modules.d, so things need to get coalesced

 * modules.conf: already up-to-date wheatness

 * modules.dep: already up-to-date goodness

 * modprobe.conf: already up-to-date nutness
```

Here is the content of /etc/modprobe.d and /etc/modules.d:

```
$ ls -l /etc/modules.d

total 8

-rw-r--r-- 1 root root 1216 2009-03-21 19:02 aliases

-rw-r--r-- 1 root root  122 2009-03-21 19:02 i386

$ ls -l /etc/modprobe.d

total 20

-rw-r--r-- 1 root root 1201 2009-03-25 14:25 alsa

-rw-r--r-- 1 root root  854 2009-03-21 19:01 blacklist

-rw-r--r-- 1 root root  549 2009-03-22 01:26 lirc

-rw-r--r-- 1 root root  647 2009-03-21 23:02 nvidia

-rw-r--r-- 1 root root  537 2009-03-21 19:01 pnp-aliases
```

As expected, "update-modules" generates /etc/modules.conf and /etc/modprobe.conf like:

```
$ cat /etc/modules.conf

### This file is automatically generated by update-modules

#

# Please do not edit this file directly. If you want to change or add

# anything please take a look at the files in ./etc/modules.d and read

# the manpage for update-modules(8).

#

### update-modules: start processing /etc/modules.d/aliases

<CONTENT OF /etc/modules.d/aliases>

### update-modules: end processing /etc/modules.d/aliases

### update-modules: start processing /etc/modules.d/i386

<CONTENT OF /etc/modules.d/i386>

### update-modules: end processing /etc/modules.d/i386

$ cat /etc/modprobe.conf

### This file is automatically generated by update-modules

#

# Please do not edit this file directly. If you want to change or add

# anything please take a look at the files in /etc/modprobe.d and read

# the manpage for update-modules(8).

#

<PARSED CONTENT OF /etc/modules.conf>

### update-modules: start processing /etc/modprobe.d/alsa

<CONTENT OF /etc/modprobe.d/alsa>

### update-modules: end processing /etc/modprobe.d/alsa

### update-modules: start processing /etc/modprobe.d/blacklist

<CONTENT OF /etc/modprobe.d/blacklist>

### update-modules: end processing /etc/modprobe.d/blacklist

### update-modules: start processing /etc/modprobe.d/lirc

<CONTENT OF /etc/modprobe.d/lirc>

### update-modules: end processing /etc/modprobe.d/lirc

### update-modules: start processing /etc/modprobe.d/nvidia

<CONTENT OF /etc/modprobe.d/nvidia>

### update-modules: end processing /etc/modprobe.d/nvidia

### update-modules: start processing /etc/modprobe.d/pnp-aliases

<CONTENT OF /etc/modprobe.d/pnp-aliases>

### update-modules: end processing /etc/modprobe.d/pnp-aliases

```

OK, that seems pretty reasonable (apart from the kind of weird distinction between modules.conf and modprobe.conf). But now, here is what modprobe thinks about his config:

```
$ modprobe -c

<CONTENT OF /etc/modprobe.conf>

<CONTENT OF /etc/modprobe.d/blacklist>

<CONTENT OF /etc/modprobe.d/pnp-aliases>

<CONTENT OF /etc/modprobe.d/nvidia>

<CONTENT OF /etc/modprobe.d/lirc>

<CONTENT OF /etc/modprobe.d/alsa>

alias acpi*:ACPI0003:* ac

alias acpi*:PNP0C0B:* fan

alias acpi*:PNPb006:* snd_mpu401

alias acpi*:WEC0517:* wbsd

...

```

So, obviously the files in /etc/modprobe.d are included twice! The first time via /etc/modprobe.conf and a second time via the direct include from /etc/modprobe.de/.

1) Does anybody know what's going on here? 

2) Where does all that dynamically generated stuff after the alsa-include come from?

Thanks and cheers,

Sven

------

```
$ equery l module-init-tools

[ Searching for package 'module-init-tools' in all categories among: ]

 * installed packages

[I--] [  ] sys-apps/module-init-tools-3.5 (0)
```

```
$  emerge --info

Portage 2.1.6.7 (default/linux/amd64/2008.0/desktop, gcc-4.1.2, glibc-2.8_p20080602-r1, 2.6.27-gentoo-r8 x86_64)

=================================================================                                               

System uname: Linux-2.6.27-gentoo-r8-x86_64-Intel-R-_Core-TM-2_CPU_6600_@_2.40GHz-with-glibc2.2.5               

Timestamp of tree: Tue, 24 Mar 2009 09:45:01 +0000                                                              

app-shells/bash:     3.2_p39                                                                                    

dev-java/java-config: 2.1.7                                                                                     

dev-lang/python:     2.5.2-r7                                                                                   

dev-util/cmake:      2.6.3

sys-apps/baselayout: 1.12.11.1

sys-apps/sandbox:    1.3.8

sys-devel/autoconf:  2.13, 2.63

sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2

sys-devel/binutils:  2.18-r3

sys-devel/gcc-config: 1.4.0-r4

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.27-r2

ACCEPT_KEYWORDS="amd64"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=nocona -O3 -fomit-frame-pointer -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"

CXXFLAGS="-march=nocona -O3 -fomit-frame-pointer -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://mirrors.sec.informatik.tu-darmstadt.de/gentoo/ http://de-mirror.org/distro/gentoo/"

LC_ALL="en_US.UTF-8"

LDFLAGS="-Wl,-O1"

LINGUAS="en de"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/portage/local/layman/lcd-filtering"

SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

USE="X a52 aac aalib acl acpi alsa amd64 berkdb branding browserplugin bzip2 cairo caps cdparanoia cdr chm cli cracklib crypt cups dbus doc dri dts dvb dvd dvdr dvdread emboss encode evo exif fam ffmpeg firefox flac fortran gdbm gif glitz gmp gnome gpm gstreamer gtk hal iconv ieee1394 imagemagick ipv6 isdnlog java jpeg jpeg2k kde ldap libnotify lirc lm_sensors mad midi mikmod mmap mmx mng mp3 mpeg mudflap multilib musicbrainz mysql ncurses nls nptl nptlonly nsplugin ogg opengl openmp pam pcre pdf perl plasma png posix ppds pppd python qt3 qt3support qt4 quicktime readline recode reflection ruby sdl session smp spell spl sse sse2 ssl ssse3 startup-notification subversion svg sysfs tcpd theora threads tiff truetype ubuntu unicode usb vnc vorbis wmf x264 xattr xcomposite xinerama xml xorg xscreensaver xulrunner xv xvid xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expiresext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewritesetenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en de" LIRC_DEVICES="devinput" USERLAND="GNU" VIDEO_CARDS="nv nvidia"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
```

Last edited by wu-s on Wed Mar 25, 2009 2:33 pm; edited 2 times in total

----------

## Sadako

It looks to me like most of the duplicate entries are just blank comments, ie just '#' or '##', at least on my setup.

What does `modprobe -c | sort | uniq -d` return?

----------

## wu-s

Thanks for the hint. But the duplicates are the multiple includes, indeed: via /etc/modprobe.conf and /etc/modprobe.d/<file>.

However, according to man modprobe.conf(5), the behaviour should be exclusive:

 *Quote:*   

> MODPROBE.CONF(5)                                                                     MODPROBE.CONF(5)
> 
> NAME
> 
>        modprobe.conf, modprobe.d - Configuration file/directory for modprobe
> ...

 

OK, here are the duplicates found in /etc/modprobe.conf and in the corresponding /etc/modprobe.d/<file>:

```
$  modprobe -c | sort | uniq -d                                                              

#

# 

##

# Add your own entries to this file

alias char-major-116 snd           

alias char-major-14 soundcore      

alias char-major-195 nvidia        

alias /dev/dsp snd-pcm-oss         

alias /dev/midi snd-seq-oss        

alias /dev/mixer snd-mixer-oss     

alias /dev/nvidiactl char-major-195

alias pnp:dPNP0303 atkbd           

alias pnp:dPNP0510 irtty-sir       

alias pnp:dPNP0511 irtty-sir       

alias pnp:dPNP0700 floppy          

alias pnp:dPNP0800 pcspkr          

alias pnp:dPNP0b00 rtc             

alias pnp:dPNP0f13 psmouse         

alias pnp:dPNPb02f analog          

alias snd-card-0 snd-emu10k1       

## alias snd-card-0 snd-interwave  

alias snd-card-1 cx88_alsa         

## alias snd-card-1 snd-ens1371    

alias sound-service-0-0 snd-mixer-oss

alias sound-service-0-12 snd-pcm-oss 

alias sound-service-0-1 snd-seq-oss  

alias sound-service-0-3 snd-pcm-oss  

alias sound-service-0-8 snd-seq-oss  

## alias sound-service-1-0 snd-mixer-oss

## alias sound-service-1-12 snd-pcm-oss 

## alias sound-service-1-3 snd-pcm-oss  

## alias sound-slot-0 snd-card-0        

alias sound-slot-0 snd-emu10k1          

alias sound-slot-1 cx88_alsa            

## alias sound-slot-1 snd-card-1        

# Alsa kernel modules' configuration file.

# ALSA portion                            

##  ALSA portion                          

## and then run `update-modules' command. 

# Autoloading eth1394 most of the time re-orders your network

blacklist eth1394                                            

blacklist evbug                                              

#blacklist pcspkr                                            

#blacklist usbkbd                                            

#blacklist usbmouse

# compiled into your kernel, or as a module but loaded before

# COMPROMISE, OR IRREPARABLY DAMAGE THE MACHINE.

# Detach first serial port from serial-driver.

# DO NOT MODIFY OR REMOVE THE DEVICE FILE RELATED OPTIONS UNLESS YOU KNOW

# /etc/modprobe.d/pnp-aliases

# evbug is a debug tool and should be loaded explicitly

# For first serial receivers:

# For parallel receivers:

# (if not blacklisted somewhere else)

## IMPORTANT:

#install lirc_serial setserial /dev/ttyS0 uart none; modprobe --ignore-install lirc_serial

#install lirc_sir    setserial /dev/ttyS0 uart none; modprobe --ignore-install lirc_sir

#install pci:v*d*sv*sd*bc03sc*i* /bin/true

# interfaces, and with buggy kernel 2.6.21, udev persistent-net

# in the format "blacklist <name of module>"

# is not able to rename these devices, so you get eth?_rename devices

# not at coldplugging and not on hotplug events.

# Nvidia drivers support

# ONLY ADD TRUSTED USERS TO THE VIDEO GROUP, THESE USERS MAY BE ABLE TO CRASH,

options cx88_alsa index=1

#options lirc_parallel irq=7 io=0x3bc

#options lirc_serial irq=4 io=0x3f8

#options lirc_sir irq=4 io=0x3f8

options nvidia NVreg_DeviceFileMode=432 NVreg_DeviceFileUID=0 NVreg_DeviceFileGID=27 NVreg_ModifyDeviceFiles=1

# options see /usr/share/doc/nvidia-drivers-180.29/README

options snd cards_limit=2

options snd-emu10k1 index=0

# OSS/Free portion

##  OSS/Free portion

# OSS/Free portion - card #1

##  OSS/Free portion - card #2

# plus an exceeded 30sec boot timeout

## Read alsa-driver's INSTALL file in /usr/share/doc for more info.

# !!! SECURITY WARNING !!!

# Set this to the correct number of cards.

# Some examples:

# Sometimes loading a framebuffer driver at boot gets the console black

# SUBSYSTEM=="pnp", ENV{MODALIAS}!="?*", RUN+="/bin/sh -c '/sbin/modprobe -a $$(while read id; do echo pnp:d$$id; done < /sys$devpath/id)'"

# the lirc-module.

# These aliases are used by this udev-rule:

# these drivers are very simple, the HID drivers are usually preferred

# They should help to autoload drivers used by various pnp-devices

# This file lists modules which will not be loaded by udev,

# To tweak the driver the following options can be used, note that

# Use this when you have your serial-port-driver statically

# WHAT YOU ARE DOING.

## You need to customise this section for your specific sound card(s)

# You probably want this to not get the console beep loud on every tab :)

# you should be careful, as it could cause instability!! For more
```

----------

## wu-s

I investigated the issue further and could attach the "double-includes" to module-init-tools-3.5.

Here is what I did:

1) Setup a new gentoo x86 in a virtual machine using the install-x86-minimal-2008.0.iso image and a stage3 tarball

1.1) systems gets module-init-tools-3.4

1.2) "modprobe -c" behaves as expected: no "double includes" from /etc/modules.d/* and /etc/modules.conf

2) Update the installation: "emerge --sync" and "emerge --uD world"

2.1) now the installation uses module-init-tools-3.5

2.2) run "update-modules"

2.3) "modprobe -c" produces the "double includes"

2.4) "/etc/init.d/alsasound" shows the soundcards twice

- Can anybody reproduce this behaviour?

- Why is Gentoo generating the redundant files /etc/modprobe.conf and /etc/modules.conf? For example, Debian uses the files in /etc/modules.d directly. That seems much more appealing at first glance.

Cheers,

Sven

```
$ # Here is /etc/modprobe.d/blacklist whose content is copied into /etc/modprobe.conf

$

$ cat /etc/modprobe.d/blacklist

# This file lists modules which will not be loaded by udev,

# not at coldplugging and not on hotplug events.

# Add your own entries to this file

# in the format "blacklist <name of module>"

# Some examples:

# evbug is a debug tool and should be loaded explicitly

blacklist evbug

# Autoloading eth1394 most of the time re-orders your network

# interfaces, and with buggy kernel 2.6.21, udev persistent-net

# is not able to rename these devices, so you get eth?_rename devices

# plus an exceeded 30sec boot timeout

blacklist eth1394

# You probably want this to not get the console beep loud on every tab :)

#blacklist pcspkr

# these drivers are very simple, the HID drivers are usually preferred

#blacklist usbmouse

#blacklist usbkbd

# Sometimes loading a framebuffer driver at boot gets the console black

#install pci:v*d*sv*sd*bc03sc*i* /bin/true

$

$

$ # Show the duplicate lines in modprobe's configuration

$

$ modprobe -c | sort | uniq -d

#

# (if not blacklisted somewhere else)

# /etc/modprobe.d/pnp-aliases

# ALSA portion

[...]

blacklist eth1394

blacklist evbug

options snd cards_limit=1

$
```

----------

