How to prefer USB wifi & turn off inbuilt wifi?

My laptop’s built-in wifi is unreliable with Linux so I bought a cheap USB Wifi dongle (GenBasic RF 2A4M1 Wireless Adapter for Linux) which has worked great (both under 23.04 and now 23.10).

Is there a way to:

  1. give the two wifi devices different names in nm-tray?
  2. prefer the USB wifi as default over the built-in one (and maybe even turn off the built-in one)?

Why I’m asking: today my laptop’s wifi became very unreliable again. After wondering if there was a problem with our home internet, then rebooting (without joy), eventually I worked out how to disconnect from both USB wifi and inbuilt wifi and reconnect only to USB wifi, and that seems to have fixed it. That was complicated by the fact that both wifi’s have the same name in nm-tray (i.e. actually the name of our router), so it involved trial and error to get the right wifi connected.
I think, after months of using the USB wifi, somehow the laptop got connected via the built-in wifi instead of the dongle, so in future I’d like to be able to distinguish between the two devices (if they’re both on) or even avoid the problem altogether by turning off the built-in wifi.

It happened again (and again it happened about 20 minutes before I had an online work meeting :sweat_smile: ): webpages / sync app just stopped loading/connecting. But this time making sure the laptop was connecting through the USB dongle and not the built-in wifi didn’t work.

I had to resort to USB tethering with my phone (after trying Bluetooth tethering reconnected to the built-in wifi chip, which I believe handles both Wifi and Bluetooth). Even that was not reliable, so I did the voice part of the meeting via the phone and used the laptop for text messages (which were occasionally delayed).

But right now it’s working fine with the USB dongle. And it will probably work fine… right up until just before I’m supposed to have another online meeting :slight_smile:

I’m not sure how to diagnose this problem, let alone solve it. Any help appreciated.

Here’s my hardware probe and (I believe) the relevant results:

Summary

HW probe of Lenovo IdeaPad 1 15IGL7 82V... #5603a5896d
Lubuntu 23.10
Built-in Wireless

USB Wireless

  • Device: “Ralink Technology MT7601U Wireless Adapter”
  • Driver: “mt7601u”
  • “Works but known to have problems”, Ralink Technology MT7601U Wireless Adapter . However the name and the photo are different from what I have. The box and device I have say “GenBasic RF 2A4M1 Wireless Adapter for Linux”

If the built-in one is unreliable and the USB one is not, why bother with the built-in at all? Just turn it off with something like:

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

where $N is the number of your device’s PCI slot.

2 Likes

Do you guys think you can disable the built-in one from the BIOS?

Would that make sense? (not being rhetorical; I actually don’t know)

Idk if you dual boot.

@wxl,

With Lubuntu Noble live in a Toshiba Satellite Pro C850-19W I tested this command line (with the modifications I could think of), but failed miserably. So I think you must explain how to do it with more details, to make it useful for people like me, who are not very good at managing pci devices via the command line.

-o-

I tried another (more complicated) way with somewhat better luck:

  • Identify the wifi device to turn off

    ip addr
    

and found wlp2s0:

  • turn it off

    sudo ip link set wlp2s0: down
    

and it made the network ‘unreachable’.

-o-

This command

sudo ip link set wlp2s0: up

will restart the network again, but in this case another device, the external wifi, should be identified and started (unless it is already running).

-o-

I think (but did not test) that the ip commands can be run automatically as part of the boot process, for example edited via

sudo crontab -e

to run ‘@reboot’, which in this case includes cold boot too.

1 Like

Thanks for the ideas. (Re dual booting, no Windows, but I do have Spiral Debian and reFind bootloader installed. Although for the last few months I’ve only used Lubuntu.)

Running lspci, this is the PCI list for the built-in wireless:
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. Device b852

So should I enter:
echo 0 > /sys/bus/pci/slot/03:00.0/power
?

And if so, what command would undo that in case I ever need to?

1 Like

If that file exists, yes. If not, try digging around in /sys/bus/pci.

To turn it back on, you’d just echo 1.

The unfortunate thing about this is it isn’t really well documented and results vary by device, etc. etc., so the best I can offer you is this hint.

1 Like

Scratch that. I found some docs.

I was able to disable my card by:

  1. determining the slot, which is in the format [domain:]bus:device.function. This is the first thing shown in the lspci listing.
  2. navigating to my device’s directory (/sys/bus/pci/devices/$N where $N in the format domain:slot:bus.function)
  3. writing a non-zero positive integer to the remove file, such as by way of echo 1 | sudo tee remove

Summing this all up for you, doing this should do the trick: echo 1 | sudo tee /sys/bus/pci/devices/0000:00:03.0/remove

The end result is that the whole device is removed from the directory tree.

Note it does not persist across reboots, so you can just undo it by rebooting.

3 Likes

Thanks for the tip, but presumably I’m doing something wrong :smiling_face:

In the file manager, I navigated to the devices location, right-clicked “Open in Terminal”, pasted that command and got the following:

{ME}:/sys/bus/pci/devices/0000:00:00.3$ echo 1 | sudo tee /sys/bus/pci/devices/0000:00:03.0/remove
[sudo] password for {ME}: 
tee: '/sys/bus/pci/devices/0000:00:03.0/remove': No such file or directory
1
1 Like

@pan4b,

Until you solve the problems with the method by wxl, you can try the method using ip according to my previous post.

I am not sure if something in the system will try to reconnect after some shorter or longer time, but it might be worthwhile trying. Anyway, I am sure that you should run the ‘sudo ip … down’ command line after each boot, maybe automatically, but before fixing the automation you should make sure that the internal wifi will not be connected automatically against your intentions.

1 Like

Apparently, something got messed up in translation. Use the right directory and it should work.

1 Like

If you right click the nmtray > Edit Connections
You can rename the connection and set a priority (in General).

(As a last resort, I think you can actually pull out the wifi-card with that Lenovo model.)

2 Likes

Actually, that’s a good point about the physical card. Even if you can’t pull out the card, I’m sure you could detach the antenna cable and render it useless.

1 Like

@wxl
The following worked. Thanks!
echo 1 | sudo tee /sys/bus/pci/devices/0000:03:00.0/remove
For now I guess I have to remember do this after rebooting.

@sudodus
I tried the ip addr command and the results were too confusing for me :smiling_face: . But I tried it again after doing @wxl ’ s echo command, and the list was one device shorter, and now I think I understand how to use it to identify the right connection.
Thanks!

@humpty
After using @wxl 's tip to turn off the built-in wifi, and using @sudodus 's tip re ip addr, I went right-clicked on nm-tray, opened the edit window for the first of the two identically-named connections, clicked on the cog icon, and saw that the “Device” was listed as “wlxa047d7305bef”. I compared to the results from ip addr and realized “Ah that must be the USB dongle connection” and appended “-USB” to the connection name. As the other had to be the built-in wifi, I checked its device name (“wlp3s0”) and appended “-Built-In” to its name.
Thanks!

I see there is also the option in nm-tray to delete a connection. Should I just go ahead and delete the built-in one so that my laptop always defaults to the USB dongle?

2 Likes

@wxl and @humpty Re pulling hardware, last month for the first time ever I did something like that (changed HDD to SSD on another laptop before installing Lubuntu) following a Youtube video. So I might be up for it, but I believe the built-in card also handles Bluetooth and the USB dongle does not.

I have never (successfully) used Bluetooth on this laptop (the one time I tried to connect, Lubuntu’s “Add Bluetooth Device” gave me a long list of ¿hexadecimal? IDs with no indication what any of those devices actually were). But I would like to keep the option available, just in case.

Well today Lubuntu was only using the USB wifi… and I still I ended up with connection problems. The other people on two separate calls had problems hearing me (the first after about 45 minutes, the second after about 3 minutes) and web pages wouldn’t load or took a very long time.

I just don’t understand what’s going on with wifi and Lubuntu on this computer. At first the built-in wifi worked fine for a few months, then it became unreliable. So I got the USB dongle. And at first that worked fine for a few months, but now it’s unreliable too.

The other factor that confuses me is that it’s not all the time. 90% of the time it’s just fine, but then it gets problematic . (Why was it fine for 45 minutes and only then became useless???)

So my “diagnosis & cure” of avoiding the built-in wifi and just using the USB dongle hasn’t worked. My clients are going to start getting pissed off with the connection problems. I don’t know what to do now. Any ideas appreciated.

(I might see what happens with another Linux.)

I use NoMachine regularly at work and sending the state of the screens (across two monitors, I might add) plus the state of input on the remote end, not too mention the fact that it also sends the remote audio, accounts for a lot of bandwidth. Yet I can usually watch YouTube videos with no problem.

That said, I have run into problems before when using WiFi. Unfortunately, WiFi is not as fast and certainly not as consistent as a wired connection. There’s really nothing to be done about this except reducing the amount of bandwidth used by e.g. reducing video quality. Or just using a wired connection.

1 Like

+1 for using a wired connection whenever possible, because it is both faster and more reliable.

1 Like

@wxl & @sudodus Wired would be nice but unfortunately rather impractical and expensive in my specific case (locations of fibre optic entry point vs home office etc). Maybe a long-term possibility when the other things I have to spend money on have passed.

I’ve been thinking of hooking up an old Wifi router to attach to the telco-supplied modem to boost the signal. But I’m not sure that would fix the problem, because this laptop never had any problems with Wifi when it ran Windows, and the signal strength is usually fine (at least according to the icon in nm-tray) even when the connection isn’t working :confused: . (I should test by taking the laptop close to the router when the problem occurs, but I have to wait until it does reoccur. It’s rather random.)

I think the problem (at least for the built-in Wifi) is not the signal but the driver under Linux.

Re bandwidth usage, I only do audio calls, no video. In the background, I only have Dropbox and meteo-qt. Moreover I’m not doing anything different/more now than when the wifi connection worked for months without problems.

Today I had a work call, and no problems at all today, before, during or since. Fingers crossed it stays that way.

Thanks for all the tips.

Perhaps your wifi channel gets congested ? (I used to get that problem before going wired).

Install an analyzer like linssid to show you how crowded it is.

In Edit Connections under Wifi, you can try selecting the band and channel.

Your built-in card looks like a higher spec. It might do 5Ghz which offers more choice.

3 Likes