# How to get rid of nouveau modules?

## Blind_Sniper

I switched from nvidia to nouveau driver to check for some videocard issue.

Now I want to switch back to nvidia-drivers.

I rebuilt kernel with old .config (it was saved before switching to nouveau and copied back now):

```
make clean && make && make modules_install

```

and re-installed nvidia driver:

```
emerge -av nvidia-drivers

nvidia-xconfig
```

During kernel rebuild I noticed that a zillion "nouveau*.o" object files was rebuilt again and nouveau kernel modules was installed to /lib/modules directory, though my kernel config is free of any nouvea stuffs:

```
cat /usr/src/linux/.config |grep NOUVEAU

# CONFIG_DRM_NOUVEAU is not set
```

the same for make.conf:

```
cat /etc/portage/make.conf |grep VIDEO_CARDS

VIDEO_CARDS="nvidia"
```

and xorg.conf:

```
Section "Device"

    Identifier     "Device0"

    Driver         "nvidia"

    VendorName     "NVIDIA Corporation"

EndSection
```

When rebooting after rebuild kernel loading nouveau driver instead of nvidia. Only blacklisting prevents nouveau loading.

Where is that trigger which causes nouveau kernel modules rebuild, and how do I get rid of nouveau completely?

----------

## alamahant

Hi

Maybe you should run

```

emerge -uDNav @world

emerge -a --depclean

```

 :Very Happy: 

----------

## Blind_Sniper

I did it after switching back to nvidia.

----------

## NeddySeagoon

Blind_Sniper,

Its easy to build one kernel and run another.

```
cat /usr/src/linux/.config |grep NOUVEAU

# CONFIG_DRM_NOUVEAU is not set
```

That good. That's the kernel build location.

What is the date/time on /usr/src/linux/.config  ?

Lose a point for a useless cat.

What is the date/time in 

```
uname -a
```

thats the build time of the currently running kernel.

For the currently running kernel to be derived from the .config you think it was, the unawe -a time must be newer than the .config time.

Is it?

If not you are not running the kernel you think you are.

----------

## Blind_Sniper

```
uname -a

Linux localhost 5.4.48-gentoo #2 SMP Sat Aug 15 13:15:37
```

```
ls -l /boot

total 10124

drwxr-xr-x 6 root root    4096 Jul  4 11:13 grub

-rw-r--r-- 1 root root 5169712 Apr  5 11:12 kernel-5.4.20

-rw-r--r-- 1 root root 5186096 Aug 15 14:17 kernel-5.4.48
```

```
ls -l /usr/src//linux/.config

-rw-r--r-- 1 root root 93968 Jun 28 14:17 /usr/src//linux/.config
```

it's really newly built kernel, and it was built on old backuped .config

----------

## halcon

Blind_Sniper, 

what is the output of that command?

```
# ls -a /proc | grep config
```

----------

## Blind_Sniper

```
ls -a /proc | grep config

config.gz
```

----------

## alamahant

Do you have a

```

/etc/modules-load.d/nvidia.conf

```

What is the output of

```

equery list '*' | grep nouveau

```

Have you update the initramfs?

 :Very Happy: Last edited by alamahant on Sat Aug 15, 2020 4:07 pm; edited 3 times in total

----------

## Blind_Sniper

I have no /etc/modules-load.d/nvidia.conf file at all.

equery list '*' | grep nouveau shows empty output

this command proves that I running righ now newly built kernel without nouveau support:

```
zcat /proc/config.gz  | grep NOUVEAU

# CONFIG_DRM_NOUVEAU is not set
```

there is nouveau.ko module in /lib/modules/5.4.48-gentoo/kernel/drivers/gpu/drm/nouveau directory.

May be it'a a module which kernel loads on boot?

Added: I can remove that drm module, but I want to know why kernel loads nouveau, if it configured to not to use nouveau modules?

Added: I do not use initramfs

----------

## alamahant

If you deleted both the nouveau.ko in /lib/modules and the  /usr/src/linux/drivers/gpu/drm/nouveau directory and also the kernel in /boot and run again

```

make modules_install

make install

```

Then create the nvidia.conf file containing "nvidia" and reboot?

But before you do this check if nvidia module is present

```

modprobe nvidia

lsmod | grep nvidia

```

----------

## Blind_Sniper

deleted nouveau.ko under /lib directory and ran this:

```
# make modules_install

  INSTALL drivers/acpi/video.ko

  INSTALL drivers/gpu/drm/nouveau/nouveau.ko

  INSTALL drivers/gpu/drm/ttm/ttm.ko

  INSTALL drivers/net/tun.ko

  INSTALL drivers/platform/x86/mxm-wmi.ko

  INSTALL drivers/platform/x86/wmi-bmof.ko

  INSTALL drivers/platform/x86/wmi.ko

  INSTALL drivers/ptp/ptp.ko

  INSTALL drivers/video/backlight/backlight.ko

  INSTALL drivers/video/backlight/generic_bl.ko

  INSTALL fs/efivarfs/efivarfs.ko

  DEPMOD  5.4.48-gentoo
```

nouveau.ko was copied again to /lib.

where this module came from? I did make clean before kernel rebuilding. I disabled nouveau in .config, wtf it wants?

 *Quote:*   

> modprobe nvidia

 

if I didn't blacklist nouveau I cannot load nvidia module, modprobe reports that there is no such device. And lsmod shows that nouveau is loaded.

if I blacklisting nouveau, nvidia loading just fine without any modprobe.

----------

## halcon

 *Blind_Sniper wrote:*   

> Added: I can remove that drm module, but I want to know why kernel loads nouveau, if it configured to not to use nouveau modules?

 

Maybe, the reason is here:

 *Blind_Sniper wrote:*   

> 
> 
> ```
> make clean && make && make modules_install
> ```
> ...

 

You omitted 

```
make modules
```

AFAIK, make modules_install does not include make modules, that is, nothing is built. And all those modules are from the previous kernel version?

I use always CONFIG_LOCALVERSION for my kernels (for example, CONFIG_LOCALVERSION="-v46"), increasing it at each re-build, and my modules can not be mixed:

# ls -a /lib/modules/

.   4.19.72-gentoo-v41  4.19.86-gentoo-v43  4.19.97-gentoo-v45

..  4.19.72-gentoo-v42  4.19.86-gentoo-v44  5.6.3-gentoo-v46

#

EDIT:

 *Blind_Sniper wrote:*   

> where this module came from?

 

I wonder too why make clean didn't remove them (evidently?)Last edited by halcon on Sat Aug 15, 2020 4:31 pm; edited 1 time in total

----------

## Blind_Sniper

 *halcon wrote:*   

> 
> 
> You omitted 
> 
> ```
> ...

 

I using gentoo for decade now and never did "make modules". If it would be mandatory, I wouldn't have nouveau module built and wouldn't fight against it now trying to prevent it to be loaded, isn't it?

----------

## halcon

 *Blind_Sniper wrote:*   

> I using gentoo for decade now and never did "make modules".

 

If so, I have no idea... But... There is another proof (the comment by not-a-user, Apr 5 '17 at 8:13).

Then, it's said, prior to 2.6, you need make modules, while after 2.6, make will also do make modules... Maybe something changed again?

EDIT:

I personally am using these commands (also for decade) and never had issues:

```
make bzImage

make modules

make modules_install
```

----------

## alamahant

It comes from here

```

/usr/src/linux/drivers/gpu/drm/nouveau 

```

Just delete this directory together with the module in /lib/modules.

Even better delete 

```

/lib/modules/<kernel-version>

/boot/vmlinuz-<version>

/usr/src/linux/drivers/gpu/drm/nouveau

```

And rerun 

```

cd /usr/src/linux

make modules_install

make install

emerge -1av nvidia-drivers

```

It will be impossible for any trace to remain.

You mention you rebuilt the kernel with

 *Quote:*   

> make clean && make && make modules_install

 

You forgot to run "make install"

Best solution rebuild a totally new kernel after deleting the whole kernel directory in /usr/src

It shouldnt take long.

Is your .config that big?

----------

## NeddySeagoon

Blind_Sniper,

Rebuild and reinstall your kernel but with an extra step.

Begin with 

```
make clean
```

That ensures that there is no build rubbish left over from earlier kernel builds.

Is your system clock correct?

If its ever done a step backwards, make will get confused but make clean sidesteps that by forcing everything to be rebuilt.

----------

## Tony0945

 *alamahant wrote:*   

> Is your .config that big?

 

After blowing it all way, just run "bzcat /prog/config.gz >>/usr/src/linux/.config" for a starting point.

Another point: Does "eselect kernel list" point to the right kernel?  

I think updating the boot menu was covered above? I use reFind which defaults to the latest built kernel, but a lot of people have forgotten to update grub after building.

----------

## Blind_Sniper

@NeddySeagoon,

I mentioned it above twice that I ran "make clean".

OK, now I did it again:

```
make clean && make && make modules_install
```

Here is the rest of make output:

```
.....

.....

  LD [M]  drivers/ptp/ptp.ko

  CC [M]  drivers/video/backlight/backlight.mod.o

  LD [M]  drivers/video/backlight/backlight.ko

  CC [M]  drivers/video/backlight/generic_bl.mod.o

  LD [M]  drivers/video/backlight/generic_bl.ko

  CC [M]  fs/efivarfs/efivarfs.mod.o

  LD [M]  fs/efivarfs/efivarfs.ko

  INSTALL drivers/acpi/video.ko

  INSTALL drivers/gpu/drm/nouveau/nouveau.ko

  INSTALL drivers/gpu/drm/ttm/ttm.ko

  INSTALL drivers/net/tun.ko

  INSTALL drivers/platform/x86/mxm-wmi.ko

  INSTALL drivers/platform/x86/wmi-bmof.ko

  INSTALL drivers/platform/x86/wmi.ko

  INSTALL drivers/ptp/ptp.ko

  INSTALL drivers/video/backlight/backlight.ko

  INSTALL drivers/video/backlight/generic_bl.ko

  INSTALL fs/efivarfs/efivarfs.ko

  DEPMOD  5.4.48-gentoo
```

Still builds and installs nouveau!

Once nore: 

```
grep 'NOUVEAU' /usr/src/linux/.config

# CONFIG_DRM_NOUVEAU is not set
```

Then 

```
cp arch/x86_64/boot/bzImage /boot/kernel-5.4.48

reboot
```

After reboot:

```
#lsmod

Module                  Size  Used by

nouveau              2121728  1

wmi                    24576  1 nouveau

video                  40960  1 nouveau

ttm                    94208  1 nouveau

backlight              16384  2 video,nouveau

vboxnetadp             28672  0

vboxnetflt             32768  0

vboxdrv               413696  2 vboxnetadp,vboxnetflt
```

Checking for kernel build date:

```
# uname -a

Linux localhost 5.4.48-gentoo #4 SMP Sun Aug 16 18:17:17
```

built today.

Seems "make clean " cleans only already built modules/binaries, but some of configuration files still presented in /usr/src and instructing make command to build nouveau modules.

----------

## NeddySeagoon

Blind_Sniper,

Lets do it again. Do the steps that follow.

```
cd /usr/src/linux

ls drivers/gpu/drm/nouveau/nouveau.ko

make clean

ls drivers/gpu/drm/nouveau/nouveau.ko

make -j<cores>

ls drivers/gpu/drm/nouveau/nouveau.ko
```

At every step drivers/gpu/drm/nouveau/nouveau.ko should be missing.

If its missing before the make clean, then you are not booting the kernel you have been building.

----------

## Blind_Sniper

OK, I'll do it again, (4th build), but if you will see again my prev post, you will notice, that make built and installed nouveau.ko.

It explicitely mentioned in make output:

```
INSTALL drivers/gpu/drm/nouveau/nouveau.ko
```

And I do run exactly just built kernel, output of uname proves it:

```
# uname -a

Linux localhost 5.4.48-gentoo #4 SMP Sun Aug 16 18:17:17
```

It's a today kernel. I have only two kernels, the old one (v5.4.20) built on April 5, and the new one built today, August 16

OK, meanwhile my new kernel is ready again:

```
localhost /root # cd /usr/src/linux

localhost /usr/src/linux # ls drivers/gpu/drm/nouveau/nouveau.ko

drivers/gpu/drm/nouveau/nouveau.ko

localhost /usr/src/linux # make clean

  CLEAN   arch/x86/entry/vdso

  CLEAN   arch/x86/kernel/cpu

  CLEAN   arch/x86/kernel

  CLEAN   arch/x86/realmode/rm

  CLEAN   arch/x86/lib

  CLEAN   certs

  CLEAN   drivers/scsi

  CLEAN   drivers/tty/vt

  CLEAN   kernel

  CLEAN   lib

  CLEAN   net/wireless

  CLEAN   arch/x86/boot/compressed

  CLEAN   arch/x86/boot

  CLEAN   arch/x86/tools

  CLEAN   modules.builtin.modinfo

localhost /usr/src/linux # ls drivers/gpu/drm/nouveau/nouveau.ko

ls: cannot access 'drivers/gpu/drm/nouveau/nouveau.ko': No such file or directory

localhost /usr/src/linux # make -j5

localhost /usr/src/linux # ls drivers/gpu/drm/nouveau/nouveau.ko

drivers/gpu/drm/nouveau/nouveau.ko
```

It again built nouveau. If you do not trust my text reports, I can screencast my desktop while building kernel.

----------

## Tony0945

Are you using "make menuconfig"? or directly editing .config ?

Just a thought.

----------

## NeddySeagoon

Blind_Sniper,

Yes, I noticed. I wanted to prove that each step did what was expected, or not.

The build system is either not using the .config file or the .config file is corrupt and the 

```
make silentoldconf 
```

at the start of make makes it legal but not what you want.

----------

## Blind_Sniper

@Tony0945, I using make menuconfig. Some options missing in .config file and can be activated only via menuconfig, so I couldn't enable that options by direct editing.

@NeddySeagoon,

I using this .config for a while now, I saved it before enabling nouveau and copied it back when I tried nouveau decided that nouveau doesn't fit my needs.. 

If .config corrupted, I could try to remove that "silentoldconf" to prevent it to be given as a template. Where this file located?

----------

## Blind_Sniper

Though I doubt that it's a some "silentoldcofig". Why? Because grep shows that DRM_NOUVEAU is not set. Both, grep .config and zgrep /proc/config.gz showsit. If silentoldcongig would enable it, zgrep would show DRM_NOUVEAU=m

----------

## NeddySeagoon

Blind_Sniper,

Agreed, as you are looking at the config file after make has been run.

That only leaves that make is not using the .config file.

If you have the config embedded in the kernel

```
cd /usr/src/linux

scripts/extract-ikconfig /path/to/kernel 
```

should extract it.

... but that is what you see in /proc/config.gz too, which is correct.

Make a copy of the .config outside of the kernel tree as the next step mill remove it.

```
cd /usr/src/linux

make mrproper
```

That's make squeaky_clean :)

Copy the .config back

Open the Makefile in your favourite editor and edit the EXTRAVERSION at the top of the file.

```
# SPDX-License-Identifier: GPL-2.0

VERSION = 5

PATCHLEVEL = 8

SUBLEVEL = 0

EXTRAVERSION = -gentoo-r1

NAME = Kleptomaniac Octopus
```

It doesn't matter what is it. This will change the version magic that the kernel uses to identify its modules.

Build and reboot into this kernel.

```
uname -a
```

 will show the new kernel name.

Any old modules that happen to be lying around will not load but dmesg will tell you all about it.

Look for version magic mismatch errors.

If nouveau is still there, its gettting built against the new kernel with the changed version magic.

Hmm. Do you use config fragments?

----------

## Blind_Sniper

yes, it works.

After "make mrproper' make doesn't create nouveau.ko 

Seems it was really some configuration file which forced make to build nouveau module.

Thanks. 

Learned something new for myself.

Make clean cleans only binary files that was built, mrproper restores entire the kernel tree, like it was re-emerged.

----------

