The Computer Oracle

disable specific PCI device at boot

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 3 Looping

--

Chapters
00:00 Disable Specific Pci Device At Boot
01:23 Answer 1 Score 4
01:41 Answer 2 Score 3
02:26 Answer 3 Score 4
03:05 Answer 4 Score 11
03:23 Thank you

--

Full question
https://superuser.com/questions/541854/d...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #drivers

#avk47



ANSWER 1

Score 11


You can remove a PCI device by adding a udev rule under /etc/udev/rules.d :

ACTION=="add", KERNEL=="0000:00:03.0", SUBSYSTEM=="pci", RUN+="/bin/sh -c 'echo 1 > /sys/bus/pci/devices/0000:00:03.0/remove'"

Replace 0000:00:03.0 with the pci device address you want to remove




ANSWER 2

Score 4


Found this thread on askubuntu:

Using lspci -vv to identify a device's PCI slot that you want to disable, it sounded like you could use this command to turn that slot's device off:

% echo 0 > /sys/bus/pci/slot/$N/power



ANSWER 3

Score 4


None of the answers solved my similar problem, but they did put me on the path to solving it!

My syslog error:

[  334.940158] hub 1-0:1.0: unable to enumerate USB device on port 7

This is an internal usb hub-port for a bluetooth option I do not have.

unbind to the pci device just resulted in the hub popping back up as another hub (5 in my case) and flooding syslog further.

By chance I noticed an unbind structure under /sys/bus/usb/drivers/hub. Using examples above I just added the following in rc.local:

echo "1-0:1.0" > /sys/bus/usb/drivers/hub/unbind

Result is syslog silence! Now to add kshurig's script example for power management and I should be golden.




ANSWER 4

Score 3


When you already have echo "0000:00:1a.0" > /sys/bus/pci/drivers/ehci_hcd/unbind in /etc/rc.local for boot than you just need to put it into a script for the power management deamon aswell.

Goes like this: Create an executable bash script file named 0_disable_webcam in directory /etc/pm/sleep.d/:

#!/bin/sh
case "$1" in
        resume|thaw)
                echo "0000:00:1a.0" > /sys/bus/pci/drivers/ehci_hcd/unbind
                ;;
esac

It should work instantly. I tried it with an usb thumb drive and it worked (meaning it remained disabled) as long as the drive was plugged. Replugging would need udev rules but since your webcam will not be unplugged it should work. If that does not do the trick I have another suggestion.