Powerdown package for unRAID v5 and v6 (DEPRECATED)


dlandon

Recommended Posts

Powerdown is deprecated.  It will not install in unRAID 6.2 because it is not necessary and was not fully tested for 6.2.

 

I know some people still want to use it, but it has become increasingly difficult to chase down the changes in the shutdown scheme LT implements in each version and for me to try to keep up.  LT has improved the shutdown procedure in 6.2.

 

I've suggested a few changes to the built in shutdown.  There is no need for the powerdown script in unRAID 6.2.

 

The webgui is the best way to start/stop the array, and shutdown/reboot the server.

 

The cli commands built into unRAID are:

- 'powerdown' - to shutdown the server.

 

Do not use:

- 'reboot' - to reboot the server. <-- does not process event scripts.

- 'powerdown -r' - to reboot the server. <-- doesn't reboot - shuts down.

- 'shutdown now' - to shutdown the server. <-- does not process event scripts.

- 'Ctrl-Alt_Del' - to shutdown the server. <-- does not process event scripts.

 

The built in powerdown path is /usr/local/sbin/powerdown.

 

A quick press of the power button will also shutdown the server.

==============================================================================

 

Version 2.23 of the powerdown package is now available.  It works on unRAID v5 (32 bit) and v6 (64 bit).  I have not tested 2.23 on v5.  Version 2.23 has been modified to be compatible with v6.2 and is backwards compatible with v5 and v6.1.9.

 

Note:  Using this on V5 may subject you to weaknesses in the way that plugins shut down.  The V5 plugins need to have an unmounting_disks event script so they can be shut down by powerdown.  The plugin authors should provide this mechanism, but may not have always done that.  If unRAID is stopping and shutting down from the webgui, then there should not be any problems.

 

Summary:

There is a powerdown script built into unRAID that properly shuts down the server.  This plugin adds additional functionality when performing a shutdown.

 

The optional powerdown plugin offers a few enhancements to the powering down of the server:

- The built in powerdown script can at times get hung on shutdown waiting for drives to unmount.  The plugin forces a shutdown at the expense of possibly a parity check on the next startup if the shutdown is unclean.

- The optional powerdown plugin forces a shutdown so the server will turn off when a power failure has happened and won't get stuck waiting for disks to unmount.

- The optional powerdown plugin offers some event scripts to be installed to handle special circumstances.

- The optional powerdown plugin saves a history of logs on the flash drive.

 

The powerdown plugin is not required for proper shutdown of the unRAID server.

 

Once the powerdown plugin is installed, all power actions use the plugin:

- Power button power down (Quick press, not held down).

- UPS shutdown.

- Command line actions like reboot and poweroff.

- Ctrl-Alt-Del powerdown.

NOTE: Powerdown was designed to do the best it could to do a clean shutdown.  It can be used to shutdown unRAID in lieu of using the webGui 'Stop' button and re-boot/powerdown procedure.  Powerdown is linked to the Linux "shutdown" procedure and will be executed after Linux and unRAID's shutdown processing.  unRAID executes the script "/etc/rc.d/lrc.local_shutdown" whenever it is shutdown.  Powerdown is added to the end of this script and is run last in the sequence.

 

NOTE: Powerdown does not have anything to do with the webGui stop array process.  If the stop array process is hanging up and drives won't unmount, this is because a plugin is holding up the process.  It is not powerdown.  If you do a telnet session "powerdown", the array will be forced to shut down because any plugins active on array drives are shut down.  This insures the array can be stopped and the system shut down.  Insuring that unRAID can shut down is critical if UPS power is about to be lost.

 

PLUGIN AUTHORS: Powerdown executes the unmounting_disks scripts in the plugin directories to shut down plugins.

 

There is a new feature in this version of powerdown for customization.  The directory /boot/config/plugins/powerdown/rc.unRAID.d/ is created on your flash drive by powerdown for script files to be executed on startup or shutdown.  The files are named Kxx and Sxx where xx is 00-99.  File names not in this format will be ignored.  The 'K' files are kill files executed when the array is stopped.  The 'S' files are startup files executed when the array comes on-line.  The numbers are used so you can control the order of the file processing.

 

Powerdown inserts event scripts to run these 'K' and 'S' scripts.  The really cool thing about the use of these scripts it that when the 'Stop' button is clicked on the webGui, the 'K' scripts are executed and you can add commands to perform shutdowns on VMs.  When the 'Start' button is clicked on the webGui, the 'S' scripts are executed and you can start your VMs.

 

For example if the directory contains:

K00.sh

K01

K02.sh

 

The files are processed by powerdown in alphabetical order:

K00.sh

K01

K02.sh

 

Place your 'K' and 'S' script files in the /boot/config/plugins/powerdown/rc.unRAID.d/ directory and powerdown will manage copying them to /etc/rc.d/rc.unRAID.d/ and execute them at the unRAID start array and stop array events.

 

Powerdown copies the 'K' and 'S' scripts from the flash drive when it is installed.  If you want to modify and test your scripts, you can update them for powerdown by executing the command "/etc/rc.d/rc.unRAID update" and your scripts will be updated to powerdown.

 

Powerdown no longer stops VMware.  The way to handle this is to add a simple script file to the /boot/config/plugins/powerdown/rc.unRAID.d/ directory.  Powerdown will manage the script for you.

 

The file contents should be:

[ -x /etc/rc.d/init.d/vmware  ] && /etc/rc.d/init.d/vmware stop

 

Putting your own scripts in the /boot/config/plugins/powerdown/rc.unRAID.d/ directory for powerdown to handle lets you customize powerdown for your situation.  Those of you needing to shutdown VMs before shutting down can add those also.  The alphabetic file name order is the sequence in which they are processed.  The Kxx files are processed when the unRAID array is stopping or a powerdown is occuring.  This provides a bit more orderly shutdown of the VM.  If the Kxx script is not provided, powerdown will kill the VM and this may not be the cleanest way to shutdown the VM.

 

NOTE: I have tested shutting down with a VM running and everything worked fine.

 

New feature in V2.07:

You can now use a configuration file to control where the historical logs are stored and how many logs you want to keep.  Create a file 'powerdown.conf' with the following contents and place it in the /boot/config/plugins/powerdown directory.  Modify for your own needs.

#
# Powerdown configuration file.
#
# This is the directory where your logs are saved.
#
LOGDIR=/boot/logs/
#
# This is the number of logs to save.
# Set zero to not save logs.
# Set to -1 to save all logs.
#
LOGSAVE="10"

 

Powerdown is linked to the "shutdown" procedure so it is executed whenever unRAID is shutdown normally from the webGui.  Powerdown can be executed from a telnet session.  The commands are:

 

“powerdown” – turns off the system

“powerdown –r” – reboots the system (same as doing a "shutdown -r now") with the exception of powerdown processing the 'K' scripts first.

 

Additional commands that can be useful for testing and debugging are:

 

"powerdown diag" - this puts diagnostic information into the syslog

"powerdown syslog" - this saves a log to the /boot/logs/ directory of your flash drive.

 

If you have the apcupsd plugin installed on your system, it may be installing powerdown 1.02 and should be modified to install 2.10. To install this version of powerdown make the following changes to the apcupsd plugin.  Nothing else needs to be done.  You will either have to install the apcupsd in a telnet session or re-boot your system.

 

<FILE Name="/boot/packages/powerdown-2.10-noarch-unRAID.tgz" Run="CTRLALTDEL=YES upgradepkg --install-new">
<URL>--no-check-certificate https://github.com/dlandon/powerdown/raw/master/powerdown-2.10-noarch-unRAID.tgz</URL>
</FILE>

 

The link to powerdown on GitHub is here: https://github.com/dlandon/powerdown/

 

You can use the following plugins if you don't use apcupsd or Dynamix on V5 and want to use powerdown.  Apcupsd and Dynamix load powerdown as a part of their plugin for V5.

 

For v5:

https://github.com/dlandon/powerdown/raw/master/powerdown.plg

 

Powerdown is not installed as part of the apcupsd plugin on V6.  Powerdown needs to be installed as a separate plugin.

 

For V6:

Paste this line into the 'Install Plugin' line in the 'Plugins' webgui and click on install.  This will install the plugin.  Don't install the plugin manually.  Let the plugin manager handle it.

https://github.com/dlandon/powerdown/raw/master/powerdown-x86_64.plg

 

I've put together a plugin that is called 'open.files' that shows what process has files open, and what files are potentially preventing an array shutdown.

 

The post about the plugin is here: http://lime-technology.com/forum/index.php?topic=42881.0

 

This can help you with troubleshooting what processes are holding files open.

Link to comment
  • Replies 678
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Thanks for this update - especially for including my fix to prevent double powerdown processing.  This issue used to annoy me, but I never received any feedback when I posted about it.  I have been running with that line commented out for more than a year, through several hundred powerdowns, and I can assure you that it doesn't introduce any new problems.

 

Anyway, I will use your new version on my 5.0.5 system, and see how it goes.

Link to comment

Thanks for this update - especially for including my fix to prevent double powerdown processing.  This issue used to annoy me, but I never received any feedback when I posted about it.  I have been running with that line commented out for more than a year, through several hundred powerdowns, and I can assure you that it doesn't introduce any new problems.

 

Anyway, I will use your new version on my 5.0.5 system, and see how it goes.

 

Be sure to let me know if you works for you.

Link to comment

Are there instructions on how to "install" it? I'd like to give it a try; I know it's usually installed through unMENU. I have a test system running V6.0beta3. Thanks!

 

Unzip the download in Windows and copy the powerdown-1.05-noarch-unRAID.tgz file to /flash/packages.

telnet to your server

cd /boot/packages

installpkg powerdown-1.05-noarch-unRAID.tgz CTRLALTDEL=YES upgradepkg --install-new

 

Use the plugin attached on the OP.  Reboot.

 

This will have to be done again on a boot.

Link to comment
Unzip the download in Windows and copy the powerdown-1.05-noarch-unRAID.tgz file to /flash/packages.

 

Err... I don't use Windows! :P

 

... but., to be serious :

 

telnet to your server

cd /boot/packages

installpkg powerdown-1.05-noarch-unRAID.tgz CTRLALTDEL=YES upgradepkg --install-new

 

This will have to be done again on a boot.

 

.. or, if you already have the 'unmenu' distribution of powerdown auto-installing, you can edit the powerdown-1.02-noarch-unRAID.tgz.auto_install script in the packages directory, to install 1.05.

 

Link to comment

Are there instructions on how to "install" it? I'd like to give it a try; I know it's usually installed through unMENU. I have a test system running V6.0beta3. Thanks!

 

Unzip the download in Windows and copy the powerdown-1.05-noarch-unRAID.tgz file to /flash/packages.

telnet to your server

cd /boot/packages

installpkg powerdown-1.05-noarch-unRAID.tgz CTRLALTDEL=YES upgradepkg --install-new

 

This will have to be done again on a boot.

 

I am getting the following when i use the command..

 

Executing install script for powerdown-1.05-noarch-unRAID.tgz.

Package powerdown-1.05-noarch-unRAID.tgz installed.

 

Cannot install CTRLALTDEL=YES:  file not found

Cannot install upgradepkg:  file not found

Cannot install --install-new:  file not found

 

thanks

Link to comment

I've created a simple plugin that will install the powerdown package.  It is attached.  Just put this file in the /boot/config/plugins.

 

Either reboot your system or do the following to install:

telnet to your unRAID

cd /boot/config/plugins

installplg powerdown.plg

 

For those of you wanting to include the new version of powerdown in your plugin change the powerdown download to:

<FILE Name="/boot/packages/powerdown-1.05-noarch-unRAID.tgz" Run="CTRLALTDEL=YES upgradepkg --install-new">
<URL>--no-check-certificate https://github.com/dlandon/powerdown/raw/master/powerdown-1.05-noarch-unRAID.tgz</URL>
</FILE>

 

The download link has changed because Google Code deprecated their download feature and we can no longer add files to the download.  I am hosting the powerdown package on my GitHub repository until WeeboTech and I can sort out the final repository.

powerdown.plg.txt

Link to comment

Silly question.... I installed this... and in Putty I entered "powerdown -r". Isn't this supposed to reboot the server? I did this remotely and it seems like my server is off.

 

Use 'shutdown -r now' to reboot the server.  Powerdown will shutdown the server.

 

Shutdown runs the same script as powerdown but does not turn off the server.

Link to comment

Thank you sir!! I have to remember that one.... for years I have been issuing the "reboot" command... I just read that this is not the right thing to do, as it starts a parity after reboot.

 

Thanks again,

 

H.

 

So if I'm reading this correctly

 

powerdown will stop the array, but not turn off.

shutdown will run the powerdown command than do a normal shutdown?

Link to comment

Are there instructions on how to "install" it? I'd like to give it a try; I know it's usually installed through unMENU. I have a test system running V6.0beta3. Thanks!

 

Unzip the download in Windows and copy the powerdown-1.05-noarch-unRAID.tgz file to /flash/packages.

telnet to your server

cd /boot/packages

installpkg powerdown-1.05-noarch-unRAID.tgz CTRLALTDEL=YES upgradepkg --install-new

 

This will have to be done again on a boot.

Why /boot/packages instead of /boot/extra? Anything in /boot/extra is automatically installed on boot.

Link to comment

Silly question.... I installed this... and in Putty I entered "powerdown -r". Isn't this supposed to reboot the server? I did this remotely and it seems like my server is off.

 

Use 'shutdown -r now' to reboot the server.  Powerdown will shutdown the server.

 

Shutdown runs the same script as powerdown but does not turn off the server.

 

I have powerdown_1.05 installed via the powerdown.plg from thread in "User Customisations" forum. Prior to reading this thread I have issued

powerdown -r

through putty and my server DID restart as expected.

 

I know

powerdown -r

was always an option in the past.

 

Seems to still work for me.

Link to comment

Thank you sir!! I have to remember that one.... for years I have been issuing the "reboot" command... I just read that this is not the right thing to do, as it starts a parity after reboot.

 

Thanks again,

 

H.

 

So if I'm reading this correctly

 

powerdown will stop the array, but not turn off.

shutdown will run the powerdown command than do a normal shutdown?

 

No.  Powerdown turns off the computer after running a power down script. "shutdown -r now" will reboot the computer after running the power down script.  The procedure is in a script in /etc/rc.d called rc.unRAID.

 

The power down script stops the array and does an orderly stop of plugins and forces all process to stop so the computer does not get "hung" trying to shutdown.  It is a requirement for apcupsd that is trying to shut the computer off before turning off the ups.  It's also a part of the Dynamix email plugin that will shut down the array and turn off the power if a hard drive overheats.

 

It's a good way to be sure the array shuts down cleanly.  If the array is not shut down cleanly, unRAID will do a parity check on start up.

 

It can also be used to shut down or reboot your system if the webgui becomes unresponsive.

 

"Powerdown -r" or "Shutdown -r now" will shut down the array and plugins then reboot.

"Powerdown" will shut down the array and plugins then turn off the computer.

Link to comment

Silly question.... I installed this... and in Putty I entered "powerdown -r". Isn't this supposed to reboot the server? I did this remotely and it seems like my server is off.

 

Use 'shutdown -r now' to reboot the server.  Powerdown will shutdown the server.

 

Shutdown runs the same script as powerdown but does not turn off the server.

 

I have powerdown_1.05 installed via the powerdown.plg from thread in "User Customisations" forum. Prior to reading this thread I have issued

powerdown -r

through putty and my server DID restart as expected.

 

I know

powerdown -r

was always an option in the past.

 

Seems to still work for me.

 

I stand corrected.  Yes it does work.

Link to comment

I stand corrected.  Yes it does work.

 

Is it safe to assume that powerdown -r is the safest way to reboot?

 

Thanks for your work BTW!!

 

The best way is always through the webgui, but when the webgui is not available or an unattended shutdown needs to occur such as a loss of power to a ups or a hard drive over temperature powerdown will do the job.  "shutdown -r now" does the same thing and then reboots.  Either of these methods is a lot better that pushing the power button.

 

Powerdown was designed to be sure unRAID shuts down in the cleanest fashion when the system has to go down.  It isn't the preferred way to shut down your system.

 

I cannot take credit for powerdown.  The original work was done by WeeboTech and I am trying to help him out because of his other commitments.  WeeboTech is still involved.  He is checking my work and I appreciate that.  He knows a lot more about Linux that I do.  I just saw a need to get this working for v6 and at the same time I'm implementing some changes he wants in the next version.

 

You'll see some of my inexperience with powerdown show at times.  Just bear with me as I get up to speed.

 

Glad I can help though.

Link to comment

Does this new version shutdown the VM's? When I manually click the webgui stop array it just sits waiting because the VM's are still running. At that point when I manually stop them the array then goes offline.

 

That is done by the unRAID webgui and has nothing to do with powerdown.

Link to comment

So powerdown does not take the array offline? Just forcefully unmounts and shutsdown?

 

It does take the array off-line.  It does the equivalent of you stopping the array and then powering off the system through the webgui.  There are times when unRAID cannot unmount the drives because there is a process running on the array and will wait forever for the process to stop.  Powerdown kills the processes to insure the array can shut down.  It is a bit forceful because it is better to force processes to stop than let the power go off during the shut down process.

 

That is part of what it does to do a clean shutdown.  It takes the array off-line, shuts downs plugins it can, and finally kills any active processes before it shuts down the system.  The idea is powerdown takes the system off-line so it does not hang on a shutdown or do an unclean shutdown.

 

Powerdown is used for plugins that need to shut down the system in the cleanest fashion possible.  It's not meant as an everyday process.  It is used in the apcupsd plugin that monitors a ups and at a pre-set level of battery level left will do a powerdown.  The idea is that you'd want the system to shut down the array as clean as possible and not risk damage from a quick loss of power.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.