Although WOL has been an issue in the past on FreeNAS, on FreeNAS 9.3 it is supported out of the box. To save a little power I wrote a small script to shut down my FreeNAS and wake it up again remotely.
First, make sure your device support Wake On LAN. To do so, log in on your NAS via SSH and run ifconfig. Check the output for “WOL_MAGIC”:
As you can see, the onboard adapter on my HP N40l (bge0) doesn’t support it WOL but luckily I’ve fitted an Intel EXPI9301CTBLK PRO1000 network card (yep, that’s a real name) which does.
If you know the name of your card you can also run
ifconfig network adapter | grep WOL
The output should look somewhat like this if your network adapter supports WOL:
So, you’ve got your hardware straight, now comes the software. For your Mac, you need wakeonlan to generate the magic packet which will be sent to the NAS. To do so, I recommend installing it via brew:
brew install wakeonlan
Then I wrote small shell script so
#!/bin/sh
if
[[ $1 = “on” ]]; then
echo “Waking up Sonoma”
wakeonlan MAC address of the NASelif
[[ $1 = “off” ]]; then
echo Sending Sonoma to sleep
ssh -t username@IP address “sudo shutdown -p now”else
echo “Please specify on or off”
fi
Replace “MAC address of the NAS”, “username” and “IP address” with your local data. Also, Sonoma is the name of my NAS and you can change the echo outputs to whatever you want.
After that, save the file with any name you like to use as a command in /usr/local/bin and make it executable with
chmod +x filename
Now, you can remotely shut down the system by using the command
filename off
and start it again with
filename on
The output looks like this: