一、前绪
使用SRPM包进行驱动的安装。通过安装Mellanox驱动为实例,进行实验,了解安装过程。
二、安装过程
1. 安装前环境检查
[root@test01 ~]# cat /etc/centos-releaseCentOS Linux release 7.4.1708 (Core) [root@test01 ~]# modprobe mlx5_core[root@test01 ~]# modinfo mlx5_core |grep versionversion: 3.0-1rhelversion: 7.4srcversion: 6B257EBEC4CCEF0E923530Fvermagic: 3.10.0-693.el7.x86_64 SMP mod_unload modversions [root@test01 ~]#
2. 下载驱动
网址为:http://www.mellanox.com/page/products_dyn?product_family=27
[root@test01 ~]# wget http://www.mellanox.com/downloads/ofed/MLNX_EN-4.4-1.0.1.0/MLNX_EN_SRC-4.4-1.0.1.0.tgz[root@test01 ~]# tar -zxvf MLNX_EN_SRC-4.4-1.0.1.0.tgz[root@test01 ~]# lsanaconda-ks.cfg MLNX_EN_SRC-4.4-1.0.1.0 MLNX_EN_SRC-4.4-1.0.1.0.tgz[root@test01 ~]# cd MLNX_EN_SRC-4.4-1.0.1.0/SRPMS/[root@test01 SRPMS]# lsmlnx-en-4.4-1.0.1.0.g3097d75.src.rpm mlnx-ofa_kernel-4.4-OFED.4.4.1.0.1.1.g3097d75.src.rpm[root@test01 SRPMS]#
3. 编译SRPM包
通过名字可以知道,mlnx-en-4.4-1.0.1.0.g3097d75.src.rpm是我们需要安装的源码包
[root@test01 SRPMS]# yum install rpm-build[root@test01 SRPMS]# rpmbuild --rebuild mlnx-en-4.4-1.0.1.0.g3097d75.src.rpm...configure: error: in `/root/rpmbuild/BUILD/mlnx-en-4.4/obj/default/compat':configure: error: no acceptable C compiler found in $PATHRPM build errors: user builder does not exist - using root Bad exit status from /var/tmp/rpm-tmp.9pRVH1 (%build)
通过报错我们知道,缺少编译器,所以我们安装gcc
[root@test01 SRPMS]# yum install gcc[root@test01 SRPMS]# rpmbuild --rebuild mlnx-en-4.4-1.0.1.0.g3097d75.src.rpmchecking for Linux sources... /usr/src/kernels/3.10.0-693.el7.x86_64checking for /usr/src/kernels/3.10.0-693.el7.x86_64... noconfigure: error: Kernel source /usr/src/kernels/3.10.0-693.el7.x86_64 could not be found.
通过报错我们知道,缺少kernel-devel。一般安装驱动都需要这个。
[root@test01 SRPMS]# rpm -ivh http://vault.centos.org/7.4.1708/os/x86_64/Packages/kernel-devel-3.10.0-693.el7.x86_64.rpm[root@test01 SRPMS]# rpmbuild --rebuild mlnx-en-4.4-1.0.1.0.g3097d75.src.rpm...+ rm -rf mlnx-en-4.4+ exit 0
4. 安装RPM驱动包
咋这么多包?用哪个呢?
[root@test01 SRPMS]# cd /root/rpmbuild/RPMS/x86_64/[root@test01 x86_64]# lsmlnx_en-4.4-1.0.1.0.g3097d75.kver.3.10.0_693.el7.x86_64.x86_64.rpm mlnx-en-doc-4.4-1.0.1.0.g3097d75.x86_64.rpm mlnx-en-utils-4.4-1.0.1.0.g3097d75.x86_64.rpmmlnx-en-debuginfo-4.4-1.0.1.0.g3097d75.x86_64.rpm mlnx-en-sources-4.4-1.0.1.0.g3097d75.x86_64.rpm
查看每个包的信息,主要看描述。
从描述上看大体上应该是这两个包有用。
[root@test01 x86_64]# rpm -qpi mlnx_en-4.4-1.0.1.0.g3097d75.kver.3.10.0_693.el7.x86_64.x86_64.rpm Name : mlnx_enVersion : 4.4Release : 1.0.1.0.g3097d75.kver.3.10.0_693.el7.x86_64Architecture: x86_64Install Date: (not installed)Group : System Environment/BaseSize : 2072959License : GPLv2Signature : (none)Source RPM : mlnx-en-4.4-1.0.1.0.g3097d75.src.rpmBuild Date : Sat 11 Aug 2018 04:56:51 AM EDTBuild Host : localhostRelocations : (not relocatable)Vendor : Mellanox TechnologiesURL : http://www.mellanox.comSummary : Ethernet NIC DriverDescription :ConnectX Ehternet device driverThe driver sources are located at: http://www.mellanox.com/downloads/Drivers/mlnx-en-4.4-1.0.1.tgz[root@test01 x86_64]# rpm -qpi mlnx-en-utils-4.4-1.0.1.0.g3097d75.x86_64.rpm Name : mlnx-en-utilsVersion : 4.4Release : 1.0.1.0.g3097d75Architecture: x86_64Install Date: (not installed)Group : System Environment/LibrariesSize : 289106License : GPLv2Signature : (none)Source RPM : mlnx-en-4.4-1.0.1.0.g3097d75.src.rpmBuild Date : Sat 11 Aug 2018 04:56:51 AM EDTBuild Host : localhostRelocations : (not relocatable)Vendor : Mellanox TechnologiesURL : http://www.mellanox.comSummary : Utilities for the Mellanox Ethernet Driver for LinuxDescription :Utilities for the Mellanox Ethernet Driver for LinuxThe driver sources are located at: http://www.mellanox.com/downloads/Drivers/mlnx-en-4.4-1.0.1.tgz
查看是否包含驱动文件*.ko
[root@test01 x86_64]# rpm -qpl mlnx_en-4.4-1.0.1.0.g3097d75.kver.3.10.0_693.el7.x86_64.x86_64.rpm |grep ko/lib/modules/3.10.0-693.el7.x86_64/extra/mlnx-en/compat/mlx_compat.ko/lib/modules/3.10.0-693.el7.x86_64/extra/mlnx-en/drivers/infiniband/hw/mlx4/mlx4_ib.ko/lib/modules/3.10.0-693.el7.x86_64/extra/mlnx-en/drivers/infiniband/hw/mlx5/mlx5_ib.ko/lib/modules/3.10.0-693.el7.x86_64/extra/mlnx-en/drivers/net/ethernet/mellanox/mlx4/mlx4_core.ko/lib/modules/3.10.0-693.el7.x86_64/extra/mlnx-en/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko/lib/modules/3.10.0-693.el7.x86_64/extra/mlnx-en/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko/lib/modules/3.10.0-693.el7.x86_64/extra/mlnx-en/drivers/net/ethernet/mellanox/mlxfw/mlxfw.ko
经查看,只有mlnx_en-4.4-1.0.1.0.g3097d75.kver.3.10.0_693.el7.x86_64.x86_64.rpm有驱动文件,所以进行安装。
[root@test01 x86_64]# rpm -ivh mlnx_en-4.4-1.0.1.0.g3097d75.kver.3.10.0_693.el7.x86_64.x86_64.rpm error: Failed dependencies: mlnx-en-utils is needed by mlnx_en-4.4-1.0.1.0.g3097d75.kver.3.10.0_693.el7.x86_64.x86_64[root@test01 x86_64]# rpm -ivh mlnx-en-utils-4.4-1.0.1.0.g3097d75.x86_64.rpm Preparing... ################################# [100%]Updating / installing... 1:mlnx-en-utils-4.4-1.0.1.0.g3097d7################################# [100%][root@test01 x86_64]# rpm -ivh mlnx_en-4.4-1.0.1.0.g3097d75.kver.3.10.0_693.el7.x86_64.x86_64.rpm Preparing... ################################# [100%]Updating / installing... 1:mlnx_en-4.4-1.0.1.0.g3097d75.kver################################# [100%]
5. 验证
[root@test01 x86_64]# modinfo mlx5_core |grep versionversion: 4.4-1.0.1rhelversion: 7.4srcversion: 1E2A3C67DF295A97772E512vermagic: 3.10.0-693.el7.x86_64 SMP mod_unload modversions
三、问题
有些驱动厂家为了给客户提供更好的服务,在安装驱动的时候附加了许多额外功能。这也就是为什么我们编译出来的RPM包这么多的原因。而日常工作中,厂家提供的这些额外功能基本上用不到,可以不用安装。