Results 1 to 7 of 7

Thread: NAS Wake on lan

  1. #1

    Default NAS Wake on lan

    Hello, I´d like to ask you for advice.

    I have NAS which has shut down scheduled for midnight. And I would like to wake on lan it by local PC when it is turn on.

    I have tried to put command "wol MAC address" to boot.local but it doesnt work.

    Also I dont know how to mount the NAS because from waking it takes time to be ready. So where should I put the command wol and how to secure disk mounting?

    Thank you,

    Martin

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,788

    Default Re: NAS Wake on lan

    Quote Originally Posted by atilius View Post
    Hello, I´d like to ask you for advice.

    I have NAS which has shut down scheduled for midnight. And I would like to wake on lan it by local PC when it is turn on.

    I have tried to put command "wol MAC address" to boot.local but it doesnt work.

    Also I dont know how to mount the NAS because from waking it takes time to be ready. So where should I put the command wol and how to secure disk mounting?

    Thank you,

    Martin
    It depends of course very much on what file systems you are to mount. When this is about file systems needed by your system to function basicaly (like /var or /usr or maybe even /home), I guess that boot.local is to late. When it is about e.g. a file system contaning a database, you only need it before the database is started. You then could combine the WOL, a loop to test on file system availablity and starting the database in a script to be run at boot (from systemd).

    BTW, I do not know if ggoing for boot.local is a good thing to do in a systemd environment. Other may have opions about this (it might work, but at the same time not being a solution for the future tat is already there).
    Henk van Velden

  3. #3

    Default Re: NAS Wake on lan

    Hello, on NAS are multimedia data. I appreciate any advice where and how to do it. Boot.local I used in the past and it is only way I know how to do it.

    Sharing is done via NFS.

    Thank you,

    Martin

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,788

    Default Re: NAS Wake on lan

    OK, I will try to provide soome building blocks in the hope you can build something out of it.

    First we must be sure that your
    Code:
    wol <macaddress>
    does work at all. You only say that you can't get it working from boot.local, but you do not tell that it works on it's own. When you can not wol, that will be the end of the exercise.

    Then we first must be sure we have can predict what happens at boot, I assume you have an entry in /etc/fstab for this mount. I also assume you do not have the noauto parameter there. I suggest to add the nofail parameter. The result should be that when the NFS server is available the mount will happen at boot and when it is not available there will be no delay in the boot process.

    Then we need a script to check what the situation is and to do those things that are missing. IMHO there are two things to test here: is the mount done and when not, is the NFS server alive.
    There are several ways you could test if the fsis mounted, my preference is to have a file in the unmounted mountpoint. This can be created e.g.
    Code:
    umount /mnt/media
    touch not-mounted
    mount /mnt/media
    I use /mnt/media as the mount point here. I assume you are able to replace this with your own mount point.

    Then we want to make a bash script. I would put that in /root/bin (the bin directory inside the home directory of root). In this example I will give the script the name nasmount. After the script is created (you can use the editor of your choice as root), you have to do
    Code:
    chmod u+x /root/bin/nasmount
    to make this script executable.

    Code:
    #!/bin/bash
    
    # First we test if the mount is present
    [[ -a /mnt/media/not-mounted ]] && mount /mnt/media
    
    # If still not mounted the NAS maybe asleep
    if [[ -a /mnt//media/not-mounted ]]
    then
            wol <macaddress>
            sleep 2m
            mount /mnt/media
    fi
    This waits 2 minutes for the NAS to boot to full functionality. You can change that of course to your reality.

    Then we can make an entry in the crontab of root. Use
    Code:
    crontab -e
    and add
    Code:
    -*/1 * * * *    /root/bin/nasmount >/dev/null 2>&1
    This will run every minute, but the overhead is almost nil.
    Henk van Velden

  5. #5

    Default Re: NAS Wake on lan

    Henk, thank you a lot for interesting post.

    Just to complete the information.

    wol MAC address works properly when I put in command line as root. What exactly happens in boot.local I dont know, only I can see that NAS is not starting.

    My fstab entry is now this:
    Code:
    192.168.1.101:/i-data/1e2c816d/nfs/DataNFS             /home/martin/DataNAS     nfs    _netdev,nofail,defaults,user,auto,noatime,intr   0 0
    I will check your complete text. It seems to me understanble except cron. This is unknown service to me so I have to firstly read something about. Thank you!

  6. #6
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    16,287

    Default Re: NAS Wake on lan

    Maybe the network is not up at that point???

  7. #7
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,788

    Default Re: NAS Wake on lan

    Quote Originally Posted by atilius View Post
    ... except cron. This is unknown service to me so I have to firstly read something about. Thank you!
    Code:
    man cron
    Code:
    man crontab
    Henk van Velden

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •