AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1393562
Accepted
Terrance
Terrance
Asked: 2022-02-18 21:37:26 +0800 CST2022-02-18 21:37:26 +0800 CST 2022-02-18 21:37:26 +0800 CST

启动时解绑和绑定驱动 20.04.3 LTS

  • 772

我的系统正在运行 20.04.3 LTS,我将它用作 Plex 媒体服务器(以及其他服务)。我正在使用绑定网络在系统上进行自适应负载平衡。当系统收到新的内核更新时,我遇到了系统问题。

系统中有2个网卡。一个在插槽中(RTL8169 PCI 千兆以太网控制器),另一个在板载(RTL8111/8168/8411 PCI Express 千兆以太网控制器)。我遇到的问题是 RTL8111/8168/8411 不喜欢 r8169 驱动程序(会发生不可预测的事情,例如无法与互联网通信)所以我必须运行以下命令来取消绑定 r8169 驱动程序并绑定r8168 驱动程序:

address=$(lspci | awk '/8168/ {print "0000:"$1}')
echo $address | sudo tee /sys/bus/pci/drivers/r8169/unbind
echo $address | sudo tee /sys/bus/pci/drivers/r8168/bind

运行这些命令后,驱动程序在lshw命令中正确显示,当为正确的卡设置正确的驱动程序时,我没有任何问题:

terrance@Intrepid:~$ sudo lshw -C network
  *-network                 
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: eth0
       version: 03
       serial: c8:3a:35:d6:ec:a0
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8168 driverversion=8.048.00-NAPI duplex=full latency=0 link=yes multicast=yes port=twisted pair slave=yes speed=1Gbit/s
       resources: irq:25 ioport:d800(size=256) memory:fdfff000-fdffffff memory:fdff8000-fdffbfff
  *-network
       description: Ethernet interface
       product: RTL8169 PCI Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 5
       bus info: pci@0000:03:05.0
       logical name: eth1
       version: 10
       serial: bc:5f:f4:79:66:fe
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 32 bits
       clock: 66MHz
       capabilities: pm bus_master cap_list rom ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.13.0-30-generic duplex=full latency=64 link=yes maxlatency=64 mingnt=32 multicast=yes port=twisted pair slave=yes speed=1Gbit/s
       resources: irq:20 ioport:e800(size=256) memory:febffc00-febffcff memory:febc0000-febdffff
  *-network
       description: Ethernet interface
       physical id: 1
       logical name: bond0
       serial: bc:5f:f4:79:66:fe
       capabilities: ethernet physical
       configuration: autonegotiation=off broadcast=yes driver=bonding driverversion=5.13.0-30-generic duplex=full firmware=2 ip=10.0.0.220 link=yes master=yes multicast=yes

这会持续到重新启动,直到下一次内核更新。但是,如果我在脚本中运行那些完全相同的命令,它会告诉我“没有这样的设备”

terrance@Intrepid:~/bin$ sudo ./driver_fix.bsh 
0000:02:00.0
tee: /sys/bus/pci/drivers/r8169/unbind: No such device
0000:02:00.0
tee: /sys/bus/pci/drivers/r8168/bind: No such device

什么是我可以使它永久化的最佳方法,以便它在启动期间进行此更改,或者仅在发生内核更新时更改?

谢谢!

networking
  • 1 1 个回答
  • 248 Views

1 个回答

  • Voted
  1. Best Answer
    Terrance
    2022-03-05T09:01:19+08:002022-03-05T09:01:19+08:00

    事实证明,您需要unbind在它运行之前创建bind。您可以将其添加到脚本中,然后在重新启动时使用 cron 或其他可能的 systemd 运行。

    我将以下行添加到脚本文件中:

    sh -c "echo 0000:02:00.0 > /sys/bus/pci/drivers/r8169/unbind"
    sh -c "echo 0000:02:00.0 > /sys/bus/pci/drivers/r8168/bind"
    

    然后将以下行添加到/etc/crontab:

    @reboot     root    /home/terrance/bin/fix_rtl.bsh
    

    现在,当系统重新启动时,正确的驱动程序已连接到正确的 NIC。

    terrance@Intrepid:~$ sudo lshw -C network
      *-network                 
           description: Ethernet interface
           product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
           vendor: Realtek Semiconductor Co., Ltd.
           physical id: 0
           bus info: pci@0000:02:00.0
           logical name: eth0
           version: 03
           serial: bc:5f:f4:79:66:fe
           size: 1Gbit/s
           capacity: 1Gbit/s
           width: 64 bits
           clock: 33MHz
           capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
           configuration: autonegotiation=on broadcast=yes driver=r8168 driverversion=8.049.02-NAPI duplex=full latency=0 link=yes multicast=yes port=twisted pair slave=yes speed=1Gbit/s
           resources: irq:25 ioport:d800(size=256) memory:fdfff000-fdffffff memory:fdff8000-fdffbfff
      *-network
           description: Ethernet interface
           product: RTL8169 PCI Gigabit Ethernet Controller
           vendor: Realtek Semiconductor Co., Ltd.
           physical id: 5
           bus info: pci@0000:03:05.0
           logical name: eth1
           version: 10
           serial: c8:3a:35:d6:ec:a0
           size: 1Gbit/s
           capacity: 1Gbit/s
           width: 32 bits
           clock: 66MHz
           capabilities: pm bus_master cap_list rom ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
           configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.13.0-35-generic duplex=full latency=64 link=yes maxlatency=64 mingnt=32 multicast=yes port=twisted pair slave=yes speed=1Gbit/s
           resources: irq:20 ioport:e800(size=256) memory:febffc00-febffcff memory:febc0000-febdffff
      *-network
           description: Ethernet interface
           physical id: 1
           logical name: bond0
           serial: c8:3a:35:d6:ec:a0
           capabilities: ethernet physical
           configuration: autonegotiation=off broadcast=yes driver=bonding driverversion=5.13.0-35-generic duplex=full firmware=2 ip=10.0.0.220 link=yes master=yes multicast=yes
    
    • 0

相关问题

  • 如何设置 VLAN 转发?

  • 如何将主机 Ubuntu 上的 VPN (tun0) 网络适配器映射到 VirtualBox 来宾 Windows?

  • 如何限制下载/上传带宽?

  • 如何通过 Windows 网络共享文件?

  • 面板小程序以文本形式显示当前网络流量?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve