SOLVED Automatically turn on and shutdown

Njanja

Dabbler
Joined
Jun 11, 2016
Messages
22
Hi everyone

I have a very simple question. I have 4 servers with TrueNAS. Two of these I want them to start and shut down automatically at specific times.
Can I set these settings somewhere?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Shutdown is simple. Create a cron job that executes /sbin/shutdown -p now at the desired time.

But how do you expect TrueNAS to wake up a system when TrueNAS is not running because the system is switched off?
You have in my experience two alternatives:

1. Wake on LAN

This needs to be supported by the hardware and you need a separate system to send a WoL packet to your TrueNAS. Very dependent on manufacture/mainboard/etc.

2. Clocked power switch

Most systems have an option in the BIOS that defines how the system should react after a power loss. With options "off", "on" and "last state". You could set that to "on" and use a timer to switch off the power, say, half an hour after your clean shutdown via cron job (see above), then restore power at the desired wake up time.


HTH,
Patrick
 

Njanja

Dabbler
Joined
Jun 11, 2016
Messages
22
Shutdown is simple. Create a cron job that executes /sbin/shutdown -p now at the desired time.

But how do you expect TrueNAS to wake up a system when TrueNAS is not running because the system is switched off?
You have in my experience two alternatives:

1. Wake on LAN

This needs to be supported by the hardware and you need a separate system to send a WoL packet to your TrueNAS. Very dependent on manufacture/mainboard/etc.

2. Clocked power switch

Most systems have an option in the BIOS that defines how the system should react after a power loss. With options "off", "on" and "last state". You could set that to "on" and use a timer to switch off the power, say, half an hour after your clean shutdown via cron job (see above), then restore power at the desired wake up time.


HTH,
Patrick

Hello Patrick

1. Wake on LAN don´t work. I have SuperMicro X10DRi-T4+, and this MB don´t support WaL.
2. Clocked power switch, I find "POWER LOSS" and it is "on", but still don´t work.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Then you are out of luck I fear. You need to solve the "powering on" puzzle, which is completely outside the scope of TrueNAS.
 

Evertb1

Guru
Joined
May 31, 2016
Messages
700
Maybe you are not totally out of luck. A couple of weeks ago I stumbled over this webpage. Maybe there is something in there you can use. It was not what I was looking for so I did not really study it.
 

Electr0

Dabbler
Joined
Dec 18, 2020
Messages
47
... Two of these I want them to start and shut down automatically at specific times.
Can I set these settings somewhere?

You can use IPMI!

I have two TrueNAS servers, a "Main" and a "Backup". I have a Cron script on my Main server that sends an IPMI power on command to my Backup server once a week. When the Backup server boots, it does a Snapshot Pull from my Main server and on completion shutsdown.

I'd have to look up the exact commands that I used, but it's pretty simple. You just 'Connect' to the offline sever's static (IPMI) IP address and issue the 'Power On' command. The only caveat is that you need to have two LAN cables connected to the Offline machine - one to the normal LAN port (for data transfer), and one to the Dedicated IPMI (LAN) port - which stays awake even when the machine is powered off, and deals with IPMI commands.

I think the command is:
ipmitool -I lanplus -H <IP-Address> -U <Username> -P <Password> power on
 
Last edited:

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,829
Here is another option:

the power on button for motherboards is nothing more than a pair of contacts that have to be shorted together to start the system. You could use pretty much anything that can replicate a “dry contact” to close said switch - either on a timer, on demand, or whatever.

if a timed approach works for you, I’d consider something as simple as a Arduino that has a relay or opto-isolator and a RTC. Set up the RTC and have the NAS reset pins shorted about 15 min before the NAS is needed. Then script a shutdown when your task is done. The advantage here is that everything can be powered off a simple 5V wall wart or even the internal power supply.

I’m sure there are other iOT devices out there that do the same thing. A RPI may even allow you to create a custom wake-up script that closes the reset pins, etc. - replicating the missing WoL functionality.

I would however always use a opto-isolator or relay to keep the two electrical circuits 100% separate.

another thing to implement is a watchdog in whatever alarm clock you come up with. IOT devices do crash for no good reason on occasion and if this is a remote location, the watchdog gives you an extra layer of protection.
 

Evertb1

Guru
Joined
May 31, 2016
Messages
700
You can use IPMI!
Yes I think IPMI is a way to go for the OP. The source I hinted at above is also using IPMI. In my home network I have a Raspberry Pi running as a VPN server. Just for the experience I will see if I can install IPMI tool on it and let it run a job to run a start script for my lab server.
 

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,829
Ha. I’d never, ever, have my IPMI connected to the general home network.

put it on a VLAN or segregated 100%. Too much funny business can happen with the crummy BMC implementations out there.
 

Electr0

Dabbler
Joined
Dec 18, 2020
Messages
47
Ha. I’d never, ever, have my IPMI connected to the general home network.


Um... why not? Because of a security concern? The only people who should have access to your home network is you.
If other people have access to your home network, you have bigger problems...
 

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,829
Layered security. Exploits have been found in routers, switches, etc.

it’s why my cameras cannot speak to the internet, my guests have a separate WLAN, and why I have a separate source for my Sonos music players, among other features.

yes, the home network *should* be secure but don’t count on it.
 

Electr0

Dabbler
Joined
Dec 18, 2020
Messages
47
Well I guess it just depends on the value you place on security vs. ease-of-use.
 

Evertb1

Guru
Joined
May 31, 2016
Messages
700
Ha. I’d never, ever, have my IPMI connected to the general home network.
I agree. But with my "home network" I mean the whole shabang of managed switches and Vlan's and what not. Networking is not my thing, I am a humble software engineer, but luckely I have a friend who makes a living with designing and implementing bussiness networks. If anything goes belly up I can always blame him for doing a crappy job in advizing and helping me :smile:
 
Last edited:

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,829
Well I guess it just depends on the value you place on security vs. ease-of-use.
I don’t follow this logic. In my use case, I almost never have to use the IPMI interface. I think the last time I “needed” access to it had to do with setting up the fan speeds inside the case.

In a SOHO Setting, the Server is readily accessible, with a screen, keyboard, etc. Most of the time, I don’t even need that because TrueNAS offers a rudimentary shell from inside the GUI.

From my POV, IPMI should at minimum be inside a VLAN if it’s always on. But even better is leaving it disconnected unless there is a constant use case.
 

Electr0

Dabbler
Joined
Dec 18, 2020
Messages
47
I don’t follow this logic.

It's quite simple really. If OP wants a easy solution to his problem, he can setup a Cron Job with a IPMI command to turn his server on, from another of his servers.

Yeah, routers or gateways or whatever may have vulnerabilities, but it's a heck of a lot easier and cheaper than trying to use a Clocked Power Switch or an Adruino or a Raspberry PI or any of the other solutions suggested.

We're also talking about OP's use case here. We don't know what network infrastructure they have or how many computers are connected to their network, or if it's even connected to the internet... Therefore my solution still stands as valid, right?

What you do and whether you have a screen, keyboard, etc connected to your server is useless info here and doesn't help answer OPs question.

But even better is leaving it disconnected unless there is a constant use case.

Like, I don't know... wanting to automatically and remotely turn on a server?
 

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,829
Are those IPMI commands sent in the clear? Or is the session somehow encrypted? If it’s not encrypted, I hope the OP can institute a VLAN to isolate the IPMI traffic to a very small cohort of isolated members.

I looked over the motherboard, it has a constant-on power pin @ 5V so for less than ~$20 you could have a working Arduino solution that does not constantly expose the target IPMI. For a little more, you could retrofit true WoL via a RPi.
 

Njanja

Dabbler
Joined
Jun 11, 2016
Messages
22
You can use IPMI!

I have two TrueNAS servers, a "Main" and a "Backup". I have a Cron script on my Main server that sends an IPMI power on command to my Backup server once a week. When the Backup server boots, it does a Snapshot Pull from my Main server and on completion shutsdown.

I'd have to look up the exact commands that I used, but it's pretty simple. You just 'Connect' to the offline sever's static (IPMI) IP address and issue the 'Power On' command. The only caveat is that you need to have two LAN cables connected to the Offline machine - one to the normal LAN port (for data transfer), and one to the Dedicated IPMI (LAN) port - which stays awake even when the machine is powered off, and deals with IPMI commands.

I think the command is:
ipmitool -I lanplus -H <IP-Address> -U <Username> -P <Password> power on

Hello

That's exactly what i'm looking for. But I have 4 NAS, 2 of them have IPMI and 2 others do not. These two who do not have IPMI, they are running 24/7 and I want one of them to send the command. Tested with this command and nothing happens.

ipmitool —H 10.10.10.20 —v —I lanplus —U user1 —P gah chassis power on

They are located on different subnets. 2 server with IPMI have 10.10.xx.xx and servers without IPMI have 10.20.xx.xx.
 

Njanja

Dabbler
Joined
Jun 11, 2016
Messages
22
Shutdown is simple. Create a cron job that executes /sbin/shutdown -p now at the desired time.

But how do you expect TrueNAS to wake up a system when TrueNAS is not running because the system is switched off?
You have in my experience two alternatives:

1. Wake on LAN

This needs to be supported by the hardware and you need a separate system to send a WoL packet to your TrueNAS. Very dependent on manufacture/mainboard/etc.

2. Clocked power switch

Most systems have an option in the BIOS that defines how the system should react after a power loss. With options "off", "on" and "last state". You could set that to "on" and use a timer to switch off the power, say, half an hour after your clean shutdown via cron job (see above), then restore power at the desired wake up time.


HTH,
Patrick

My network cards have WOL, but I do not find this function in the BIOS
 

Attachments

  • ifconfig.JPG
    ifconfig.JPG
    55.6 KB · Views: 607

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,829
Could it be one of following, ie have you verified that
  • the machines can reach each other across subnets?
  • the IPMI command works as expected when sent by a machine on the local subnet?

    logs might help you understand if commands are received but nothing happens.
 

Njanja

Dabbler
Joined
Jun 11, 2016
Messages
22
Could it be one of following, ie have you verified that
  • the machines can reach each other across subnets?
  • the IPMI command works as expected when sent by a machine on the local subnet?

    logs might help you understand if commands are received but nothing happens.

Hi
Thanks so much

You were right, NAS and IPMI were on different subnets.
Changed that they are on the same network and tested with IPMI command and now works as I want.
 
Top