Shuitai
Articles2
Tags3
Categories2
在Ubuntu 22.04.1 LTS上安装Realtek 8852BE网卡驱动

在Ubuntu 22.04.1 LTS上安装Realtek 8852BE网卡驱动

前言

在双十一活动上,我看中了Lenovo ThinkBook 16+(Intel i5版本挺便宜的)

买下来到货之后,便心血来潮装了个Ubuntu 22.04作为编写blog的地方,结果发现Ubuntu没有Windows 11有的wifi选项,只有以太网(有线网络)能用。

摸索

在装之前,我拿了旧电脑进行安装尝试,那边是有wifi选项的。(实际上这不是我的电脑,后面被我爸呵斥停止安装了)

没有了wifi选项,让我怀疑是不是Ubuntu 22.04所配置的内核(Linux Kernel 5.15.0-43-generic)没有与该电脑的无线网卡对应的驱动。

于是我先换回Windows 11系统,查看电脑配置的网卡。

一看是Intel Realtek 8852BE,心想,linux绝对不可能有这类网卡驱动了。

然后我去度娘、CSDN、Google等处,都让我自己用以太网自己安装网卡驱动。TMD 这怎么可能啊 学校的有线网络服务比我流量卡100G流量费还贵 带宽还烂

于是我只能在windows系统自己找办法安装所需了。

运气很好,我很快在GitHub上找到了与我电脑网卡型号有关的repo(度娘直接搜Intel Realtek 8852BE):lwfinger/rtw89

安装驱动

让我们来看看这个repo的内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
## A repo for the newest Realtek rtlwifi codes.

This branch was created from the version merged into the wireless-drivers-next repo, which is in the 5.16 kernel. IF YOU USE DRIVERS FROM THIS REPO FOR KERNELS 5.16+, TOU MUST BLACKLIST THE KERNEL VERSIONS!!!! FAILING TO DO THIS WILL RESULT IN ALL MANNER OF STRANGE ERRORS.

This code will build on any kernel 5.7 and newer as long as the distro has not modified any of the kernel APIs. IF YOU RUN UBUNTU, YOU CAN BE ASSURED THAT THE APIs HAVE CHANGED. NO, I WILL NOT MODIFY THE SOURCE FOR YOU. YOU ARE ON YOUR OWN!!!!!

I am working on fixing builds on older kernels.

This repository includes drivers for the following card:

Realtek 8852AE, 8852BE, and 8853CE

If you are looking for a driver for chips such as RTL8188EE, RTL8192CE, RTL8192CU, RTL8192DE, RTL8192EE, RTL8192SE, RTL8723AE, RTL8723BE, or RTL8821AE, these should be provided by your kernel. If not, then you should go to the Backports Project (https://backports.wiki.kernel.org/index.php/Main_Page) to obtain the necessary code.

省流:仅适配Realtek 8852AE, 8852BE, 8853CE这仨无线网卡型号,并且内核版本要在5.7及以上,5.16及以下(因为5.16以上版本有可能会出现莫名其妙的bug)。

再来看看安装步骤:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Requirements

You will need to install "make", "gcc", "kernel headers", "kernel build essentials", and "git".

For Ubuntu: You can install them with the following command

sudo apt-get update
sudo apt-get install make gcc linux-headers-$(uname -r) build-essential git

## Installation

### For all distros:

git clone https://github.com/lwfinger/rtw89.git
cd rtw89
make
sudo make install

## Installation with module signing for SecureBoot

### For all distros:

git clone https://github.com/lwfinger/rtw89.git
cd rtw89
make
sudo make sign-install

大概意思是,安装驱动前你得先安装make, gcc, kernel headers, kernel build essentials, git这五样东西。

然后我试了一下:

1
2
3
4
5
$ make --version
make: 未找到命令

$ gcc --version
gcc: 未找到命令

又要我自己一个人手动安装了……还好我自己就有一个ubuntu服务器,可以手动下载deb包并拷贝过来。

经过调查,安装的核心都在build-essential上,我可以通过build-essential进行依赖包递归搜索。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!usr/bin/bash

logfile="./apt-downloaded.log"
ret=""

function getDepends() {
echo "fileName is" $1>>$logfile
# use tr to del < >
ret=`apt-cache depends $1|grep Depends |cut -d: -f2 |tr -d "<>"`
echo $ret|tee -a $logfile
}

# 需要获取其所依赖包的包
libs="build-essential"

# download libs dependen. deep in 5
# downloaded files will be saved in /var/cache/apt/archives
i=0
while [ $i -lt 5 ] ;
do
let i++
echo $i
# download libs
newlist=" "
for j in $libs
do
added="$(getDepends $j)"
newlist="$newlist $added"
apt-get install $added --reinstall -d -y
done
libs=$newlist
done

就这样,所有依赖包安装完成了,把所有安装好的包复制到任意路径中,输入以下命令运行:

1
2
3
4
5
# 注意事项:
# 1.请不要使用dpkg -i命令,此命令不会按照依赖顺序安装,运行后不仅会报出依赖包未安装的错误,还会把apt搞崩,严重不推荐;
# 2.请在apt install前加入sudo命令以root权限运行,或者直接登录root账号,这里就不多说了;
# 3.在安装包名称前请加上路径名称,如./xxx,否则apt会从/var/cache/apt/archives上查找安装包,导致文件不存在的报错。
$ sudo apt install ./build-essential*

安装完成后,再把自己提前准备好的rtw89文件夹复制到任意路径中,然后再运行上面安装步骤中的Installation下的命令,等待安装完成。

当你在设置窗口中看到以下东西时,说明你已经成功安装了Realtek 8852BE的网卡驱动啦!

success image

Author:Shuitai
Link:https://bigshuitai.github.io/ubuntu-rtw89.html
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可
×