# Writing custom udev rule for nvidia driver

## Xarthisius

Hi,

I have Dell XPS 13 Studio laptop with HybridSLI cards:

```
02:00.0 VGA compatible controller: nVidia Corporation G98 [GeForce 9200M GS] (rev a1)

03:00.0 VGA compatible controller: nVidia Corporation C79 [GeForce 9400M G] (rev b1)
```

The first card is completely useless and only gets in a way when try to do CUDA programming.

When the nvidia driver loads it creates following devices:

```
crw-rw---- 1 root video 195,   0 Aug 15 23:32 /dev/nvidia0

crw-rw---- 1 root video 195,   1 Aug 15 23:32 /dev/nvidia1

crw-rw---- 1 root video 195, 255 Aug 15 23:32 /dev/nvidiactl
```

I would like to have something like that:

```
crw-rw---- 1 root video 195,   1 Aug 15 23:32 /dev/nvidia0

lrwxrwxrwx 1 root  root         3 Aug 15 23:32 nvidia1 -> nvidia0

crw-rw---- 1 root video 195,   0 Aug 15 23:32 /dev/nvidia_junk0

crw-rw---- 1 root video 195, 255 Aug 15 23:32 /dev/nvidiactl
```

I can force nvidia driver not to create devices while loading:

```
options nvidia NVreg_ModifyDeviceFiles=0
```

I can create required configuration manually with rm, mknod, etc, but I would really appreciate if someone would help me to write custom udev rule to do all the magic.

I have experimented with various rules based on attr and so on, but everything failed.

Relevant info for BAD card:

```
udevadm info -a -p /sys/module/nvidia/drivers/pci\:nvidia/0000\:02\:00.0/

  looking at device '/devices/pci0000:00/0000:00:0c.0/0000:02:00.0':

    KERNEL=="0000:02:00.0"

    SUBSYSTEM=="pci"

    DRIVER=="nvidia"

    ATTR{vendor}=="0x10de"

    ATTR{device}=="0x06e8"

    ATTR{subsystem_vendor}=="0x1028"

    ATTR{subsystem_device}=="0x0271"

    ATTR{class}=="0x030000"

    ATTR{irq}=="23"

    ATTR{local_cpus}=="3"

    ATTR{local_cpulist}=="0-1"

    ATTR{modalias}=="pci:v000010DEd000006E8sv00001028sd00000271bc03sc00i00"

    ATTR{numa_node}=="0"

    ATTR{enable}=="1"

    ATTR{broken_parity_status}=="0"

    ATTR{msi_bus}==""

    ATTR{boot_vga}=="0"
```

and GOOD card:

```
  looking at device '/devices/pci0000:00/0000:00:10.0/0000:03:00.0':

    KERNEL=="0000:03:00.0"

    SUBSYSTEM=="pci"

    DRIVER=="nvidia"

    ATTR{vendor}=="0x10de"

    ATTR{device}=="0x0866"

    ATTR{subsystem_vendor}=="0x1028"

    ATTR{subsystem_device}=="0x0271"

    ATTR{class}=="0x030000"

    ATTR{irq}=="18"

    ATTR{local_cpus}=="3"

    ATTR{local_cpulist}=="0-1"

    ATTR{modalias}=="pci:v000010DEd00000866sv00001028sd00000271bc03sc00i00"

    ATTR{numa_node}=="0"

    ATTR{enable}=="1"

    ATTR{broken_parity_status}=="0"

    ATTR{msi_bus}==""

    ATTR{boot_vga}=="1"
```

Best regards,

Xarthisius

----------

