How to Install RTL8812BU USB WiFi Dongle on Linux
by Alan Pfahler on January 31, 2020NOTE: Install USB Wi-Fi Adapters(RTL8812BU chipset) on GUN/Linux, a few known wireless cards that use this driver include:
Installing the Driver(RTL8812BU Chipset) on Your System:
Open a terminal window. Copy & paste the following into the terminal window and hit Return. You may be prompted to enter your password.
# Ubuntu/Mint/Kali (tested)
sudo apt update sudo apt -y install dkms git bc git clone https://github.com/fastoe/RTL8812BU.git cd RTL8812BU VER=$(sed -n 's/\PACKAGE_VERSION="\(.*\)"/\1/p' dkms.conf) sudo rsync -rvhP ./ /usr/src/rtl88x2bu-${VER} sudo dkms add -m rtl88x2bu -v ${VER} sudo dkms build -m rtl88x2bu -v ${VER} sudo dkms install -m rtl88x2bu -v ${VER} sudo modprobe 88x2bu sudo reboot


# openSUSE Leap 15.1/Debian 10 (tested)
sudo apt update sudo apt -y install dkms git bc git clone https://github.com/fastoe/RTL8812BU.git cd RTL8812BU VER=$(sed -n 's/\PACKAGE_VERSION="\(.*\)"/\1/p' dkms.conf) sudo rsync -rvhP ./ /usr/src/rtl88x2bu-${VER} sudo dkms add -m rtl88x2bu -v ${VER} sudo dkms build -m rtl88x2bu -v ${VER} sudo dkms install -m rtl88x2bu -v ${VER} sudo modprobe 88x2bu sudo reboot


# For setting monitor mode
# configure for monitor mode sed -i 's/CONFIG_80211W = n/CONFIG_80211W = y/' Makefile sed -i 's/CONFIG_WIFI_MONITOR = n/CONFIG_WIFI_MONITOR = y/' Makefile make sudo make install sudo ifconfig wlx1cbfcea97791 down sudo iwconfig wlx1cbfcea97791 mode monitor sudo ifconfig wlx1cbfcea97791 up

# Raspbian (Raspberry Pi OS)
Currently tested with Linux RaspberryPi 5.4.51-v7l+/4.19.118-v7+/4.19.97-v7+ on:
- Raspberry Pi 4 B
- Raspberry Pi Zero W
- Raspberry Pi 3 B+
- Raspberry Pi 2 B
For Raspberry Pi OS 5.10 kernel, please clone the v5.6.1 branch:
sudo apt update sudo apt install -y bc git dkms build-essential raspberrypi-kernel-headers git clone -b v5.6.1 https://github.com/fastoe/RTL8812BU_for_Raspbian cd RTL8812BU_for_Raspbian make sudo make install sudo reboot
For Raspberry Pi OS 5.4 kernel:
sudo apt update sudo apt install -y bc git dkms build-essential raspberrypi-kernel-headers git clone https://github.com/fastoe/RTL8812BU_for_Raspbian cd RTL8812BU_for_Raspbian make sudo make install sudo reboot
If fails to compile like /lib/modules/5.x.x-v7+/build: No such file or directory. Stop:
pi@raspberrypi:~/RTL8812BU_for_Raspbian $ make make ARCH=arm CROSS_COMPILE= -C /lib/modules/5.4.51-v7+/build M=/home/pi/RTL8812BU_for_Raspbian modules make[1]: *** /lib/modules/5.4.51-v7+/build: No such file or directory. Stop. make: *** [Makefile:2284: modules] Error 2
please run the rpi-source command to install the kernel headers for kernel:
sudo apt install -y bc git flex bison libssl-dev sudo wget https://raw.githubusercontent.com/RPi-Distro/rpi-source/master/rpi-source -O /usr/local/bin/rpi-source && sudo chmod +x /usr/local/bin/rpi-source && /usr/local/bin/rpi-source -q --tag-update rpi-source
then, re-make again.

Known Issues
Below are a few known bugs,
- Always required autenthication without connect on 5GHz band
- Short disconnects every few seconds on 5GHz band
the above problems are caused by power saving. First, make sure that the power supply of your Raspberry Pi can provide 3A current, then we can disable the 8812bu WiFi adapter power saving.
sudo modprobe -r 88x2bu sudo modprobe 88x2bu rtw_power_mgnt=0 rtw_ips_mode=0 rtw_enusbss=0 sudo echo "options 88x2bu rtw_power_mgnt=0 rtw_ips_mode=0 rtw_enusbss=0" | sudo tee /etc/modprobe.d/88x2bu.conf
When the current is around 100mA, it never disconnects.

144 mA@full speed download (22MB/s).

Installation video
References
- Driver for RTL8812BU(RTL88x2BU) WiFi Adapters - Raspberry Pi
- Driver for RTL8812BU(RTL88x2BU) WiFi Adapters
Enjoy!