New unMENU package: Powerdown


Recommended Posts

just wondering, what's the difference/advantage of using this compared to the default unraid menu of stopping the array and then hit the powerdown button?

Three main differences.

  • If there are any open files or process that prevent a clean shut-down and un-mounting of file-systems, this script will terminate those processes and cleanly shut down.  If you used the normal management screen, the disks that can be un-mounted will show up as "unformatted" and the array will not stop because the one that is busy cannot be un-mounted.  If all the drives cannot be un-mounted, the array cannot be stopped cleanly.  If it cannot be stopped cleanly and you power down, you will be faced with a full parity check on reboot.  If you accidentally click the "Format" button, you could lose data.
  • You can tie this script to the Ctl-Alt-Delete key sequence so even if you lose browser connectivity you can still cleanly shut down the server from the system console.
  • From the command line you can type "powerdown" and have the server cleanly stop and shut down.

 

An added benefit... If you install and configure scripts to allow a UPS to shut down the server upon extended power loss, it can use the "powerdown" command this package installs to do a clean stop and power-down when its batteries are used up.

 

None of this applies if you are running a stock unRAID and install no additions of your own.  (Of course, since you are asking about this in the unMENU thread, it might be you are considering adding extras)  It does not apply if you have a UPS on your PC, the router, and the unRAID server and can still control it in a power failure to shut it down from the PCs browser. 

No matter what, this package does not prevent you from using the normal management screen, it provides options when you cannot.

 

Joe L.

Link to comment
  • 11 months later...

I have 4.5 Final but powerdown script seems not working for me anymore. I upgraded from 4.4.2 to 4.5 final.

 

My server keeps rebooting instead of shutting it down. It does the same even if I use the normal shutdown or force shutdown on unmenu.

 

I am also using cache_dirs, apcupsd, etc..

 

Can anyone help me? I want powerdown script to work the way it should be specially when APC calls for it.

 

Thanks!

Link to comment

I have 4.5 Final but powerdown script seems not working for me anymore. I upgraded from 4.4.2 to 4.5 final.

 

My server keeps rebooting instead of shutting it down. It does the same even if I use the normal shutdown or force shutdown on unmenu.

 

I am also using cache_dirs, apcupsd, etc..

 

Can anyone help me? I want powerdown script to work the way it should be specially when APC calls for it.

 

Thanks!

 

Any idea guys... I been reading and searching but I cant find the right answer OR maybe I am using wrong key word on my searches.

Should I just go back to 4.4.2?

 

Thanks!

Link to comment

I have 4.5 Final but powerdown script seems not working for me anymore. I upgraded from 4.4.2 to 4.5 final.

 

My server keeps rebooting instead of shutting it down. It does the same even if I use the normal shutdown or force shutdown on unmenu.

 

I am also using cache_dirs, apcupsd, etc..

 

Can anyone help me? I want powerdown script to work the way it should be specially when APC calls for it.

 

Thanks!

Before you go back to the older version, let's try a few things first.

 

Before you do, stop the array using the management console, that way you won't be faced with it trying a full parity calc when you power back up again.

 

Then, at the linux prompt, type:

poweroff

 

Notice I asked you to type poweroff, not powerdown.   Does the server shut down, or does it reboot?   (It should power off)

 

If it powers itself off, then you can power up once more, stop the array once more, then type (using the full path as shown below)

DEBUG=1 /sbin/powerdown/

 

This time, does it power off, or does it reboot?  (again, it should power off)

 

Joe L.

 

Link to comment

Just to be certain 4.5 does work as the older versions, I stopped my array from the management console, then at the command prompt typed:

DEBUG=1 /sbin/powerdown

 

I saw the commands as they were being executed on my screen.  One of the last commands issued was a "shutdown -h now" (or something like that) and my server powered itself down.

 

(I had to walk down to the basement and press the power button on it to get it to start back up again)  4.5 unRAID still can power down a server.

 

Joe L.

Link to comment

Just to be certain 4.5 does work as the older versions, I stopped my array from the management console, then at the command prompt typed:

DEBUG=1 /sbin/powerdown

 

I saw the commands as they were being executed on my screen.  One of the last commands issued was a "shutdown -h now" (or something like that) and my server powered itself down.

 

(I had to walk down to the basement and press the power button on it to get it to start back up again)  4.5 unRAID still can power down a server.

 

Joe L.

 

Thanks Joe L. for doing that.

Apologize fro my late response. I been doing a backup and cannot shutdown my server.

I did the poweroff and again my server restart after shutting down. (it did the same thing DEBUG=1 /sbin/powerdown)

 

I did more investigation on my setup and the only thing I am playing with is S3 but I cannot get it right it's hit or miss on my system. I disable that script BUT I forgot to disable a "wake-up daily @ 6:00 A" on my BIOS setting. After disabling that settings on my BIOS everything is back to normal. Its kind of weird!

 

Now my question is - is that normal? I mean when you have a BIOS setting to have your PC wake-up on a certain time but your pc don't shutdown, then the next time you turn off your pc/server it will just reboot itself?

 

Hmmmm! It's good test for people that has same setup as mine "pc waking-up daily" and you miss to shut your pc/server down for a day.

 

Thanks Joe L.

 

Cheers,

Link to comment

Just to be certain 4.5 does work as the older versions, I stopped my array from the management console, then at the command prompt typed:

DEBUG=1 /sbin/powerdown

 

I saw the commands as they were being executed on my screen.  One of the last commands issued was a "shutdown -h now" (or something like that) and my server powered itself down.

 

(I had to walk down to the basement and press the power button on it to get it to start back up again)  4.5 unRAID still can power down a server.

 

Joe L.

I'm almost willing to bet that if you had made your test between midnight and 6 AM the server would not have powered itself back on again.

 

A clear case of the BIOS not being tested properly.  The motherboard shutting the server down should not have resulted in it starting back up unless the on-board clock is exactly 6:00 AM (or whatever time you set it)   Glad you found the issue.

Thanks Joe L.

 

Cheers,

You are welcome.
Link to comment

"shutdown -h now" (or something like that) and my server powered itself down.

 

(I had to walk down to the basement and press the power button on it to get it to start back up again)  4.5 unRAID still can power down a server.

 

Hi Joe, if your server mainboard do not have provision for IPMI management board you can get a tcp/ip controlled power strip from BayTech for instance off ebay. They are pretty cheap and each power outlet offers remote on/off/reboot via telnet. You can get one for something as low as $30..$50. Cheers!

Link to comment
  • 1 month later...

How does this work in contrast to the 4.5 final which includes powerdown?  I thought that with 4.5 the included powerdown command did cleanly shut the array down - but it doesn't appear to.  It stops SAMBA and that's about it - I guess because there are still files mounted or something.

 

So my question is how do I override "powerdown" in 4.5 to use the unMenu version?

 

Thanks, Matt.

Link to comment


How does this work in contrast to the 4.5 final which includes powerdown?  I thought that with 4.5 the included powerdown command did cleanly shut the array down - but it doesn't appear to.  It stops SAMBA and that's about it - I guess because there are still files mounted or something.
 
So my question is how do I override "powerdown" in 4.5 to use the unMenu version?
 
Thanks, Matt.
To use the version of "powerdown" installed by the unMENU package you must type the full path to the command:
/sbin/powerdown
It is that easy.   as you discovered, if you do not give the full path, you will invoke the system supplied command, as it is first in the command search PATH.
 
Unfortunately, the version of "powerdown" now included in unRAID by lime-tech is not equivalent.  
 
There are HUGE differences between the two commands:
 
The command lime-technology supplies does this:
  • It uses the "wget" command to press the "Powerdown" button on the management interface.  
    Normally, when the array is started, this button is not visible.  
    Normally you need to stop the array before you can see the "Powerdown" button on the web-interface.  
    * At least one user reported that using the powerdown command supplied by unRAID does not first stop the array.  
    If that is true, you will be faced by a lengthy parity check when you next power up the server.  
     
    I have not experimented to learn the newest behavior since that report.  
    If the web-management interface (emhttp) is not available, the unRAID supplied powerdown command will not do anything.  This would be the case if emhttp was killed by the Linux kernel because you ran out of free memory and emhttp was the process that had been idle the longest.
  • Installed as /usr/local/sbin/powerdown

 

The powerdown package installed by unMENU does this::

  • Installed in as /sbin/powerdown
  • It is completely independent of the web-management interface.
  • It will perform many tasks to assist in the clean shutdown of the array prior to powering down.  
     
    It will:
    • Save a diagnostic "dump" to the syslog of system information to aid in analysis of problems.
      This includes logging the contents of:
      • /proc/version
      • /proc/cmdline
      • /proc/meminfo
      • /proc/devices
      • /proc/interrupts
      • /proc/ioports
      • /proc/dma
      • /proc/mounts
      • /proc/diskstats

      • The output of the "hdparm -I -i /dev/???" command for each of the disks in your server
      • The output of the "smartctl -n standby -d ata -a /dev/???" for each of the disks in your server.
      • The output of the "lspci" command
      • The output of the "lsmod" command
      • The output of the "ifconfig eth0" command
      • The output of the "ethtool eth0" and ethtool -S eth0" commands
      • The contents of the config files for the user-shares
      • The contents of the "mdcmd status" command

       

      It will then:

      • log the status of the server and any processes that are currently running accessing the disks.
      • Attempt to stop the vmserver process (if running as an add-on)
      • Stop the samba SMB server
      • Stop the NFS file-system server
      • Send a TERM signal to any process running on the disks to allow them to cleanly stop
      • Send a second TERM signal to any process running on the disks to allow them to cleanly stop (in case the first was missed)
      • Send a KILL signal to any process running on the disks to terminate them
      • Un-mount the disks from the array
      • Issue a "sync" command to flush the disk buffer cache to the physical disks
      • Attempt to cleanly stop the array
      • Save a copy of the system log to the flash drive in case analysis is later needed
      • Finally, it will power down by using the "shutdown -t5 now" command

 

Joe L.

Link to comment

The command lime-technology supplies does this:

  • Installed as /usr/local/sbin/powerdown

The powerdown package installed by unMENU does this::

  • Installed in as /sbin/powerdown

 

I don't know if this has been discussed before, but wouldn't it make sense if the unMENU powerdown installs as /usr/local/sbin/powerdown thus overwriting the stock powerdown?  

 

I mean, if someone installs the powerdown package, isn't that exactly what they would want to accomplish?

 

Link to comment

The lime-technologies version of "powerdown" is a fairly recent addition to unRAID.

 

The version of "powerdown" written by Weebotech has existed for a very long time.  The package he created to install it also pre-dates by a very long time the command added by lime-tech.

 

Yes, I agree,  I would not want to use the lime-tech supplied version if the Weebotech was installed.  Although you did not explicitly ask me to change the unMENU package manager to ensure the correct version is executed, it is a great idea you just gave me.

 

After installing the unMENU package it would be simple enough to re-name the command lime-tech is now installing to an alternate name.  It would then still be available, if you ever wanted to use it, but under its new name.

 

I've added a line to the package manager .conf file for the powerdown command.  The new unMENU package will rename the lime-tech version of powerdown to unraid_powerdown  This will prevent its accidental use when Weebotech's version is installed, but still make it available if you so desired.

 

The line I added is:

PACKAGE_INSTALLATION [ -f /usr/local/sbin/powerdown ] && mv /usr/local/sbin/powerdown /usr/local/sbin/unraid_powerdown

 

An updated powerdown unMENU package manager .conf file is attached.  Just download and replace your existing file.  you'll need to disable auto-install and re-enable auto-install for the package manager to create the new .auto_install file with the added rename of the lime-tech supplied command.

 

Joe L.

 

powerdown_ctlaltdel-unmenu-package.conf

Link to comment

I've added a line to the package manager .conf file for the powerdown command.  The new unMENU package will rename the lime-tech version of powerdown to unraid_powerdown   This will prevent its accidental use when Weebotech's version is installed, but still make it available if you so desired.

You may also want to take care of this soft link:

lrwxrwxrwx 1 root root 25 Nov 15 20:48 /root/powerdown -> /usr/local/sbin/powerdown*

 

Link to comment

I've added a line to the package manager .conf file for the powerdown command.  The new unMENU package will rename the lime-tech version of powerdown to unraid_powerdown   This will prevent its accidental use when Weebotech's version is installed, but still make it available if you so desired.

You may also want to take care of this soft link:

lrwxrwxrwx 1 root root 25 Nov 15 20:48 /root/powerdown -> /usr/local/sbin/powerdown*

 

Good point... I can either rename /root/powerdown to /root/unraid_powerdown and point it to unraid_powerdown in /usr/local/sbin

OR

fix the link to point to weebotech's powerdown

OR

delete the link entirely, since the others are certainly in the search path.

 

Any preference?

 

Joe L.

Link to comment

I've added a line to the package manager .conf file for the powerdown command.  The new unMENU package will rename the lime-tech version of powerdown to unraid_powerdown  This will prevent its accidental use when Weebotech's version is installed, but still make it available if you so desired.

You may also want to take care of this soft link:

lrwxrwxrwx 1 root root 25 Nov 15 20:48 /root/powerdown -> /usr/local/sbin/powerdown*

 

Good point... I can either rename /root/powerdown to /root/unraid_powerdown and point it to unraid_powerdown in /usr/local/sbin

OR

fix the link to point to weebotech's powerdown

OR

delete the link entirely, since the others are certainly in the search path.

 

Any preference?

Either way should do.  Personally, I don't see much point of having such a link there.

Having something like unraid_powerdown may turn out to be confusing for new users.

If it were up to me, the only change I'd make in unMENU would be this:

PACKAGE_INSTALLATION  ln -sf /sbin/powerdown /usr/local/sbin/powerdown

...instead of the line that you added in your previous post.

 

Link to comment

Having something like unraid_powerdown may turn out to be confusing for new users.

That got me thinking...

Wouldn't it make sense to also wrap the new powerdown logic around the halt commands (reboot and poweroff)?

 

And what about the shutdown command? Does it use the halt command, or does it do the thing by itself?

 

Or, instead of worrying about all those commands, wouldn't it be cleaner if we use the /etc/rc.d/rc.local_shutdown to do all the things that the /sbin/powerdown is doing?

 

Link to comment

Or, instead of worrying about all those commands, wouldn't it be cleaner if we use the /etc/rc.d/rc.local_shutdown to do all the things that the /sbin/powerdown is doing?

 

I'm sure I shared this here before, but here's mine:

 

#!/bin/sh
#
# /etc/rc.d/rc.local_shutdown: local system shutdown script.

if [ -x /etc/rc.d/rc.transmission-daemon ]; then
  . /etc/rc.d/rc.transmission-daemon stop
fi

if [ -x /etc/rc.d/rc.sabnzbd ]; then
. /etc/rc.d/rc.sabnzbd stop
fi

if [ -x /etc/rc.d/rc.eggdrop ]; then
. /etc/rc.d/rc.eggdrop stop
fi

# kick off unraid powerdown
[ -x /etc/rc.d/rc.unRAID ] && /etc/rc.d/rc.unRAID stop

 

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.