Some Realtek based USB Wi-Fi adapters, including many rebrands such as Baseus, initially present themselves as a USB mass storage device labeled DISK. This behavior is intended for Windows auto-installers and prevents Linux from loading a Wi-Fi driver. This repository provides a single interactive Bash script that:
- checks for root privileges
- detects the Linux distribution and installs usb_modeswitch
- lists current USB devices and lets you select the Realtek adapter
- extracts the vendor and product IDs
- generates a temporary usb_modeswitch configuration in the current directory
- invokes usb_modeswitch against that temporary config to switch the device into network mode
- cleans up the temporary file
The script does not persist any rule. After a reboot or replug, the device may return to DISK mode unless you add a permanent rule. A persistence section is included below for users who want that behavior.
- Fedora and other dnf based systems
- Ubuntu, Debian, and derivatives using apt
- Arch and Manjaro using pacman
- openSUSE using zypper
- Bash
- sudo or root access
- usbutils for lsusb listing. The script checks and installs it if missing.
- Clone the repository
- Make the script executable
- Run the script with sudo
- Follow the on-screen prompts
git clone https://github.com/iman-zamani/realtek-usb-wifi-modeswitch.git
cd realtek-usb-wifi-modeswitch
chmod +x modeswitch.sh
sudo ./modeswitch.sh
- If the adapter is still listed as DISK after switching, physically unplug and replug it. Some devices require power cycling.
- After a successful switch, confirm that a new Wi-Fi interface appears with the following command:
nmcli device status
You should see a new interface.
- Connect to a network using NetworkManager:
nmcli dev wifi list
nmcli dev wifi connect "SSID" password "PASSWORD" ifname interface-name
The script is intentionally temporary. If you want automatic switching every time the adapter is attached, create a static usb_modeswitch data file and a udev rule.
Example usb_modeswitch file:
sudo mkdir -p /etc/usb_modeswitch.d
sudo tee /etc/usb_modeswitch.d/0bda:a192 >/dev/null <<'EOF'
DefaultVendor=0x0bda
DefaultProduct=0xa192
TargetClass=0x0000
MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
EOF
Example udev rule:
sudo tee /etc/udev/rules.d/40-realtek-modeswitch.rules >/dev/null <<'EOF'
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="a192", RUN+="/usr/sbin/usb_modeswitch -c /etc/usb_modeswitch.d/0bda:a192"
EOF
sudo udevadm control --reload
Note that vendor and product IDs must match your adapter. Replace them if your device uses different values.
Switching to network mode does not install a Wi-Fi driver. If no wireless interface appears after a successful switch, you may need a driver package. Examples include rtl88xxau, rtl8xxxu alternatives, or other Realtek out-of-tree modules. Consult your distribution and the chipset reported after switching.
-
usb_modeswitch not found Install it using your distribution’s package manager, or run this script with sudo so it installs automatically.
-
Selected lsusb line does not contain an ID Some localized lsusb outputs differ. Ensure the selected line contains “ID VVVV PPPP”. If not, update usbutils.
-
Device returns to DISK after reboot Use the persistence section above to add a permanent rule.
-
Interface exists but cannot connect Update your system, install appropriate driver packages, and test with nmcli. Check dmesg for driver and firmware errors.
-
Multiple Realtek devices Run the script again and choose the correct line. If both are present, disconnect one at a time to avoid confusion.
- The script only writes a temporary usb_modeswitch configuration in the current directory and deletes it after use.
- The script does not make permanent system changes unless you follow the optional persistence section.
- Review the script before running. It requires elevated privileges to install packages and call usb_modeswitch.
This project is licensed under a MIT license. See LICENSE for full terms.