为 PVE 安装 RTL8125B 2.5G网卡驱动

Prologue

年末对自己分流设备做了一次配置升级,宿主机系统选择了Proxmox VE
CPU把原先的AMD Ryzen 3 2200G,更换为了ADM R5 5600G
主板从A320M-HDV换成了MSI MAG B550M MORTAR WIFI

B550M这块主板自带了2.5G LAN口,正好配合我的交换机和NAS使用
由于换成了PVE 7.0,Linux kernels 5.4+已自带R8169驱动,支持Realtek 8169/8168/8101/8125
这里记录下之前装驱动的瞎折腾过程

Get Ethernet Driver

在MSI官网找下这块板子的参数,使用的是 Realtek® RTL8125B 2.5G LAN
https://us.msi.com/Motherboard/MAG-B550M-MORTAR-WIFI/Specification

到 Realtek®官网找到即可linux驱动即可下载
选择2.5G Ethernet LINUX driver r8125 for kernel up to 5.6并下载
https://www.realtek.com/ja/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software

Install Dependence / Compile

由于官方源还是挺慢的,这里还是换成清华大学的开源镜像源
https://mirrors.tuna.tsinghua.edu.cn/help/debian/

Debian 的软件源配置文件是 /etc/apt/sources.list

1
2
3
4
5
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

然后添加非商业源,编辑 /etc/apt/sources.list.d/pve-no-subscription.list

1
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian bullseye pve-no-subscription

删除企业源

1
rm /etc/apt/sources.list.d/pve-enterprise.list

更新源,并安装编译必要的依赖

1
2
3
4
5
6
7
apt update -y

apt -y install dkms make gcc

### PVE7的话,已经安装了`libc6`和`libelf`,下面就不需要执行了
apt -y install build-essential
apt -y install libelf-dev

当然,要编译还需要安装 Linux Kernel Header
使用uname -r看下内核版本,比如我的是5.11.22-4-pve,然后apt search找下并安装即可
如果没有搜索到,请按上面步骤添加pve-no-subscription

1
2
3
4
5
6
7
8
9
10
11
12
13
root@shirobako:~# uname -r
5.11.22-4-pve

root@shirobako:~# apt search 5.11.22-4
Sorting... Done
Full Text Search... Done
pve-headers-5.11.22-4-pve/stable 5.11.22-9 amd64
The Proxmox PVE Kernel Headers

pve-kernel-5.11.22-4-pve/stable 5.11.22-9 amd64 [upgradable from: 5.11.22-8]
The Proxmox PVE Kernel Image

root@shirobako:~# apt install pve-headers-5.11.22-4-pve

编译安装网卡驱动

1
2
3
4
5
6
### 把下载好的驱动解压
tar vjxf r8125*

### 运行 autorun.sh
chmod a+x autorun.sh
./autorun.sh

Do Some Tests

测试一下网卡驱动是否成功,lsmod | grep r8125有返回就表示驱动打上了
看下网卡状态

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
33
34
35
36
37
38
39
### 安装一些网络工具
root@shirobako: apt -y install net-tools ethtool

### 使用 ifconfig 看下网卡名字,比如我的是enp42s0
### 用 ethtool 看下状态, Speed: 2500Mb/s 就对了
root@shirobako: ethtool enp42s0
Settings for enp42s0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
2500baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
2500baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
2500baseT/Full
Link partner advertised pause frame use: Symmetric Receive-only
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 2500Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: pumbg
Wake-on: d
Link detected: yes

可以用iperf3和另一台主机试一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
root@shirobako: iperf3 -c 192.168.50.111
Connecting to host 192.168.50.111, port 5201
[ 5] local 192.168.50.150 port 58048 connected to 192.168.50.111 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 285 MBytes 2.39 Gbits/sec 0 649 KBytes
[ 5] 1.00-2.00 sec 284 MBytes 2.38 Gbits/sec 0 649 KBytes
[ 5] 2.00-3.00 sec 282 MBytes 2.37 Gbits/sec 0 771 KBytes
[ 5] 3.00-4.00 sec 282 MBytes 2.37 Gbits/sec 0 771 KBytes
[ 5] 4.00-5.00 sec 284 MBytes 2.38 Gbits/sec 0 771 KBytes
[ 5] 5.00-6.00 sec 281 MBytes 2.36 Gbits/sec 0 807 KBytes
[ 5] 6.00-7.00 sec 284 MBytes 2.38 Gbits/sec 0 807 KBytes
[ 5] 7.00-8.00 sec 282 MBytes 2.37 Gbits/sec 0 807 KBytes
[ 5] 8.00-9.00 sec 281 MBytes 2.36 Gbits/sec 0 807 KBytes
[ 5] 9.00-10.00 sec 282 MBytes 2.37 Gbits/sec 0 807 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 2.76 GBytes 2.37 Gbits/sec 0 sender
[ 5] 0.00-10.00 sec 2.76 GBytes 2.37 Gbits/sec receiver

iperf Done.

看起来一切在正常