收起左侧

Intel e1000e 网卡异常挂起解决方案(FnOS )

0
回复
61
查看
[ 复制链接 ]

1

主题

7

回帖

0

牛值

江湖小虾

飞牛百度网盘玩家

📌 适用对象:使用 Intel I219-V / I218-LM 网卡的 Linux 用户,遇到断网、挂起、SMB 扫描死机等问题


一、问题背景

在 FnOS 系统中,Intel 的 e1000e 网卡驱动可能出现以下异常:

  • Detected Hardware Unit Hang
  • tx timeout
  • NIC link is down
  • SMB 扫描或虚拟机桥接时网卡软死

image.png
via @janewar666


二、解决方案概览

我采用了以下四步方案,已在实际环境中验证稳定运行:

  1. ✅ 设置 modprobe 参数,优化驱动行为
  2. ✅ 创建 systemd 服务,关闭 offload 并调整队列
  3. ✅ 编写日志监控脚本,自动记录异常
  4. ✅ 每周生成异常报告,辅助分析与维护

三、驱动参数优化

SSH连接飞牛设备

登录后,sudo su 提权为root

✅ modprobe 参数配置(推荐方式)

创建编辑文件:

nano /etc/modprobe.d/e1000e.conf

复制粘贴内容(鼠标右键):

options e1000e InterruptThrottleRate=3000 RxIntDelay=0 TxIntDelay=0 SmartPowerDownEnable=0

保存并退出

  • 按下 Ctrl+O → 回车(保存)
  • 然后按下 Ctrl+X(退出)

说明:

  • InterruptThrottleRate=3000:限制中断频率,减少中断风暴
  • RxIntDelay=0 / TxIntDelay=0:关闭接收/发送延迟
  • SmartPowerDownEnable=0:禁用节能模式,避免网卡休眠导致挂起

✅ systemd 服务优化(关闭 offload + 调整队列)

创建编辑文件:

nano /etc/systemd/system/e1000e-fix.service

复制粘贴内容:

[Unit]
Description=Disable offload for e1000e to prevent hang
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/bin/bash -c '\
ethtool -K eno1 tso off gso off gro off; \
ethtool -C eno1 adaptive-rx on adaptive-tx on rx-usecs 64 tx-usecs 64; \
ethtool --set-eee eno1 eee off; \
ip link set eno1 txqueuelen 2000'
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

保存并退出

  • 按下 Ctrl+O → 回车(保存)
  • 然后按下 Ctrl+X(退出)

启用服务:

sudo systemctl daemon-reexec
sudo systemctl enable e1000e-fix.service
sudo systemctl start e1000e-fix.service

四、异常日志监控脚本(可选)

nano /usr/local/bin/debug-e1000e.sh

#!/bin/bash

LOGFILE="/vol1/1000/Doc/debug-e1000e.log"
COUNTERFILE="/tmp/e1000e_error_count"
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
link_status=$(ip link show eno1 | grep -q "state UP" && echo "UP" || echo "DOWN")
error_msg=""

if [ "$link_status" != "UP" ]; then
  error_msg="网卡状态异常:$link_status"
else
  raw_msg=$(dmesg | tail -n 200)
  if echo "$raw_msg" | grep -qiE 'Detected Hardware Unit Hang|tx timeout|resetting|NIC link is down'; then
    error_msg=$(echo "$raw_msg" | grep -iE 'Detected Hardware Unit Hang|tx timeout|resetting|NIC link is down')
  fi
fi

if [ ! -f "$COUNTERFILE" ]; then
  echo "0" > "$COUNTERFILE"
fi

if [ -n "$error_msg" ]; then
  count=$(cat "$COUNTERFILE")
  count=$((count + 1))
  echo "$count" > "$COUNTERFILE"

  {
    echo "[$timestamp] ⚠️ 异常检测:网卡状态 = $link_status"
    echo "[$timestamp] 错误日志:"
    echo "$error_msg"
    echo "异常累计次数:$count"
    echo "----------------------------------------"
  } >> "$LOGFILE"
fi

创建定时任务:

crontab -e
*/10 * * * * /usr/local/bin/debug-e1000e.sh

功能:

  • 每 10 分钟自动检测网卡状态
  • 仅记录真正异常(如 hang、tx timeout)
  • 输出日志至 /vol1/1000/debug-e1000e.log

五、总结

e1000e的bug,本人已经尝试过

  1. https://blog.csdn.net/Z_YMing/article/details/143424890
  2. https://gist.github.com/crypt0rr/60aaabd4a5c29a256b4f276122765237
  3. https://forum.proxmox.com/threads/e1000e-eno1-detected-hardware-unit-hang.59928/
  4. https://www.reddit.com/r/Proxmox/comments/1drs89s/intel_nic_e1000e_hardware_unit_hang/?tl=zh-hans
  5. https://gist.github.com/crypt0rr/60aaabd4a5c29a256b4f276122765237

这些方案会导致eno1网口不开启工作,因为:

  1. systemd 服务执行过早
  • systemd 服务是 After=network.target,但有些系统里 network.target 触发时网卡还没完全 ready。
  • 结果就是 ethtool 命令在网卡还没 up 的时候执行,导致参数没能正确应用,甚至直接让 eno1 保持 down 状态。
  1. ethtool 参数设置过激
  • 比如同时关闭了 rx/tx offloadgro/gso/tso,再加上 rx-usecs=0,在某些硬件/驱动组合下会让网卡初始化失败。
  • 特别是 ip link set eno1 txqueuelen 2000 如果执行时网卡还没 up,会报错,进一步影响启动。

现在的方案已在 FnOS 环境下稳定运行,成功规避了 e1000e 网卡挂起问题。
欢迎其他用户参考部署,如有更优改进欢迎交流!

本文内容及代码,大部分使用copilot-gpt5完成

收藏
送赞
分享

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则