Help Converting Mkinitcpio Hook to Dracut to Fix e1000e Driver Issue

Greetings,

I would like to request some help with regards to converting a mkinitcpio hook to a dracut equivalent. I have been having issues with ethernet not working on my device and after much research it seems to be an issue with coreboot and my ethernet card being woken by a WoL packet causing the driver to fail. Luckily, this can be fixed by resetting the device before the driver is loaded according to this github post which prescribes the usage of the detailed mkinitcpio hook. I have tried to create my own dracut hook following the dracut docs, but it does not seem to do anything.

I would greatly appreciate if someone knowledgeable on the matter could provide me with guidance.

garuda-inxi:

System:
  Kernel: 6.10.0-zen1-2-zen arch: x86_64 bits: 64 compiler: gcc v: 14.1.1
    clocksource: tsc avail: hpet,acpi_pm
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=acc91bbd-51b8-4669-9368-f85ecd75b0a1 rw rootflags=subvol=@
    rd.udev.log_priority=3 vt.global_cursor_default=0
    resume=UUID=5bb1f004-d544-4ddf-bfac-8a1cf21296d8 loglevel=3 ibt=off
  Desktop: KDE Plasma v: 6.1.3 tk: Qt v: N/A info: frameworks v: 6.4.0
    wm: kwin_x11 with: krunner vt: 2 dm: SDDM Distro: Garuda base: Arch Linux
Machine:
  Type: Laptop System: LENOVO product: ThinkPad W541 v: 1.0
    serial: <superuser required> Chassis: type: 9 serial: <superuser required>
  Mobo: LENOVO model: ThinkPad W541 v: 1.0 serial: <superuser required>
    BIOS: coreboot v: 4.20-410-g3e523b495c date: 06/17/2023
CPU:
  Info: model: Intel Core i7-4710MQ bits: 64 type: MT MCP arch: Haswell
    gen: core 4 level: v3 note: check built: 2013-15 process: Intel 22nm
    family: 6 model-id: 0x3C (60) stepping: 3 microcode: 0x28
  Topology: cpus: 1x cores: 4 tpc: 2 threads: 8 smt: enabled cache:
    L1: 256 KiB desc: d-4x32 KiB; i-4x32 KiB L2: 1024 KiB desc: 4x256 KiB
    L3: 6 MiB desc: 1x6 MiB
  Speed (MHz): avg: 3461 high: 3500 min/max: 800/3500 scaling:
    driver: intel_cpufreq governor: performance cores: 1: 3397 2: 3481 3: 3500
    4: 3398 5: 3413 6: 3500 7: 3500 8: 3500 bogomips: 39906
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities: <filter>
Graphics:
  Device-1: Intel 4th Gen Core Processor Integrated Graphics vendor: Lenovo
    driver: i915 v: kernel arch: Gen-7.5 process: Intel 22nm built: 2013 ports:
    active: eDP-1 empty: DP-1, DP-2, HDMI-A-1, HDMI-A-2, VGA-1 bus-ID: 00:02.0
    chip-ID: 8086:0416 class-ID: 0300
  Device-2: Bison Integrated Camera driver: uvcvideo type: USB rev: 2.0
    speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 3-12:4 chip-ID: 5986:026a
    class-ID: 0e02
  Display: x11 server: X.Org v: 21.1.13 with: Xwayland v: 24.1.1
    compositor: kwin_x11 driver: X: loaded: modesetting
    alternate: fbdev,intel,vesa dri: crocus gpu: i915 display-ID: :0
    screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.00x11.22")
    s-diag: 582mm (22.93")
  Monitor-1: eDP-1 model: AU Optronics 0x34ed built: 2012 res: 1920x1080
    hz: 60 dpi: 142 gamma: 1.2 size: 344x193mm (13.54x7.6") diag: 394mm (15.5")
    ratio: 16:9 modes: 1920x1080
  API: EGL v: 1.5 hw: drv: intel crocus platforms: device: 0 drv: crocus
    device: 1 drv: swrast gbm: drv: crocus surfaceless: drv: crocus x11:
    drv: crocus inactive: wayland
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 24.1.4-arch1.2
    glx-v: 1.4 direct-render: yes renderer: Mesa Intel HD Graphics 4600 (HSW
    GT2) device-ID: 8086:0416 memory: 1.46 GiB unified: yes
  API: Vulkan v: 1.3.279 layers: 4 device: 0 type: integrated-gpu name: Intel
    HD Graphics 4600 (HSW GT2) driver: mesa intel v: 24.1.4-arch1.2
    device-ID: 8086:0416 surfaces: xcb,xlib device: 1 type: cpu name: llvmpipe
    (LLVM 18.1.8 256 bits) driver: mesa llvmpipe v: 24.1.4-arch1.2 (LLVM
    18.1.8) device-ID: 10005:0000 surfaces: xcb,xlib
Audio:
  Device-1: Intel Xeon E3-1200 v3/4th Gen Core Processor HD Audio
    vendor: Lenovo driver: snd_hda_intel v: kernel bus-ID: 00:03.0
    chip-ID: 8086:0c0c class-ID: 0403
  Device-2: Intel 8 Series/C220 Series High Definition Audio vendor: Lenovo
    driver: snd_hda_intel v: kernel bus-ID: 00:1b.0 chip-ID: 8086:8c20
    class-ID: 0403
  Device-3: NVIDIA GK107 HDMI Audio vendor: Lenovo driver: snd_hda_intel
    v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16 bus-ID: 01:00.1
    chip-ID: 10de:0e1b class-ID: 0403
  API: ALSA v: k6.10.0-zen1-2-zen status: kernel-api tools: N/A
  Server-1: sndiod v: N/A status: off tools: aucat,midicat,sndioctl
  Server-2: PipeWire v: 1.2.1 status: active with: 1: pipewire-pulse
    status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
    4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Intel Ethernet I217-LM driver: N/A modules: e1000e port: 1040
    bus-ID: 00:19.0 chip-ID: 8086:153a class-ID: 0200
  Device-2: Intel Wireless 7260 driver: iwlwifi v: kernel pcie: gen: 1
    speed: 2.5 GT/s lanes: 1 bus-ID: 03:00.0 chip-ID: 8086:08b2 class-ID: 0280
  IF: wlp3s0 state: up mac: <filter>
  Info: services: NetworkManager, smbd, systemd-timesyncd, wpa_supplicant
Bluetooth:
  Device-1: Intel Bluetooth wireless interface driver: btusb v: 0.8 type: USB
    rev: 2.0 speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 3-11:3 chip-ID: 8087:07dc
    class-ID: e001
  Report: btmgmt ID: hci0 rfk-id: 0 state: up address: <filter> bt-v: 4.0
    lmp-v: 6 status: discoverable: no pairing: no class-ID: 6c010c
Drives:
  Local Storage: total: 931.51 GiB used: 47.44 GiB (5.1%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 870 EVO 1TB
    size: 931.51 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    tech: SSD serial: <filter> fw-rev: 3B6Q scheme: MBR
Partition:
  ID-1: / raw-size: 914.37 GiB size: 914.37 GiB (100.00%)
    used: 47.44 GiB (5.2%) fs: btrfs dev: /dev/sda1 maj-min: 8:1
  ID-2: /home raw-size: 914.37 GiB size: 914.37 GiB (100.00%)
    used: 47.44 GiB (5.2%) fs: btrfs dev: /dev/sda1 maj-min: 8:1
  ID-3: /var/log raw-size: 914.37 GiB size: 914.37 GiB (100.00%)
    used: 47.44 GiB (5.2%) fs: btrfs dev: /dev/sda1 maj-min: 8:1
  ID-4: /var/tmp raw-size: 914.37 GiB size: 914.37 GiB (100.00%)
    used: 47.44 GiB (5.2%) fs: btrfs dev: /dev/sda1 maj-min: 8:1
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default) zswap: no
  ID-1: swap-1 type: zram size: 15.58 GiB used: 0 KiB (0.0%) priority: 100
    comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 8 dev: /dev/zram0
  ID-2: swap-2 type: partition size: 17.14 GiB used: 0 KiB (0.0%)
    priority: -2 dev: /dev/sda2 maj-min: 8:2
Sensors:
  System Temperatures: cpu: 53.0 C mobo: N/A
  Fan Speeds (rpm): N/A
Info:
  Memory: total: 16 GiB available: 15.58 GiB used: 5.5 GiB (35.3%)
  Processes: 272 Power: uptime: 39m states: freeze,standby,mem,disk
    suspend: deep avail: s2idle,shallow wakeups: 0 hibernate: platform
    avail: shutdown, reboot, suspend, test_resume image: 6.2 GiB
    services: org_kde_powerdevil, power-profiles-daemon, upowerd Init: systemd
    v: 256 default: graphical tool: systemctl
  Packages: pm: pacman pkgs: 1958 libs: 444 tools: octopi,paru pm: flatpak
    pkgs: 0 Compilers: clang: 18.1.8 gcc: 14.1.1 Shell: garuda-inxi
    default: Bash v: 5.2.26 running-in: ghostty inxi: 3.3.35
Garuda (2.6.26-1):
  System install date:     2023-12-07
  Last full system update: 2024-07-23
  Is partially upgraded:   No
  Relevant software:       snapper NetworkManager dracut
  Windows dual boot:       <superuser required>
  Failed units:            

It would be good to test if the mkinitcpio hook actually works on your system before converting it to a dracut hook. I’m not sure if you have a practical way to do that, but if the mkinitcpio hook doesn’t work then almost certainly a dracut version of the same thing will also not work.

Anyway, I think you need to create a dracut module for this.

Create a directory in the dracut module directory:

sudo mkdir /usr/lib/dracut/modules.d/99reset-e1000e

Make a script to set up the dracut module and save it in the directory you just created.

sudo micro /usr/lib/dracut/modules.d/99reset-e1000e/module-setup.sh
#!/bin/bash

install() {
    inst_hook cmdline 99 "$moddir/reset-e1000e.sh"
}

The inst_hook cmdline command installs a script early in the initramfs boot process and the 99 will run it after any other cmdline hooks (with lower numbers) run.

Save and exit, then make the script executable.

sudo chmod +x /usr/lib/dracut/modules.d/99reset-e1000e/module-setup.sh

Next, add the script from the GitHub gist you posted. You don’t need the run_hook part, that is for mkinitcpio. You can just add the echo lines.

sudo micro /usr/lib/dracut/modules.d/99reset-e1000e/reset-e1000e.sh
#!/bin/bash

echo "Resetting PCI Ethernet card"
# Hardcoded PCI path, check the right one on your machine
echo 1 > /sys/devices/pci0000\:00/0000\:00\:19.0/reset

In the gist they have escaped the colons with backslashes, I guess you will need to do that also…but obviously change the actual PCI path for whatever the PCI path is on your machine.

Make that script executable too.

sudo chmod +x /usr/lib/dracut/modules.d/99reset-e1000e/reset-e1000e.sh

Regenerate the initramfs:

sudo dracut-rebuild

That’s it, I’m not sure if it will work but I’m curious to hear how it goes.

1 Like

Unfortunately it did not work, the echo statement didn’t even print either, though dracut reports the module as loaded properly. I’ve also tried variations of this running in pre-udev to no avail. If someone is curious to dig deeper, here is the exact dmesg error:

e1000e: Intel(R) PRO/1000 Network Driver
e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
e1000e 0000:00:19.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
e1000e 0000:00:19.0: probe with driver e1000e failed with error -3

You can try running the script later in the boot process, for example like this:

#!/bin/bash

install() {
    inst_hook initqueue/finished 99 "$moddir/reset-e1000e.sh"
}

Unfortunately, like I mentioned we don’t know if this would actually even work–even if we got every detail exactly right–until we test the mkinitcpio hook and confirm that it works. It may not be practical to spend a lot of time on it without that baseline of information.

1 Like

Still no dice, I might try contacting the author of the script to see if mkinitcpio still works for him. Though again, I can’t tell if the script is running at all, given that the print statement isn’t present either. Thank you for your help though. @BluishHumility

Have you thought of executing the script with a startup service?

If it doesn’t execute properly you could try either blacklisting or rmmoding the e1000e driver first. Then modprbe the e1000e driver and execute your echo command.

I think it is fairly likely that this can be executed successfully with a service.

1 Like

Are you sure WOL is disabled in your bios?


I’ve written an example service file that you can test, that may (or may not) work for you.

As your Ethernet connection was down when you ran your garuda-inxi its exact device ID is unknown, (it will resemble enp2s0).

If your adapter ID is different than enp2s0 or you will need to substitute you own adapter’s ID in place of enp2s0 anywhere it appears in the service file.

Make sure Ethtool is installed before enabling the service below.

From the ethtool man page you can disable wol with:

$ sudo ethtool -s eth0 wol d

This can be utilized in a service to disable wol.

Follow the instructions below:

Create the required service file.

sudo touch /etc/systemd/system/nic-config.service

The contents of the service should be written into the file as follows:

#cat /etc/systemd/system/nic-config.service
#systemctl enable nic-config.service
#systemctl start nic-config.service
#systemctl status nic-config.service
#systemctl daemon-reload

[Unit]
Description=NIC Configuration 
After=multi-user.target
Restart=on-failure

[Service]
User=root
Type=oneshot
RemainAfterExit=yes
ExecStartPre=-/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking off'
ExecStart=/usr/bin/sleep .5
ExecStart=-/usr/bin/systemctl stop NetworkManager
ExecStart=/usr/bin/sleep .5
ExecStart=-/usr/bin/ip link set enp2s0 down
ExecStart=/usr/bin/sleep .5
ExecStart=-/usr/bin/modprobe -r e1000e
ExecStart=/usr/bin/sleep1
ExecStart=-/usr/bin/modprobe e1000e
ExecStart=/usr/bin/ethtool -s enp2s0 wol d
ExecStart=/usr/bin/sleep .5
ExecStart=-/usr/bin/ip link set enp2s0 up
ExecStart=/usr/bin/sleep .5
ExecStart=-/usr/bin/systemctl start NetworkManager
ExecStart=/usr/bin/sleep .5
ExecStart=-/usr/bin/sudo -u $USER /bin/bash -lc 'nmcli networking on'

[Install]
WantedBy=multi-user.target

Save your newly created service file, then enable the service:

systemctl enable nic-config.service

Start the service:

systemctl start nic-config.service

Reload running services:

systemctl daemon-reload

Check the new service’s status:

systemctl status nic-config.service

Reboot your system and your new NIC WOL configuration parameters should hopefully be loaded at each start.


I’ve no idea if this will work for you, but it’s worth a try.


1 Like

Thank you for the script! Unfortunately, when trying to enable the service the command hangs. As for whether or not WoL is enabled in the BIOS, I have no way of confirming. I use SeaBIOS v4.20 and looked into nvramtool to see if it was enabled there to no avail. Furthermore, when trying to confirm the correct adapter ID, none of the tools at my disposal show what it should be. See below for a list of outputs:

systemctl status nic-config.service:

○ nic-config.service - NIC Configuration
     Loaded: loaded (/etc/systemd/system/nic-config.service; enabled; preset: disabled)
     Active: inactive (dead)

Jul 25 22:21:10 Garuda-W541 systemd[1]: /etc/systemd/system/nic-config.service:10: Unknown ke
y 'Restart' in section [Unit], ignoring.

sudo hwinfo | grep "0000:00:19.0":

    0000-0000 : 0000:00:19.0
  pci device: name = 0000:00:19.0
    path = /devices/pci0000:00/0000:00:19.0
i/o:0 0x0000 - 0x0000 (0x01) "0000:00:19.0"
  P: /devices/pci0000:00/0000:00:19.0
  M: 0000:00:19.0
  E: DEVPATH=/devices/pci0000:00/0000:00:19.0
  E: PCI_SLOT_NAME=0000:00:19.0
  E: ID_PATH=pci-0000:00:19.0
/devices/pci0000:00/0000:00:19.0
  SysFS ID: /devices/pci0000:00/0000:00:19.0
  SysFS BusID: 0000:00:19.0

sudo lspci -nnvmm | egrep -A 6 -B 1 -i 'network|ethernet':

Slot:   00:19.0
Class:  Ethernet controller [0200]
Vendor: Intel Corporation [8086]
Device: Ethernet Connection I217-LM [153a]
SVendor:        Intel Corporation [8086]
SDevice:        Device [0000]
Rev:    05
ProgIf: 00

sudo lshw -class network:

  *-network UNCLAIMED
       description: Ethernet controller
       product: Ethernet Connection I217-LM
       vendor: Intel Corporation
       physical id: 19
       bus info: pci@0000:00:19.0
       version: 05
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi cap_list
       configuration: latency=0
       resources: memory:82800000-8281ffff memory:82840000-82840fff ioport:1040(size=32)

ethtool eth0:

netlink error: no device matches name (offset 24)                                            netlink error: No such device
netlink error: no device matches name (offset 24)
netlink error: No such device
netlink error: Operation not permitted
netlink error: no device matches name (offset 24)
netlink error: No such device
netlink error: no device matches name (offset 24)
netlink error: No such device
netlink error: no device matches name (offset 24)
netlink error: No such device
netlink error: no device matches name (offset 24)
netlink error: No such device
No data available

This has been truncated. I can not read the error message.

Are you dual booting with Windows?

If you are dual booting with Windows always cold boot into Linux.

Be sure to disable all WOL features in the Windows Device Manager advanced options for your Intel Ethernet driver. Also disable any power saving options for your Windows Ethernet driver.

In addition, be sure fastboot is disabled in both Windows and your bios.

You installed Garuda last year according to your garuda-inxi.

When exactly did this problem with your Ethernet begin?

I would recommend removing your laptop battery and unplugging your power supply for 5 minutes. If this changes nothing, I would also recommend resetting your bios to the factory default. You will need to alter some bios settings for Linux comparability after a factory settings restore.

Does your Ethernet work on any Linux live boot disks?

Please test various live boot disks and report the results.

Also please answer all other questions put to you and report the results of all suggestions.

1 Like

This was not truncated, it is all that came out of the command. I am not dual booting windows, and I never noticed the ethernet issue until I tried using a know-working ethernet cable at work. As for the battery, I usually remove it from the device completely so as to conserve battery health and run on AC directly.

I have recommended the script below to users with similar issues with their Intel Ethernet adapters in the past:

#!/bin/bash

#Get the PCI-Address of network card (Caution: This works ONLY with ONE NIC)
PCI=`/usr/bin/lspci | /bin/egrep -i 'network|ethernet' | /usr/bin/cut -d' ' -f1`
PCIPATH=`/usr/bin/find /sys -name *\${PCI} | /bin/egrep -i *pci0000*`

#echo "PCI    =$PCI"
#echo "PCIPATH=$PCIPATH"
#ls -la $PCIPATH

/usr/bin/logger -t "ResetNIC" "Resetting PCI NIC ${PCIPATH}"

#Reset the PCI Device completely (like Power-ON/Off)
echo 1 >${PCIPATH}/reset

For some users that I have recommended the above script to it has helped.

You can find that script recommended more than once on the Arch forum.
Below is a link to one of those threads:

https://bbs.archlinux.org/viewtopic.php?id=191981

If the above script works for you, then you can likely have it automatically executed at boot by using a startup service.

Good luck.

2 Likes

Unfortunately this also did not work. I thank you very much for all your help thus far. I did some deeper investigating and I might be able to fix it by doing some specific configuration in my BIOS.

Thanks again for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.