How to shutdown debian using the power button?

5,603 views
Skip to first unread message

Andrius Kurtinaitis

unread,
Mar 18, 2013, 6:32:10 AM3/18/13
to cubie...@googlegroups.com
Hello,
I am using a headless debian OS on my cubieboard attached to a SATA hdd.
Sometimes I want to detach the hdd and I need to power off the computer.
Currently I need another computer to connect via ssh and issue the
'poweroff' command. It is not very nice.
I would like to only press the button and have it shutdown gracefully.
Is there any chance to hook up the button press to initiate a gracefull
shutdown?
Kind regards
Andrius

Michal Suchanek

unread,
Mar 18, 2013, 9:27:13 AM3/18/13
to cubie...@googlegroups.com
Short button press causes an input event. gnome interprets it and so
could some power/acpi/system daemon or you can write your own script.
You can do cat /dev/input/eventN and watch what happens when you press
a button. You can find which event device belongs to AXP driver by
searching /sys a bit.

HTH

Michal

Patrick Wood

unread,
Mar 18, 2013, 9:56:08 PM3/18/13
to cubie...@googlegroups.com

You need to install acpid. This is the service that responds to power button presses.

Andrius Kurtinaitis

unread,
Mar 19, 2013, 7:13:57 AM3/19/13
to cubie...@googlegroups.com
You need to install acpid.  This is the service that responds to power button presses.

I installed acpid and got this error message:
------------------
Processing triggers for man-db ...
Setting up module-init-tools (9-2) ...
Setting up acpid (1:2.0.16-1) ...
[....] Starting ACPI services...RTNETLINK1 answers: No such file or directory
acpid: error talking to the kernel via netlink
. ok
------------------ 

Is it bad, or should I just ignore it?

I am not at home, so I cannot press the power button and see if it works...

Patrick Wood

unread,
Mar 20, 2013, 12:00:59 AM3/20/13
to cubie...@googlegroups.com
You probably don't have acpi enabled in your kernel.

Andrius Kurtinaitis

unread,
Mar 20, 2013, 6:57:56 AM3/20/13
to cubie...@googlegroups.com
I am using kernel 3.0.57-r2-rm1
How do I enable acpi in it?

Michal Suchanek

unread,
Mar 20, 2013, 7:05:32 AM3/20/13
to cubie...@googlegroups.com
On 20 March 2013 11:57, Andrius Kurtinaitis <and...@kurtinaitis.lt> wrote:
> I am using kernel 3.0.57-r2-rm1
> How do I enable acpi in it?

Of course you don't have acpi. That's x86 only.

The button event is same as what acpi button produces so eg. gnome
recognizes it but acpid uses acpi-specific netlink interface which
does not work. Maybe it can be configured differently or you will need
a different pm daemon.

HTH

Michal

Patrick Wood

unread,
Mar 20, 2013, 10:22:28 PM3/20/13
to cubie...@googlegroups.com
My installation of acpid is working fine on the Cubieboard.  The /etc/init/acpid.conf file starts acpid like this: exec acpid -c /etc/acpi/events -s /var/run/acpid.socket and when it starts, I get the message

acpid: starting up with netlink and the input layer
acpid
: 1 rule loaded
acpid
: waitingfor events: eventlogging is off

When I press the power button, I get the message "acpid exited" followed by a normal shutdown sequence.  I'm using my own kernel built with the standard sun4i_defconfig from the linux-sunxi git repository. 

I also have powermgmt-base installed.

Vladimir Luniov

unread,
May 5, 2013, 5:25:01 PM5/5/13
to cubie...@googlegroups.com
Might be related to your problem.

Try running and press the button.
acpi_listen
If you see button events like "button/power PBTN 00000080 00000000" then it's needed to configure the acpi daemon.

Add an event listener to /etc/acpi/events by creating a file with the following content:
event=button/power
action=/etc/acpi/powerbtn.sh %e
Then create the appropriate script /etc/acpi/powerbtn.sh and implement the desired functionality.

Reply all
Reply to author
Forward
0 new messages