10

I want to disable the internal webcam of my laptop running Ubuntu 13.10? As suggested here, I already disabled the concerning kernel modules by blacklisting them. But after reboot the modules are loaded nevertheless. What can I do to get rid of these modules?

My module blacklist lies in /etc/modprobe.d/blacklist-webcam.conf and looks like this:

blacklist videodev
blacklist videobuf2_core
blacklist videobuf2_memops
blacklist videobuf2_vmalloc
blacklist uvcvideo

But lsmod gives me (after reboot):

Module                  Size  Used by
uvcvideo               80885  0 
videobuf2_vmalloc      13216  1 uvcvideo
videobuf2_memops       13362  1 videobuf2_vmalloc
videobuf2_core         40499  1 uvcvideo
videodev              133509  2 uvcvideo,videobuf2_core

Edit:
When I do a sudo modprobe -r uvcvideo the modules are gone. So I could write a script to do that. But I would not consider that as a clean solution ;-)

5 Answers5

7
  • In your blacklist.conf change blacklist videodev to install videodev /bin/false
  • update-initramfs -u
  • reboot

For more details see Kernel Modules Blacklisting on the Arch Wiki:

Blacklisting

Blacklisting, in the context of kernel modules, is a mechanism to prevent the kernel module from loading. This could be useful if, for example, the associated hardware is not needed, or if loading that module causes problems: for instance there may be two kernel modules that try to control the same piece of hardware, and loading them together would result in a conflict.

Some modules are loaded as part of the initramfs. mkinitcpio -M will print out all automatically detected modules: to prevent the initramfs from loading some of those modules, blacklist them in /etc/modprobe.d/modprobe.conf. Running mkinitcpio -v will list all modules pulled in by the various hooks (e.g. filesystems hook, block hook, etc.). Remember to add that .conf file to the FILES section in /etc/mkinitcpio.conf, if you have not done so already, and rebuild the initramfs once you have blacklisted the modules, and reboot afterwards.

Using files in /etc/modprobe.d/

Create a .conf file inside /etc/modprobe.d/ and append a line for each module you want to blacklist, using the blacklist keyword. If for example you want to prevent the pcspkr module from loading:

/etc/modprobe.d/nobeep.conf

# Do not load the 'pcspkr' module on boot.
blacklist pcspkr

Note: The blacklist command will blacklist a module so that it will not be loaded automatically, but the module may be loaded if another non-blacklisted module depends on it or if it is loaded manually.

However, there is a workaround for this behaviour; the install command instructs modprobe to run a custom command instead of inserting the module in the kernel as normal, so you can force the module to always fail loading with:

/etc/modprobe.d/blacklist.conf

...
install module_name /bin/false
...

This will effectively blacklist that module and any other that depends on it.

bain
  • 12,200
1

Just putting the list of modules in /etc/modprobe.d/blacklist.uvcdrver.conf should work. The file name can be anything. Just make sure the format and permissions are correct.

askb
  • 790
  • 1
  • 6
  • 11
1

Thank you all very much for your help! I found the source of the problem while trying bain's solution. His solution works well. After reboot the modules were really gone. But there is one drawback: I can not load the module via modprobe uvcvideo in case I want to re-enable the webcam.

While digging through my system in order to find out, why the uvcvideo module was loaded, I finally made a grep -r uvcvideo /etc/ and voilĂ , I found a script in /etc/pm/power.d which did a modprobe uvcvideo when the power cable is plugged in. I wrote this script some time ago to optimize the power consumption. I commented out the lines dealing with the webcam module and after that, the blacklist worked!

0

I would suggest you run

sudo update-initramfs -u

after modifying your blacklist. This will update your initial ramdisk.

fossfreedom
  • 174,526
N8tron
  • 734
0

In the case that you were after a solution in one command line instruction this might be helpful (based on this answer):

To disable the camera until reboot use this command:

sudo modprobe -r uvcvideo

Type your password and if there are no errors shown in the terminal, your webcam should be disabled. If you got the error message: modprobe: FATAL: Module uvcvideo is in use, you can try to force its removal with:

sudo rmmod -f uvcvideo

To enable your webcam back again, type in shell:

sudo modprobe uvcvideo