# USB wifi dongle - startup script

## zeptin

I have a wifi dongle that requires the following command to be run every time the machine is started (the driver is not loaded until this command is run, even modprobe does not work): 

echo "2001 330D" | tee /sys/bus/usb/drivers/rtl8192cu/new_id

Which startup/init script do I place this command in so that the init script for the wifi adapter will complete successfully? I do not want to edit the adapter's init script, as it is linked to the loopback adapter's script.

----------

## Logicien

You can create an initramfs to do it, but I think create an entry in /etc/inittab would be enough

```
# System initialization, mount local filesystems, etc.

ai::sysinit:/bin/echo "2001 330D" | /usr/bin/tee /sys/bus/usb/drivers/rtl8192cu/new_id

si::sysinit:/sbin/rc sysinit
```

This way, your Usb wireless card should be drive before any net services start.

According with what you say, an other way is to use the /etc/modprobe.d/modprobe.conf file

```
install rtl8192cu /bin/echo "2001 330D" | /usr/bin/tee /sys/bus/usb/drivers/rtl8192cu/new_id && /sbin/modprobe rtl8192cu
```

Maybe this one have more chances to succeed:

```
install rtl8192cu /sbin/modprobe rtl8192cu && /bin/echo "2001 330D" | /usr/bin/tee /sys/bus/usb/drivers/rtl8192cu/new_id
```

If you use an initramfs, you may have to recreate it to include the modprobe.conf file.

----------

## Anon-E-moose

You could add the echo line to the end of  /etc/local.d/baselayout1.start (assuming you are using openrc not systemd)

I have several unbind commands there for hardware that I've set aside for vm usage.

Or you can do as Logicien suggested.

It all depends on whether the dongle is your primary network interface.

----------

## zeptin

Thanks, I went with Logicien's suggestion to put it into /etc/inittab, and everything now appears to be correctly loaded on startup. However, the dongle itself is not appearing in /dev and it is therefore not appearing in the ifconfig list either. To be honest, it wasn't actually showing up there before, but I wanted to resolve the kernel modules not loading on startup first.

dmesg seems to indicate that it is happy:

```

[    2.960160] usb 1-5: New USB device found, idVendor=2001, idProduct=330d

[    2.960217] usb 1-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[    2.960271] usb 1-5: Product: 802.11n WLAN Adapter

[    2.960324] usb 1-5: Manufacturer: Realtek

[    2.960376] usb 1-5: SerialNumber: 00e04c000001

[    2.960623] usb 1-5: usb_probe_device

[    2.960626] usb 1-5: configuration #1 chosen from 1 choice

[    2.961403] usb 1-5: adding 1-5:1.0 (config #1, interface 0)

...

[    5.968531] usbcore: registered new interface driver rtl8192cu

```

lsusb finds the dongle as well:

```

Bus 001 Device 003: ID 2001:330d D-Link Corp.

```

Just to confirm that the modules are indeed being loaded, here's the lsmod output:

```

Module                  Size  Used by

rtl8192cu              90431  0

rtlwifi               105981  1 rtl8192cu

rtl8192c_common        53674  1 rtl8192cu

```

Based on the above, I would expect /dev/wlp0s18f2u5 to be present. I think I got it working briefly once, hence knowing what the device name is, but currently there is only a /dev/enp2s0 for the wired connection.

Just a note for anyone else trying to get a wifi dongle of this type working in the future: I had to emerge the linux-firmware package, it is not immediately obvious that you have to do this.

----------

## NeddySeagoon

zeptin,

Your device 2001 330D is not known to the rtl8192cu driver.  The echo command tells the rtl8192cu driver to take the device anyway.

There are two cleaner ways to do what you need.

1. Patch your kernel. Its a one line change.

2. Run modinfo  rtl8192cu.  This will tell what options the module takes.  You may be able to run 

```
modprobe  rtl8192cu <Option1>=2001 <Option2>=330d
```

If 2 works, (it depends on the module) then the options can be provided in /etc/conf.d/modules along with the instruction to load the module.

You may find that the one line kernel patch is already in a newer kernel.

----------

## Logicien

A lot of network modules need firmwares. So, some firmware packages often have to be emerge. The name of a network device do not appear in the /dev directory. Why, is a good question.

You have to make ifconfig show all the network devices available, up and down, with the -a parameter to be sure your Usb wireless device is listed or not.

```
ifconfig -a
```

or

```
ip link show
```

The firmwares needed by the rtl8192cu module are all include in the linux-firmware package. I see no module parameter to tell rtl8192cu to try to support your card. So you will have to echo it. To be sure the echo command have succeeded, do

```
cat /sys/bus/usb/drivers/rtl8192cu/new_id
```

In the case where you cannot use your wireless card, try to use the latest ~amd64 kernel 3.13.7 from gentoo-sources or vanilla-sources like NeddySeagoon recommand.

----------

