永久禁用以太网以加快启动时间

Anw*_*war 5 boot network-manager kernel ethernet

我不使用有线以太网卡。在我看来,Ubuntu 总是在启动时尝试通过 eth0 检查网络,这会消耗一些时间,我想这可能会稍微减慢启动过程。我的dmesg输出低于(部分)

2012-06-11 23:06:47 Ubuntu-KDE 内核 [1.985592] 输入:视频总线为 /devices/LNXSYSTM:00/device:00/PNP0A08:00/LNXVIDEO:01/input/input5
2012-06-11 23:06:47 Ubuntu-KDE 内核 [1.985651] ACPI:视频设备 [GFX0](多头:是 ROM:无帖子:否)
2012-06-11 23:06:47 Ubuntu-KDE 内核 [1.985693] [drm] 初始化 i915 1.6.0 20080730 为 0000:00:02.0 次要 0
2012-06-11 23:06:47 Ubuntu-KDE 内核 [2.056261] firewire_core:创建设备 fw0:GUID 00023f87af41fd7d,S400
2012-06-11 23:06:47 Ubuntu-KDE 内核 [3.710435] EXT4-fs (sda9):以有序数据模式挂载的文件系统。选项:(空)
                                 A big time here.....
Run Code Online (Sandbox Code Playgroud)
2012-06-11 23:06:47 Ubuntu-KDE 内核 [13.466642] ADDRCONF(NETDEV_UP):eth0:链接未准备好
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.125296] 在 /dev/sda6 上添加 1050620k 交换。优先级:-1 范围:1 跨:1050620k
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.226952] EXT4-fs (sda9):重新安装。选项:(空)
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.335012] snd_hda_intel 0000:00:1b.0:PCI INT A -> GSI 22(级别,低)-> IRQ 22
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.335091] snd_hda_intel 0000:00:1b.0:MSI/MSI-X 的 irq 45
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.335128] snd_hda_intel 0000:00:1b.0:将延迟计时器设置为 64
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.346410] 输入:Ideapad 额外按钮为 /devices/platform/ideapad/input/input6
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.428551] 输入:HDA 英特尔耳机作为 /devices/pci0000:00/0000:00:1b.0/sound/card0/input7
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.436958] cfg80211:调用 CRDA 更新世界监管域
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.476550] Linux 视频采集接口:v2.00
2012-06-11 23:06:47 Ubuntu-KDE 内核 [14.486385] uvcvideo:找到 UVC 1.00 设备 USB 2.0 相机 (04f2​​:b008)

所以,我的问题是如何完全禁用以太网卡,以便内核不会尝试使用它?

pl1*_*1nk 6

将网卡驱动列入黑名单

  1. 在中创建黑名单文件 /etc/modprobe.d/

请注意,文件中/etc/modprobe.d/必须有.conf后缀。此外,将模块命名为 in/etc/modprobe.d/blacklist.conf不会影响内核自动加载模块,因此您必须制作自己的文件。

黑名单文件示例: blacklist-ethernet.conf

blacklist driver_0     # eth0 by default
Run Code Online (Sandbox Code Playgroud)

注意:这里driver_0是您的 NIC 驱动程序的名称。您可以通过lspci -v在终端中使用 command命令来查找 LAN 卡的内核驱动程序名称。
例如我的输出是:

…………
………… 
6:00.0 以太网控制器:Broadcom Corporation NetLink BCM5906M 快速以太网 PCI Express(修订版 02)
    子系统:Lenovo Device 3861
    标志:总线主控、快速开发、延迟 0、IRQ 46
    b8000000 处的内存(64 位,不可预取)[大小=64K]
    [已禁用] 的扩展 ROM
    能力: 
    正在使用的内核驱动程序:tg3
    内核模块:tg3
…………
…………

在这里,我看到司机是tg3所以你需要写tg3(或你的驱动程序)来代替driver_0.

  1. 通过运行生成 modules.dep 和映射文件: depmod -ae

  2. 重新创建您的 initrd: update-initramfs -u

可以在此处找到大量信息。