$ lsusb Bus 001 Device 009: ID 0bda:1a2b Realtek Semiconductor Corp. RTL8188GU 802.11n WLAN Adapter (Driver CDROM Mode)
好吧,也不指望开箱即用,下面涉及两个问题:
驱动问题
为什么NIC会显示成CDROM?如何解决?
1. 驱动问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14
kernel: usb 1-2: new high-speed USB device number 5 using xhci_hcd kernel: usb 1-2: New USB device found, idVendor=0bda, idProduct=c811, bcdDevice= 2.00 kernel: usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 kernel: usb 1-2: Product: 802.11ac NIC kernel: usb 1-2: Manufacturer: Realtek kernel: usb 1-2: SerialNumber: 123456 kernel: Loading firmware: rtw88/rtw8821c_fw.bin kernel: rtw_8821cu 1-2:1.0: Direct firmware load for rtw88/rtw8821c_fw.bin failed with error -2 kernel: rtw_8821cu 1-2:1.0: failed to request firmware kernel: rtw_8821cu 1-2:1.0: failed to load firmware kernel: rtw_8821cu 1-2:1.0: failed to setup chip efuse info kernel: rtw_8821cu 1-2:1.0: failed to setup chip information kernel: rtw_8821cu 1-2:1.0: probe with driver rtw_8821cu failed with error -22 kernel: usbcore: registered new interface driver rtw_8821cu
有关日志如上,看来是缺少驱动,可以注意到使用rtw88/rtw8821c_fw.bin驱动,需要注意的是,该驱动如今已经在内核中原生支持,如果不支持,请考虑升级Linux内核,我使用的是Gentoo,并启用了linux-firmware的savedconfig USE flag, 这会删除所有我没显式指定的驱动,以节约空间,所以加上再重新安装就完美解决了:
echo rtw88/rtw8821c_fw.bin | sudo tee -a /etc/portage/savedconfig/sys-kernel/linux-firmware
2.为什么NIC会显示成CDROM?如何解决?
在经过一番搜索后,找到了这个项目,记录了大量 Linux 上 USB NIC 的知识,在此表示敬意o>
Question: My USB WiFi adapter is showing up as a CDROM or Flash drive instead of a WiFi adapter. What is the problem? Answer: Your USB WiFi adapter showing up as a CDROM or Flash drive (often with ID 0bda:1a2b) instead of functioning as a network adapter (such as ID 35bc:0102 or similar) is likely due to a “mode-switching” issue. Some USB WiFi adapters include onboard memory that contains drivers or installation software for Windows. When plugged into a system for the first time, they initially present themselves as a virtual CD-ROM or Flash driver containing the drivers. This is fairly common with USB WiFi adapters that use Realtek chipset. 您的 USB WiFi 适配器显示为光驱或闪存盘(通常为 ID 0bda:1a2b),而非作为网络适配器(如 ID 35bc:0102 等)正常工作,这很可能是由于「模式切换」问题所致。一些 USB WiFi 适配器包含内置存储,其中存放了 Windows 的驱动程序或安装软件。首次插入系统时,它们会先以虚拟光驱或闪存盘的形式出现,包含驱动程序。这在使用 Realtek 芯片的 USB WiFi 适配器中相当常见。
In Linux, the usb_modeswitch utility generally handles this issue but there are situations where it does not work as expected. 在 Linux 中,usb_modeswitch 工具通常可以处理此问题,但某些情况下可能无法按预期工作。
$ usb_modeswitch -K -W -v 0bda -p 1a2b Take all parameters from the command line
* usb_modeswitch: handle USB devices with multiple modes * Version 2.6.1 (C) Josua Dietze 2017 * Based on libusb1/libusbx
! PLEASE REPORT NEW CONFIGURATIONS !
DefaultVendor= 0x0bda DefaultProduct= 0x1a2b
StandardEject=1
Look for default devices ... found USB ID 0bda:9210 vendor ID matched found USB ID 1d6b:0003 found USB ID 13d3:56fb found USB ID 0489:e0cd found USB ID 258a:010c found USB ID 1ea7:0066 found USB ID 0fe6:9910 found USB ID 1a40:0101 found USB ID 1d6b:0002 found USB ID 1d6b:0003 found USB ID 0bda:c811 vendor ID matched found USB ID 1d6b:0002 No devices in default mode found. Nothing to do. Bye!
$ lsusb Bus 001 Device 012: ID 0bda:c811 Realtek Semiconductor Corp. 802.11ac NIC
WoW, It works!下面就是配置自动执行了,具体可以在链接里看,基本就是添加一条udev规则和usb_modeswitch配置。
配置热点
下面ip link可以看到网卡了:
1 2 3
6: wlp5s0f3u2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DORMANT group default qlen 1000 link/ether 5a:74:98:1d:ab:ed brd ff:ff:ff:ff:ff:ff permaddr 6c:1f:f7:0f:60:c1 altname wlx6c1ff70f60c1