If you have a FreeNAS server at home, you might want to switch it on and off to match the other computers in your network. With two scripts and a Raspberry Pi is both automatic Wake-on-LAN and automatic shutdown for FreeNAS possible.
The basic prerequisite is that Wake-on-LAN with FreeNAS works. Also, there should be... Turn off FreeNAS automatically. This is the case when there are no other devices online in the network that can make a data request to FreeNAS. You also need a Rasberry Pithis setup scans the network for active devices and sends the WOL packet to FreeNAS as soon as a computer is found.
Step 1: Turn off FreeNAS automatically & enable Wake-on-LAN
As described in my instructions, FreeNAS must be configured to shut down automatically when no more computers are online. You have to make sure that the Wake-on-LAN support is activated. The steps necessary for both points I have described in other blog posts:
Step 2: Prepare Raspberry Pi
In order for the Raspberry Pi to send the "Magic Packet" which wakes up the FreeNAS server, it is necessary to install the appropriate software. I describe this here using Raspbian, but with other distributions it works accordingly.
~# sudo apt-get install etherwake
Etherwake is used to send the command to wake up to the MAC address of the FreeNAS server. You can try this with the following command, the NAS should then start:
~# etherwake 00:11:22:33:44:55
If the FreeNAS server starts now, this part of the configuration has worked: the Raspberry Pi can start the FreeNAS server via Wake-On-LAN.
Step 3: Automate Wake-on-LAN
This guide assumes that all computers on the network that access the FreeNAS server have a fixed IP address. Otherwise a certain IP range would have to be scanned, the basic idea remains the same: the Raspberry Pi checks every 5 minutes if one of the IP addresses responds to a ping. If there is a response, the Magic Packet is sent to wake up the FreeNAS. So the maximum wait time between starting the client and possible data access is 5 minutes + NAS boot time.
The following script checks if the IP addresses stored in "pinglist.txt" answer:
#!/bin/bash # Program name: wakeup.sh date cat /directory/pinglist.txt | while read output do ping -c 1 "$output" > /dev/null if [ $? -eq 0 ]; then echo "IP $output is up". /usr/sbin/etherwake 00:11:22:33:44:55 else echo "IP $output is down". fi done
The output should look like this if you made the script executable with chmod 777 A device is online, so a wake-up signal is sent to FreeNAS:
Sun Sep 7 16:37:18 CEST 2014 IP 192.168.0.60 is down IP 192.168.0.61 is down IP 192.168.0.68 is up IP 192.168.0.65 is down IP 192.168.0.73 is down
In combination with the automatic shutdown, the automatic start makes even more sense. The NAS is really only active when it is needed, which saves power and the hard drives. With a Raspberry Pi, there are more exciting control options, such as starting the FreeNAS at night to start the Backup to be carried out.
- Up to 400GB to record even more hours of Full HD video
- Transfer speeds of up to 100 MB/sec. Operating Temperature : -25 ºC to 85 ºC (-13 ºF to 185 ºF).Storage Temperature: -40 ºC to 85 ºC
Last updated on 2021-09-19 at 13:05 / Affiliate Links / Images from the Amazon Product Advertising API.