centos7.9解决RTL8125网卡不识别的问题

1.获取网卡驱动源码

点击跳转到realtek官网下载页面

2.升级内核(可选)

不确定这个网卡依赖还是不依赖内核,建议升级内核版本

2.1 检查是否安装ELRepo
1
2
3
4
yum  --disablerepo="*"  --enablerepo="elrepo-kernel"  list  available
已加载插件:fastestmirror
Error getting repository data for elrepo-kernel, repository not found
# 看到error说明没有安装ELRepo
2.2 升级安装ELRepo
1
2
3
4
5
6
7
8
yum -y update
#载入ELRepo仓库的公共密钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

yum -y update
#载入ELRepo仓库的公共密钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

2.3.查看可用安装包
1
2
3
4
#查看可用的系统内核包
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available

# 长期维护版本为lt,最新主线稳定版为ml
2.4 手动下载
1
2
3
4
5
6
7
8
9
10
wget http://linux-mirrors.fnal.gov/linux/elrepo/archive/kernel/el7/x86_64/RPMS/kernel-lt-headers-5.4.242-1.el7.elrepo.x86_64.rpm
wget http://linux-mirrors.fnal.gov/linux/elrepo/archive/kernel/el7/x86_64/RPMS/kernel-lt-tools-libs-5.4.242-1.el7.elrepo.x86_64.rpm
wget http://linux-mirrors.fnal.gov/linux/elrepo/archive/kernel/el7/x86_64/RPMS/kernel-lt-devel-5.4.242-1.el7.elrepo.x86_64.rpm
wget http://linux-mirrors.fnal.gov/linux/elrepo/archive/kernel/el7/x86_64/RPMS/kernel-lt-tools-5.4.242-1.el7.elrepo.x86_64.rpm
wget http://linux-mirrors.fnal.gov/linux/elrepo/archive/kernel/el7/x86_64/RPMS/kernel-lt-tools-5.4.242-1.el7.elrepo.x86_64.rpm
#安装完成之后重新生成grub配置文件
#同样也可以删除掉旧的内核
rpm -qa | grep kernel
#然后移除相关的旧的内核包
grub2-mkconfig -o /boot/grub2/grub.cfg
2.5 查看内核启动顺序
1
2
3
4
5
6
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub2/grub.cfg

0 : CentOS Linux (5.4.108-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-1160.11.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)
3 : CentOS Linux (0-rescue-20210128140208453518997635111697) 7 (Core)
2.6 安装辅助工具
1
sudo yum install -y grub2-pc
2.7 设置内核启动顺序
1
sudo grub2-set-default 0
2.8 重新生成grub配置文件
1
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
2.9 重启
1
sudo reboot

3.更换gcc

1
2
3
4
5
6
7
8
9
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-8-binutils-2.30-55.el7.1.x86_64.rpm
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-8-gcc-8.3.1-3.2.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-8-gcc-c%2B%2B-8.3.1-3.2.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-8-gcc-gdb-plugin-8.3.1-3.2.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-8-gcc-gfortran-8.3.1-3.2.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-8-gcc-plugin-devel-8.3.1-3.2.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-8-libquadmath-devel-8.3.1-3.2.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-8-libstdc%2B%2B-devel-8.3.1-3.2.el7.x86_64.rpm
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/sclo/x86_64/rh/Packages/d/devtoolset-8-runtime-8.1-1.el7.x86_64.rpm

将所有下载好的软件包安装完毕
激活toolchain

1
2
3
4
5
6
7
8
9
10
11
cd /opt/rh/devtoolset-8 
./enable
#直接替换旧的gcc
#旧的gcc是运行的 /usr/bin/gcc,所以将该目录下的gcc/g++替换为刚安装的新版本gcc软连接,免得每次enable
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++-4.8.5
ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++
查看gcc版本是否已经升级成功
gcc --version
g++ --version

4.开始编译第一步下载驱动源码,并安装

1
2
cd r8125-9.011.01 
./autorun.sh

centos7.9解决RTL8125网卡不识别的问题
https://dreamaccount.github.io/2023/05/15/centos7-9解决ETL8125网卡不识别的问题/
作者
404NotFound
发布于
2023年5月15日
许可协议