Skip to content

Instantly share code, notes, and snippets.

@vintagefuture
Forked from sebastianneubert/README.md
Created August 23, 2024 13:51
Show Gist options
  • Select an option

  • Save vintagefuture/1cd6af198d1ab1df1f4f6b4f4b4219b5 to your computer and use it in GitHub Desktop.

Select an option

Save vintagefuture/1cd6af198d1ab1df1f4f6b4f4b4219b5 to your computer and use it in GitHub Desktop.

Revisions

  1. @sebastianneubert sebastianneubert revised this gist Jan 21, 2024. 1 changed file with 14 additions and 4 deletions.
    18 changes: 14 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -35,17 +35,23 @@ so you have to do it after each reboot (because after your reboot, the configura

    ### Create a script

    1. change to root user

    ```bash
    # 1. be root user
    sudo su root
    ```

    2. create the script

    # 2. create the script
    ```bash
    cat >> /root/wol_fix.sh <<EOF
    #!/bin/bash
    ethtool -s enp3s0 wol g
    EOF
    ```

    # 3. add execution flag to that script
    3. add execution flag to that script
    ```bash
    chmod 755 /root/wol_fix.sh
    ```

    @@ -69,13 +75,17 @@ WantedBy=multi-user.target
    EOF
    ```

    ```
    ```bash
    # Reload the systemd manager configuration.
    systemctl daemon-reload
    ```

    ```bash
    # start the wol_fix.service
    systemctl start wol_fix
    ```

    ```bash
    # Enable to wol_fix service script.
    systemctl enable wol_fix.service
    ```
  2. @sebastianneubert sebastianneubert created this gist Jan 21, 2024.
    83 changes: 83 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,83 @@
    # Enabling WoL on a TrueNAS System

    Source: https://www.truenas.com/community/threads/enable-wol.95856/

    As an Admin user you can use the ethtool with sudo rights to check if WoL is available on your system.
    The usual ethernet NIC name is "enp3s0" so I use everytime this name.

    ## Check if WoL is available

    ```bash
    sudo ethtool enp3s0
    ```

    ```
    Supports Wake-on:
    - d available and inactive
    - g available and active
    ```

    ```bash
    # turn on WoL once
    sudo ethtool -s enp3s0 wol g
    ```

    You can now check with `sudo ethtool enp3s0` if now the supports WoL is turned to g, which means -> active

    To proof, you can shutdown and send a magic package to your MAC address. (Use Android app or wake-on-lan tool from a different OS)

    If this is working, you can be happy for a few minutes. Unfortunatelly, the step above is not permanently persisted,
    so you have to do it after each reboot (because after your reboot, the configuration is gone.

    ## Make it permanently

    - switch to root user and create a script which does the step above

    ### Create a script

    ```bash
    # 1. be root user
    sudo su root

    # 2. create the script
    cat >> /root/wol_fix.sh <<EOF
    #!/bin/bash
    ethtool -s enp3s0 wol g
    EOF

    # 3. add execution flag to that script
    chmod 755 /root/wol_fix.sh
    ```

    Try it! Change the WoL config back to "d" manually. `ethtool -s enp3s0 wol d` and execute your script as root `/root/wol_fix.sh`
    Check if the configuration changed back to "g".

    ### Start a service on boot, which executes the script

    ```bash
    cat >> /etc/systemd/system/wol_fix.service <<EOF
    [Unit]
    Description=Fix WakeOnLAN being reset to disabled on shutdown
    [Service]
    ExecStart=/root/wol_fix.sh
    Type=oneshot
    RemainAfterExit=yes
    [Install]
    WantedBy=multi-user.target
    EOF
    ```

    ```
    # Reload the systemd manager configuration.
    systemctl daemon-reload
    # start the wol_fix.service
    systemctl start wol_fix
    # Enable to wol_fix service script.
    systemctl enable wol_fix.service
    ```

    If everything works as expected, you have now permanently WoL enabled.