Posts by peguerosdc

    So it has been running for around a week with a daily reboot and I think it's safe to say that it is working!

    Maybe you need to add some pause between the lines/commands.sleep 2

    I added the sleep between every command and apparently that did the trick! Plan B (as someone kindly suggested in another conversation) would have been to chain all the script in a single line with ANDs and (lol) ORs to make it fit in the single-lined input box in the OMV GUI, but luckily there was no need to get that dirty.

    Still I have no idea why if I don't echo 1, 0, 1 (in that order) to pwm0/enable it doesn't work, but I am willing to live with it.

    For the curious: when I echo the first 1, nothing happens. Then when I echo 0, the fan starts spinning like full power. Then when I echo 1, it slows down to what I like to think are my period/duty_cycle settings. I think 0 is supposed to turn it off and 1 to turn it on, but ‍♂️

    Stopped working again.

    Well, sometimes it works and sometimes (most of the times) it doesn't. The fan just doesn't turn on and still having the same error:

    line 3: echo: write error: Device or resource busy

    Also worth mentioning that when I log in as root and try to run the script manually, it gives the same result. But if I run directly line by line in the shell, it works.

    Has anyone had a similar issue?

    Thanks @ryecoaaron ! Indeed I moved the script to an executable folder and that fixed the error message, the only weird thing is that still the PWM pin was not getting activated and I had to change the order of the script a bit and duplicate a few lines to make it work (there's no particular reason. Just trial and error):

    echo "Enabling pwmchip1"
    echo 0 > /sys/class/pwm/pwmchip1/export
    echo 50000 > /sys/class/pwm/pwmchip1/pwm0/period
    echo 45000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
    echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable
    echo 0 > /sys/class/pwm/pwmchip1/pwm0/enable
    echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable
    echo "DONE"
    exit 0

    But it is working now. Thanks!


    I am not sure if I should post this here or in Armbian's forum as I am not sure to whom this is concerned, but I am hoping to find some guidance on how to address my issue :)

    I have a NanoPi M4 + SATA hat which has a RK3399 processor with Armbian+OMV 4 installed and I want to run a script to turn on a fan connected to the PWM pin when the device is rebooted.

    I have written the following script to turn modulate the PWM pin which basically has the same instructions that the official documentation of my device provides:

    Bash: /sharedfolders/sys/activate_fan.hs
    echo "Enabling pwmchip1"
    echo 0 > /sys/class/pwm/pwmchip1/export
    echo 0 > /sys/class/pwm/pwmchip1/pwm0/enable
    echo 50000 > /sys/class/pwm/pwmchip1/pwm0/period
    echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable
    echo 45000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle
    echo "DONE"
    exit 0

    And I am using OMV's "Scheduled Jobs" to tell Cron to run the script at every reboot. These are the settings:

    ENABLED: enabled
    TIME OF EXECUTION: at reboot
    USER: root
    COMMAND: bash /sharedfolders/sys/
    SEND EMAIL: disabled
    COMMENT: Enable fan via de PWM pin

    The thing is that sometimes it works and sometimes it doesn't. I don't see anything weird in the Log's and when I setup the job to forward the output vía email, most of the times I get this which has a weird write error, but sometimes I don't and apparently that is not related to the PWM pin being activated or not (that means, even if I don't see the error message, the pin is not activated):

    Enabling pwmchip1
    /sharedfolders/sys/ line 3: echo: write error: Device or resource busy

    Still, another weird thing happening here is that once the system starts and I log in via SSH as root, if I run the script like:

    bash /sharedfolders/sys/

    Always fails and throws the error message like last time. I have to run it several times to get the PWM pin activated and even when the script works, I still get the error message.

    The only way to activate the PWM pin flawlessly is to log in via SSH as root once the system gets running and run the content of the script manually (that is, line by line). That way I still get the error message, but the PWM pin is activated. From this, I can tell that the lines that apparently don't get execute correctly are these:

    echo 0 > /sys/class/pwm/pwmchip1/pwm0/enable

    echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable

    Has anyone encountered a similar problem? Is this related to how OMV runs the scheduled jobs or should I post this on the Armbian forum?


    I have no files inside .../interfaces.d/. Could you provide what this custom file should look like?

    It's supposed to have no files by default. As the link @geaves bookmarked says "During the networking daemon initiation the /etc/network/interfaces.d/ directory is searched for network interface configurations. Any found network configuration is included as part of the /etc/network/interfaces. " so you are supposed to place in there your custom configuration you want to apply. This is mine I use to define the MAC address:

    Code: /etc/network/interfaces.d/mac_eth0
    # Setup MAC address
    allow-hotplug eth0
    iface eth0 inet dhcp
    hwaddress ether MY_MAC_ADDRESS

    Just replace "MY_MAC_ADDRESS" with the address you want. Also the filename doesn't have to be "mac_eth0". You can name it as you want as long as it is inside /etc/network/interfaces.d/

    EDIT: If you used the solution from the Nano Pi Neo and added a Mac address to the /etc/network/interfaces, then create the static IP in the router with that MAC address that should resolve it? But you would have to remove the static IP from the GUI and/or at least from the two config files.

    So, I removed the static IP from both config files I had edited and from the web GUI and was preparing to set the MAC address with the NanoPi Neo's solution when I found in the OMV docs / Advanced Configuration sitehttps://openmediavault.readthe…html?highlight=interfacesthat editing the interfaces file directly is a bad idea as "The file /etc/network/interfaces will be (re-)generated by openmediavault on demand. Thus custom changes that are done by the user will get lost." and they suggest to add any custom configuration to an executable script located at "usr/share/openmediavault/mkconf/interfaces.d/", so I put the NanoPi Neo's code snippet into that script and followed the instructions on the doc, but it didn't work.
    Apparently, it was just being ignored and the MAC address was still randomly generated, but I found out that just by adding the configuration to the custom file in the /etc/network/interfaces.d/ folder does the trick, so that's how I have it now. The MAC address doesn't change anymore and I can set the static IP directly in my router's table.

    Thanks for your support!

    Still not working. I've just set the interfaces file to:

    # The loopback network interface
    auto lo
    iface lo inet loopback
    iface lo inet6 loopback
    # eth0 network interface
    allow-hotplug eth0
    # Include additional interface stanzas.
    source-directory interfaces.d

    And created the new file with the static IP address:

    Code: /etc/network/interfaces/interfaces.d/eth0
    iface eth0 inet static
    address MY IP ADDRESS
    gateway MY GATEWAY
    netmask THE NETMASK
    iface eth0 inet6 auto
    privext 2
    pre-up echo 1 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
    pre-up echo 1 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
    pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/disable_ipv6

    Rebooted the N4 and got the static IP address that I set (which was already the result I had), but still the IP address is changing whenever the router reboots.

    If I am right your system is using Network Manager, which again is the right way :) for whatever reason I bookmarked this which should help you resolve what you are experiencing.

    Thanks! So I checked on my N4 and apparently the OMV web GUI configures the static IP the same way it is explained in your link, except that I found the /etc/network/interfaces file was edited directly instead of creating a new instance under /etc/network/interfaces.d/, so maybe the Network Manager is not being used (?).

    Anyway, my issue is that despite I can setup the static IP directly in the N4 successfully, the configuration doesn't survive router reboots as the N4 ends up with a different IP address given by the DHCP. That's really the issue I want to overcome (or to find a way to set the MAC address).

    Ok, so my goal here is to set a static IP address to my NAS running on a NanoPi M4 with OMV + Debian Stretch (latest updates installed), but I have encountered two issues:

    The cleanest way to achieve this (IMO) is to set the static IP via the router, which is perfectly possible except for the fact that my M4 changes its mac address every time it is rebooted. I searched in this forum and I found this old post from Jan 2018, but apparently the error was not reproducible so there is not much info there. Then, I searched in Armbian's forum and found 2 similar threads (one from February 2018 regarding a NanoPi Neo and one from May 2017 regarding and Opi Zero) and the suggested solution is to edit the /etc/interfaces file to hardcode the MAC address, but this thread of September-December 2018 says that editing the interfaces file is not a good idea as it may clash with whatever the Network Manager is doing.

    So, the not cleanest way (but still functional) is to set the static IP via the OMV web GUI. I encountered a loooot of issues about how changing the interfaces may break the web GUI's network section (which I think have been described a lot in this forum. See the May 2017 post mentioned above, for example), but still I managed to do it.

    The issue now is that I found that if I reboot my router (there are weeks I have to do it every day) while the M4 is on, when the router gets back and re-assigns IP addresses, apparently it ignores the static IP configuration and the N4 ends up with a completely different IP address, which is not the behavior I want.

    So, as I still prefer to set the static IP directly in the router via de MAC address, my main question is:

    How can I prevent the MAC address from changing on every reboot?

    If that is not possible (for whatever reason, which would be odd), then my question would be:

    How can I prevent the IP address from changing on every router reboot? Is it an issue with the router or with the N4?


    Can you please share more details about which NanoPi M4 version you have (2GB or 4GB RAM) and its performance with whatever you have running on it?

    I am planning to build my own NAS with this very same setup (after reading a lot of threads in this form about DIY NASs with SBC. They have been really useful. Thank you, guys!) and I am just trying to find out if I need the 2GB or the 4GB version.

    My use case is just the NAS as a backup for all my media files, to run Plex to stream only music (not video) and very rarely to run a torrent client. Plex's Media Server Requirements website says that "In general, Plex Media Server doesn’t require large amounts of RAM. 2GB of RAM is typically more than sufficient and some installs (particularly Linux-based installs) can often happily run with even less. Of course, more RAM won’t hurt you and will certainly be helpful if you’re also doing other things on the computer.", but it would be good to read what you guys have experienced so far.