Author Topic: powerbutton clean shutdown  (Read 19196 times)

Offline revs

  • Member
  • **
  • Posts: 20
  • Gigabyte GA-G31M-ES2L
Re: powerbutton clean shutdown
« Reply #90 on: September 21, 2009, 12:06:20 PM »
Bumping an old thread!

Whats the status of this with 4.5b6? I admit i didn't read up about it and have been just pressing the power button on my UnRAID server an leaving it shut down, its seems to go through a shutdown procedure and then turn off (i.e. doesn't just turn off straight away, i see a load of console ext about various services shutting down).

So - should I be pressing the power button to shutdown the server? Should I be shutting down some other way? The machine is headless, so dont really want to hook up a KB and monitor each time I want to shutdown! :)



Offline kricker

  • Sr. Member
  • ****
  • Posts: 444
Re: powerbutton clean shutdown
« Reply #91 on: September 21, 2009, 12:31:25 PM »
With 4.5beta6 I press the power button and it shutdowns cleanly.

Offline pfp

  • Sr. Member
  • ****
  • Posts: 252
Re: powerbutton clean shutdown
« Reply #92 on: April 13, 2010, 09:57:01 AM »
Is the version of the powerdown script installed from unmenu 1.3 supposed to shut down when using the power button?  Mine doesn't.  Is there something I need to do besides install the script (and reinstall on reboot)?  CTRL-ALT-DEL works fine just not the power button.  I press the button and nothing happens on the console.  I hold it down for a few seconds and the machine just turns off without running any script.
Primary: unRAID 4.7 | Norco 4224 | Corsair TX750 V2 | Supermicro C2SEA | celeron 450 | 4gb ram | 2x SUPERMICRO AOC-SASLP-MV8 | sil3132 | 13x Hitachi 7K2000 | 7x (so far) Hitachi 5K3000
Secondary: unRAID 5.0-b7 | Antec 1200 & CP850 | Supermicro C2SEA | celeron 450 | 2gb ram | 2x Adaptec 1430SA | 4 x Scythe SCY-HDSX4 | 12 drives 1.5-2gb
Odd man out: Cooler Master 590 | CORSAIR CX430 | BIOSTAR A760G M2+ | AMD Sempron 140 | 2gb ram |

Offline BRiT

  • Hero Member
  • *****
  • Posts: 2701
    • WTF.com
Re: powerbutton clean shutdown
« Reply #93 on: April 13, 2010, 10:07:16 AM »
When installing the unRAID powerdown script, there may be an option to hook into the kernel settings. I'm not sure if you told it to or not.

On my full Slackware-Current instance, I have it hooked in via:

Code: [Select]
sysctl -w kernel.poweroff_cmd="/sbin/powerdown"

Offline prostuff1

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5544
  • Greenleaf Technology
    • Greenleaf Technology
Re: powerbutton clean shutdown
« Reply #94 on: April 13, 2010, 10:08:43 AM »
Is the version of the powerdown script installed from unmenu 1.3 supposed to shut down when using the power button?  Mine doesn't.  Is there something I need to do besides install the script (and reinstall on reboot)?  CTRL-ALT-DEL works fine just not the power button.  I press the button and nothing happens on the console.  I hold it down for a few seconds and the machine just turns off without running any script.

You might need to look in the BIOS to see if you can set an option for what the power button does when pressed.  I do think you need to add something to the powerdown install sequence to get it to init on the press of the power button.

With all that said, the easiest option is to plug in a keyboard and press CTRL-ALT-DEL.

EDIT: I see I was beaten to the answer.  If/When i get home tonight i will see if i can update the unmenu package so this can be given as an option when installing.
« Last Edit: April 13, 2010, 10:10:26 AM by prostuff1 »
Like us on Facebook | Follow me on Twitter
Looking for a prebuilt server? Greenleaf Technology
Building it yourself? Greenleaf Prototype Builds
Troubleshooting | Wiki

Offline Joe L.

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 17794
Re: powerbutton clean shutdown
« Reply #95 on: April 13, 2010, 11:35:39 AM »
Is the version of the powerdown script installed from unmenu 1.3 supposed to shut down when using the power button?  Mine doesn't.  Is there something I need to do besides install the script (and reinstall on reboot)?  CTRL-ALT-DEL works fine just not the power button.  I press the button and nothing happens on the console.  I hold it down for a few seconds and the machine just turns off without running any script.

You might need to look in the BIOS to see if you can set an option for what the power button does when pressed.  I do think you need to add something to the powerdown install sequence to get it to init on the press of the power button.

With all that said, the easiest option is to plug in a keyboard and press CTRL-ALT-DEL.

EDIT: I see I was beaten to the answer.  If/When i get home tonight i will see if i can update the unmenu package so this can be given as an option when installing.
I may have beaten you to it.   I just edited my unmenu package for the powerdown add-on, and also fixed a different issue I discovered in /etc/acpi/acpi_handler.sh  It was set to use the lime-tech supplied /usr/local/sbin/powerdown.   It is now edited to use /sbin/powerdown when WeeboTech's  powerdown command is installed via unMENU

You can check to see what the current ctl-alt-del handler is set to, by typing:
sysctl  kernel.poweroff_cmd

If it is set to /sbin/powerdown, then it is already set correctly.  On my server, it was set to /sbin/poweroff. 
(Not what we want.  That is a non-clean power off of the server.)

You can set it by the command described in the previous post. 
(the newer unMENU package for powerdown I just uploaded to the SVN at google.code has the sysctl command to change it to point to /sbin/powerdown)

Joe L.

Offline lewcass

  • Full Member
  • ***
  • Posts: 136
Re: powerbutton clean shutdown
« Reply #96 on: April 15, 2010, 01:24:23 PM »
(the newer unMENU package for powerdown I just uploaded to the SVN at google.code has the sysctl command to change it to point to /sbin/powerdown)

I could not get mine to switch to /sbin/powerdown with unmenu_install132 using the -u update option.  I resorted to cleaning out the unmenu and package directories and reinstalled completely using unmenu_install -i -d /boot/unmenu then re-enabling my packages including Clean Powerdown. That finally did the trick.

Offline EdgarWallace

  • Full Member
  • ***
  • Posts: 190
Re: powerbutton clean shutdown
« Reply #97 on: October 27, 2010, 04:54:51 AM »
The last post is quite old - so it seems that this issue is fixed?

Here is where I´m coming from:
  • I can shutdown my server with the alt-ctl-del keystroke
  • I have the powerdown script installed
  • I can click on "powerdown" in unMENU and the server is doing the expected.
  • There is no BIOS option where I can influence what the power button is doing
  • ...if I push the power button nothing happens (unless I press some more seconds and it will stop immediately

This is a 7 pages thread .... is someone willing to provide me with an advise to cut it short?

Thanks a lot.
unRaid 5.0-rc12a / ESXi 5.1
Supermicro X9SCL-F, XEON E3-1240V2
2x Kingston ValueRAM 4GB DDR3, 1333MHz, PC3-10667E, CL9, ECC, 240pin
1x AOC-SAS2LP-MV8 (passthru)
1x Samsung SSD 840, 256 GB as datastore
1x Seagate Barracuda SATA III 3TB (Parity)
3x WDC WD15EARS, 1.5TB
1x WDC WD10EAVS, 1TB
1x Hitachi Deskstar 7K1000, 1TB
2x WDC WD20EARX, 2TB

Offline Joe L.

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 17794
Re: powerbutton clean shutdown
« Reply #98 on: October 27, 2010, 06:35:11 AM »
The last post is quite old - so it seems that this issue is fixed?

Here is where I´m coming from:
  • I can shutdown my server with the alt-ctl-del keystroke
  • I have the powerdown script installed
  • I can click on "powerdown" in unMENU and the server is doing the expected.
  • There is no BIOS option where I can influence what the power button is doing
  • ...if I push the power button nothing happens (unless I press some more seconds and it will stop immediately

This is a 7 pages thread .... is someone willing to provide me with an advise to cut it short?

Thanks a lot.

Is there an option in the BIOS for ACPI?   It must be enabled to capture the momentary press of a power button.

The basic steps to figure out what happens when you momentarily press the power button is here:
http://lime-technology.com/forum/index.php?topic=6078.0

Joe L.

Offline EdgarWallace

  • Full Member
  • ***
  • Posts: 190
Re: powerbutton clean shutdown
« Reply #99 on: October 29, 2010, 12:53:24 AM »
Good morning Joe,

I followed the description and here is the result:
Code: [Select]
root@Tower:~# ps -ef | grep acpid | grep -v grep
root       117     2  0 Oct26 ?        00:00:00 [kacpid]
root      1405     1  0 Oct26 ?        00:00:00 /usr/sbin/acpid

Code: [Select]
root@Tower:~# cat /proc/acpi/event
button/power PWRF 00000080 00000001

Code: [Select]
root@Tower:/etc/acpi# grep power /etc/acpi/acpi_handler.sh
# tmm - power off via webGui
#     power) /sbin/init 0
      power) /usr/local/sbin/powerdown

The last line indicates, that WeeboTech's powerdown package is NOT being used (....which is the only way how I'm able to power down my unRAID server. Any of the running processes e.g. Twonky Media Server do prevent to un-mount the disks and stop the array. I can´t even stop the array via the original menu).

Anyhow I have to change the last line power) /sbin/powerdown to: /sbin/powerdown. Am I correct?

How to do that to avoid that the change is being lost after the next reboot?
unRaid 5.0-rc12a / ESXi 5.1
Supermicro X9SCL-F, XEON E3-1240V2
2x Kingston ValueRAM 4GB DDR3, 1333MHz, PC3-10667E, CL9, ECC, 240pin
1x AOC-SAS2LP-MV8 (passthru)
1x Samsung SSD 840, 256 GB as datastore
1x Seagate Barracuda SATA III 3TB (Parity)
3x WDC WD15EARS, 1.5TB
1x WDC WD10EAVS, 1TB
1x Hitachi Deskstar 7K1000, 1TB
2x WDC WD20EARX, 2TB

Offline Joe L.

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 17794
Re: powerbutton clean shutdown
« Reply #100 on: October 29, 2010, 02:32:21 AM »
Good morning Joe,

I followed the description and here is the result:
Code: [Select]
root@Tower:~# ps -ef | grep acpid | grep -v grep
root       117     2  0 Oct26 ?        00:00:00 [kacpid]
root      1405     1  0 Oct26 ?        00:00:00 /usr/sbin/acpid

Code: [Select]
root@Tower:~# cat /proc/acpi/event
button/power PWRF 00000080 00000001

Code: [Select]
root@Tower:/etc/acpi# grep power /etc/acpi/acpi_handler.sh
# tmm - power off via webGui
#     power) /sbin/init 0
      power) /usr/local/sbin/powerdown

The last line indicates, that WeeboTech's powerdown package is NOT being used (....which is the only way how I'm able to power down my unRAID server. Any of the running processes e.g. Twonky Media Server do prevent to un-mount the disks and stop the array. I can´t even stop the array via the original menu).

Anyhow I have to change the last line power) /sbin/powerdown to: /sbin/powerdown. Am I correct?

How to do that to avoid that the change is being lost after the next reboot?
It looks like you are installing the powerdown package in the "go" script.

If you were installing it through unMENU's package manager it also performs these steps in addition to the installpkg.

You are probably doing this already:
CTRLALTDEL=yes installpkg /boot/packages/powerdown-1.02-noarch-unRAID.tgz

After it you can add these four lines to the end of the "go" script:
[ -f /sbin/powerdown ] && mv /usr/local/sbin/powerdown /usr/local/sbin/unraid_powerdown
[ -f /sbin/powerdown ] && sed -i "sX/usr/local/sbin/powerdownX/sbin/powerdownX" /etc/acpi/acpi_handler.sh
[ ! -f /usr/local/sbin/unraid_powerdown ] && sed -i  "sX/sbin/init 0X/sbin/powerdownX" /etc/acpi/acpi_handler.sh
sysctl -w kernel.poweroff_cmd=/sbin/powerdown


The first renamed the lime-tech supplied "powerdown" command to "unraid_powerdown"
The next two edit the acpi_handler.sh script so it will invoke the newly installed powerdown command.
The third is only needed if you are running an older version of unRAID where lime-tech did not supply its own powerdown command.
The 4th line is so the linux kernel's shutdown will use the new command instead of /sbin/shutdown or /sbin/poweroff

Looks like my prior post made it easy to figure out what will happen when you press the power button on your server.   Easy, isn't it..  Lots happens when you momentarily press the power button...

Joe L.

Offline EdgarWallace

  • Full Member
  • ***
  • Posts: 190
Re: powerbutton clean shutdown
« Reply #101 on: October 29, 2010, 04:43:02 AM »
 :)  :)  :)

That did the job. Thanks a lot Joe.
unRaid 5.0-rc12a / ESXi 5.1
Supermicro X9SCL-F, XEON E3-1240V2
2x Kingston ValueRAM 4GB DDR3, 1333MHz, PC3-10667E, CL9, ECC, 240pin
1x AOC-SAS2LP-MV8 (passthru)
1x Samsung SSD 840, 256 GB as datastore
1x Seagate Barracuda SATA III 3TB (Parity)
3x WDC WD15EARS, 1.5TB
1x WDC WD10EAVS, 1TB
1x Hitachi Deskstar 7K1000, 1TB
2x WDC WD20EARX, 2TB

Offline skank

  • Hero Member
  • *****
  • Posts: 777
Re: powerbutton clean shutdown
« Reply #102 on: June 13, 2011, 12:49:52 PM »
Old topic, but i still got a question concerning this.
I want to make the dune shut down my server correctly.
A person on mpcclub is willing to make a dsf file which can be run from the dune
He only needs to know how i launch this powerdown script.
My knowledge concerning this is not enough.
I just press the case power button, and its triggering somehow the powerdown script.
Can you tell me what i need to tell the guy so he knows how i trigger this powerdown script?

Offline baggies

  • Member
  • **
  • Posts: 67
Re: powerbutton clean shutdown
« Reply #103 on: May 13, 2012, 10:10:06 AM »
Good morning Joe,

I followed the description and here is the result:
Code: [Select]
root@Tower:~# ps -ef | grep acpid | grep -v grep
root       117     2  0 Oct26 ?        00:00:00 [kacpid]
root      1405     1  0 Oct26 ?        00:00:00 /usr/sbin/acpid

Code: [Select]
root@Tower:~# cat /proc/acpi/event
button/power PWRF 00000080 00000001

Code: [Select]
root@Tower:/etc/acpi# grep power /etc/acpi/acpi_handler.sh
# tmm - power off via webGui
#     power) /sbin/init 0
      power) /usr/local/sbin/powerdown

The last line indicates, that WeeboTech's powerdown package is NOT being used (....which is the only way how I'm able to power down my unRAID server. Any of the running processes e.g. Twonky Media Server do prevent to un-mount the disks and stop the array. I can´t even stop the array via the original menu).

Anyhow I have to change the last line power) /sbin/powerdown to: /sbin/powerdown. Am I correct?

How to do that to avoid that the change is being lost after the next reboot?
It looks like you are installing the powerdown package in the "go" script.

If you were installing it through unMENU's package manager it also performs these steps in addition to the installpkg.

You are probably doing this already:
CTRLALTDEL=yes installpkg /boot/packages/powerdown-1.02-noarch-unRAID.tgz

After it you can add these four lines to the end of the "go" script:
[ -f /sbin/powerdown ] && mv /usr/local/sbin/powerdown /usr/local/sbin/unraid_powerdown
[ -f /sbin/powerdown ] && sed -i "sX/usr/local/sbin/powerdownX/sbin/powerdownX" /etc/acpi/acpi_handler.sh
[ ! -f /usr/local/sbin/unraid_powerdown ] && sed -i  "sX/sbin/init 0X/sbin/powerdownX" /etc/acpi/acpi_handler.sh
sysctl -w kernel.poweroff_cmd=/sbin/powerdown


The first renamed the lime-tech supplied "powerdown" command to "unraid_powerdown"
The next two edit the acpi_handler.sh script so it will invoke the newly installed powerdown command.
The third is only needed if you are running an older version of unRAID where lime-tech did not supply its own powerdown command.
The 4th line is so the linux kernel's shutdown will use the new command instead of /sbin/shutdown or /sbin/poweroff

Looks like my prior post made it easy to figure out what will happen when you press the power button on your server.   Easy, isn't it..  Lots happens when you momentarily press the power button...

Joe L.

Thanks for this.

Was having the same problem but added your 4 lines to my go script and the power button now shuts down the server.