Jump to content
XPEnology Community

Power off from the buttom


sraptor

Recommended Posts

  • 3 months later...

I have the same problem. I want to press the power button on my XPEnology box to shutdown the OS safely.

@sraptor: Btw, I understood your initial question very well.

 

What I found out is, that there is no driver installed as default. If I check "cat /proc/acpi/event" and press the power button no event will be logged. After loading the button.ko kernel module I see an event after pressing the button:

 

DiskStation> cat /proc/acpi/event
button/power PWRF 00000080 00000001

 

The event needs a event handler ... I will check the forum.....

Link to comment
Share on other sites

Here is my solution for this issue: powering off the DiskStation by shortly pressing the power button. I'm using 4.2.3211++ (repack v1.2) natively installed.

If you want to follow these steps, do it as user root!

I have packed all my file to a tar-file, which can be downloaded here: https://www.dropbox.com/s/tzg9n0336zqez79/acpid-files.tar

 

1. Make button.ko loaded automatically

- open /etc/rc for editing

- search for the first occurence of the environment variable KERNEL_MODULES and put 'button' at the end of the string.

 

2. Install a acpid daemon

- For this I have rebuilt the busybox with enabled acpid. Since I'm not sure, if the other busybox features are correctly working with my own built busybox, I'm using it only as acpid.

The acpid in the download package is simply a renamed busybox.

- copy acpid to /bin as user root and check that it's executable. Should look like this:

DiskStation> ll /bin/acpid
-rwxr-xr-x    1 root     root        536592 Oct 27 18:08 /bin/acpid

 

3. Install a acpid start/stop script

- create an startup script /usr/syno/etc/rc.d/S30acpid.sh

#!/bin/sh
#
# This goes in /usr/syno/etc/rc.d and gets run at boot-time.

PATH_ACPID=/bin/acpid

case "$1" in

start)
       if [ -x "$PATH_ACPID" ] ; then
               echo "start acpid"
               $PATH_ACPID
       fi
       ;;

stop)
       echo "stop acpid"
       killall acpid > /dev/null 2>&1
       logger -p daemon.error "$0 stopped acpid"
       ;;

*)
       echo "usage: $0 { start | stop }" >&2
       exit 1
       ;;

esac

- check that it's executable. Should look like this:

DiskStation> ll /usr/syno/etc/rc.d/S30acpid.sh
-rwxr-xr-x    1 root     root           359 Oct 29 20:45 /usr/syno/etc/rc.d/S30acpid.sh

 

4. Add a acpid event config

- Finally add a acpid config file for the power button event /etc/acpi/PWRF/00000080

#!/bin/sh

poweroff

- also here: check it's owned by root and executable:

DiskStation> ll /etc/acpi/PWRF/00000080
-rwxrwxrwx    1 root     root            20 Oct 17 22:28 /etc/acpi/PWRF/00000080

 

Finally reboot your box.

Now you could safely shutdown your box by pressing the power button. For a vSphere based XPenology system it should now be possible that the system will be shutdown when the ESXi is shutting down. But this I haven't tested.

Hope it helps you too! :smile:

Link to comment
Share on other sites

Thank darkest_star for this :grin:

 

Using poweroff command in /etc/acpi/PWRF/00000080 will of course shutdown the machine but if I'm right will not stop/unmount properly services/volumes.

 

I think we should use syno_poweroff_feasible_check and/or syno_poweroff_task commands.

Link to comment
Share on other sites

From my point of view the 'poweroff' command really does a graceful shutdown of the system. :???: If I press the button I see, that my HDD LEDs are flickering and after a while one after another is powered off. The shutdown (from pressing power button until power-off) takes around 20-30 seconds.

Btw, I have a hybrid RAID with 3 disks and after a poweroff with the button I never had a problem with my RAID. There was never a complain caused by a "hard" power off.

 

But I didn't knew the special shutdown commands (syno_poweroff_feasible_check and/or syno_poweroff_task) and would test it with them today evening.

Link to comment
Share on other sites

After some tests and after reading on the internet "syno_poweroff_feasible_check" seems to be a more save way to shutdown the system. As far as I understand it would prevent shutting down, if e.g. backup operations are still running.

So, I would also vote for replacing "poweroff" with "syno_poweroff_feasible_check" in the acpid-configure script /etc/acpi/PWRF/00000080.

 

But nevertheless, I had not observed any problems with the simple "poweroff".

Link to comment
Share on other sites

Will this solution help if the system freezes aswell?

I've had rare ocurrences when I needed to hold down the power button on my Synology to have it reboot. Doesn't feel that safe.

Depends on what you mean with freeze. If only the webservices freezes maybe that the powerbutton shutdown may work.

What do you exactly mean with "freezes'?

Link to comment
Share on other sites

After calling syno_poweroff_feasible_check manually:

ps |grep power

17883 root 2540 S < /sbin/poweroff

17885 root 2540 S < sh -c /usr/syno/bin/syno_poweroff_task -p > /dev/nul

17886 root 8300 S < /usr/syno/bin/syno_poweroff_task -p

17927 root 2544 R grep power

 

 

It should poweroff the DS shortly afterwards;)

Link to comment
Share on other sites

On my n54l nothing happens, poweroff was working fine I double checked the file and permissions all ok. maybe wifi connection, bt or usb ups is causing a problem/telling dsm not to shutdown? I will test more tomorrow time for sleep now, I have been at work since 5am I had to drive for 7.5hrs swap over a server and drive 7.5hrs back to the office.

Link to comment
Share on other sites

Will this solution help if the system freezes aswell?

I've had rare ocurrences when I needed to hold down the power button on my Synology to have it reboot. Doesn't feel that safe.

Depends on what you mean with freeze. If only the webservices freezes maybe that the powerbutton shutdown may work.

What do you exactly mean with "freezes'?

 

Well, I've had my syno box become unresponsive, that I can't access the web gui or transmission even.

I just thought that it was the OS that froze, but now that you mention it, it seems more logical that it's the web serve that might have crashed or something.

 

If the whole OS froze (probably not likely with a unix based OS?) then I guess data would be lost if you were to pull the plug.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×
  • Create New...