Like Windows and almost all other computers, your unRAID server should be properly shut down first before being powered off. The Linux console command poweroff is not sufficient. Open files need to be closed, the unRAID array needs to be properly stopped, the drives unmounted, Samba stopped, etc. If the array is not properly stopped and drives are not unmounted, then on the next boot, unRAID will usually require a parity check.
Here is a power down script which should handle all necessary procedures for proper power off of your unRAID environment. This script handles it by:
- Insuring that only one powerdown process is active
- Stopping Samba
- Syncing the drives (which effectively wakes them all up and flushes buffers)
- Killing any active programs/pids/users on the unRAID drives
- Unmounting all unRAID drives
- Stopping the unRAID array (needed to save the superblock correctly)
- Saving syslog in case you need to review it (currently, the 10 most recent logs are saved; to increase this, add the LOGSAVE=## parameter to the command below)
- Calling the standard system shutdown
The code/program and Slackware install package have been located on Google Code, here.
Latest version of Powerdown package can be downloaded from here.
Installation instructions are here.
Recommended go script line should look something like:
CTRLALTDEL=YES LOGSAVE=30 installpkg /boot/packages/powerdown-1.02-noarch-unRAID.tgz
The command above will install Powerdown v1.02 from the /packages folder of your flash drive, so that you can type /sbin/powerdown at the console or Telnet/PuTTY prompt, and your unRAID server will be shut down and powered off correctly. The CTRLALTDEL=YES parameter will allow you to press the Ctrl-Alt-Del key combination on a keyboard attached to your unRAID server, and cleanly and safely shutdown your server, even if there is no monitor attached!
For a more advanced way to bind to the Ctrl-Alt-Del key sequence, see Binding powerdown script to ctrl-alt-del for headless shutdown.
If your motherboard supports this, you can add the following line to your go script to bind the powerdown command to your unRAID server's power button, so that just pressing the power button will execute the Powerdown script. Some motherboards support this, and some don't. Try it and see.
sysctl -w kernel.poweroff_cmd="/sbin/powerdown"
For a complete discussion of Powerdown and related topics, see the forum thread here.