Skip to content

iman-zamani/realtek-usb-wifi-modeswitch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Realtek USB Wi-Fi Adapters Stuck in “DISK” Mode on Linux: Automated Modeswitch

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:

  1. checks for root privileges
  2. detects the Linux distribution and installs usb_modeswitch
  3. lists current USB devices and lets you select the Realtek adapter
  4. extracts the vendor and product IDs
  5. generates a temporary usb_modeswitch configuration in the current directory
  6. invokes usb_modeswitch against that temporary config to switch the device into network mode
  7. 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.

Supported distributions

  1. Fedora and other dnf based systems
  2. Ubuntu, Debian, and derivatives using apt
  3. Arch and Manjaro using pacman
  4. openSUSE using zypper

Requirements

  1. Bash
  2. sudo or root access
  3. usbutils for lsusb listing. The script checks and installs it if missing.

Quick start

  1. Clone the repository
  2. Make the script executable
  3. Run the script with sudo
  4. 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

Usage notes

  1. If the adapter is still listed as DISK after switching, physically unplug and replug it. Some devices require power cycling.
  2. 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.

  1. Connect to a network using NetworkManager:
nmcli dev wifi list
nmcli dev wifi connect "SSID" password "PASSWORD" ifname interface-name

Optional persistence

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.

Driver installation

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.

Troubleshooting

  1. usb_modeswitch not found Install it using your distribution’s package manager, or run this script with sudo so it installs automatically.

  2. 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.

  3. Device returns to DISK after reboot Use the persistence section above to add a permanent rule.

  4. Interface exists but cannot connect Update your system, install appropriate driver packages, and test with nmcli. Check dmesg for driver and firmware errors.

  5. Multiple Realtek devices Run the script again and choose the correct line. If both are present, disconnect one at a time to avoid confusion.

Security and safety

  1. The script only writes a temporary usb_modeswitch configuration in the current directory and deletes it after use.
  2. The script does not make permanent system changes unless you follow the optional persistence section.
  3. Review the script before running. It requires elevated privileges to install packages and call usb_modeswitch.

License

This project is licensed under a MIT license. See LICENSE for full terms.