Score:0

unable to edit contents of /sys/bus/pci/devices

lk flag

when attempting to run

#!/bin/sh

for i in /sys/bus/pci/devices/*/boot_vga; do
    if [ $(cat "$i") -eq 0 ]; then
        GPU="${i%/boot_vga}"
        AUDIO="$(echo "$GPU" | sed -e "s/0$/1/")"
        USB="$(echo "$GPU" | sed -e "s/0$/2/")"
        echo "vfio-pci" > "$GPU/driver_override"
        if [ -d "$AUDIO" ]; then
            echo "vfio-pci" > "$AUDIO/driver_override"
        fi
        if [ -d "$USB" ]; then
            echo "vfio-pci" > "$USB/driver_override"
        fi
    fi
done

modprobe -i vfio-pci

(as an sh file) I got the output

./a.sh: 8: cannot create /sys/bus/pci/devices/0000:17:00.0/driver_override: Permission denied
./a.sh: 10: cannot create /sys/bus/pci/devices/0000:17:00.1/driver_override: Permission denied

when looking at those file locations, I found that /sys/bus/pci/devices/0000:17:00.0/driver_override and /sys/bus/pci/devices/0000:17:00.1/driver_override already existed the contents of which are "(null)"

Score:0
be flag

This issue is likely because you are not running the script with root permissions. The /sys directory in Linux is part of the virtual filesystem and is protected. Modifying files here often requires root (or superuser) permissions.

In your case, you're trying to modify driver_override files, which need higher privileges.

Try running the script with sudo, like so:

sudo ./a.sh

This command will execute the script with root privileges, and you should no longer see the "Permission denied" error.

However, be cautious when running scripts with root permissions, especially when they modify system files, because mistakes could potentially harm your system. Always make sure you understand what the script is doing before running it as the root user.

The "(null)" content in the driver_override file might be because no driver has been specified to override the current one. The driver_override interface allows you to specify a particular driver to bind to a device when the device driver auto probing is performed. It's an advanced feature and should be used carefully.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.