ACPI shutdown does nothing

I have DietPi installed in qemu / kvm, and everything seems to work except ACPI events. I cannot initiate a clean shutdown from the VM host, the only way to do it is to SSH in and issue a shutdown command. I have tried installed qemu guest additions and setting that up as a workaround, but it didn’t help.

Installing and running evtest on DietPi shows “Power Button” as /dev/input/event4". Monitoring this input and issuing a shutdown command from the VM host shows that DietPi is receiving it:

root@DietPi:~# evtest 
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:	AT Translated Set 2 keyboard
/dev/input/event1:	VirtualPS/2 VMware VMMouse
/dev/input/event2:	VirtualPS/2 VMware VMMouse
/dev/input/event3:	QEMU QEMU USB Tablet
/dev/input/event4:	Power Button
/dev/input/event5:	PC Speaker
Select the device event number [0-5]: 4
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x1 version 0x0
Input device name: "Power Button"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 116 (KEY_POWER)
Testing ... (interrupt to exit)
Event: time 1563058630.608071, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1563058630.608071, -------------- SYN_REPORT ------------
Event: time 1563058630.608073, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1563058630.608073, -------------- SYN_REPORT ------------

However it does not initiate a shutdown. Is there a way to fix this so that DietPi properly shuts down when I receives an ACPI shutdown command?

It’s essentially a RPi, which doesn’t even have an on/off switch - and no acpi shutdown. I just use shutdown -h now on my VM.

That doesn’t help though. As it is now, when the host shuts down or restarts, the dietpi VM makes the host wait 2 minutes before it times out force destroys the VM to continue shutting down. That’s the issue I’m ultimately trying to solve.

Is there a way to install ACPI? Or perhaps setup a udev rule to shutdown when the “power button” is pressed? I’m just not sure how to setup the appropriate udev rule to match the button press

I created a vm.service file in my systemd to handle this (improperly) to keep me from waiting. I probably need to look at it a little harder cause it’s “yanking the plug” however I dont have to wait. It’s not a huge deal to me because if it corrupts I usually have a recent backup… That’s what VMs are good at anyway!

Description=Dietpi VM service virtualbox.service

ExecStart=/usr/lib/virtualbox/VBoxHeadless -s DietPi2
ExecStop=/usr/lib/virtualbox/VBoxManage controlvm DietPi2 poweroff


Then you can just enable the service file and it will shut it down when the machine shuts down and boot it when it boots without having to worry about it.

I solved it. Make sure acpid is installed, then create /etc/acpi/events/power_button with the following:

event=button/power PBTN 00000080 00000000

Your event may differ, but you can look it up by running acpi_listen and then sending the ACPI shutdown command.

1 Like

Thanks that’s fantastic! Works for me and better than my solution. FYI I’m going to keep my service file and change it to send a acpi signal to properly shut my VM down on restarts now.


I’n new to dietpi. I have just successfully installed dietpi on my PC (Intel DN2800DT mobo, with Atom N2800 cpu), running Roon Bridge.

Can you explain how to create the /etc/acpi/events/power_button ?

I tried to enter what you have posted after logging in:

event=button/power PBTN 00000080 00000000

but got an error message (PBTN: command not found)

Any help would be much appreciated.

sudo touch /etc/acpi/events/power_button
cat <<EOF > /etc/acpi/events/power_button
event=button/power PBTN 00000080 00000000

Thank you for getting back to me. Tried this command, but unfortunatley I got the following error message:

touch: cannot touch /etc/acpi/events/power_button: No such file or directory

I think you have also to create the paths, if not existing.

I’m sorry I know this is a lame question, but I’m a first time Linux user (and 35+ years PC user):

do you know a command to create this path?

Is there some kind of Norton/Total Commander equivalnet I can download to do this?

mkdir -p /etc/acpi/events/

I did all of this but nothing happened:


After I hit enter, I got the “>” symbol. I have rebooted the system, but the power button still doesn’t work as power off as if nothing happened.

Any ideas?

You missed the last line of the cat command

Thanks! The EOF command brought me back to root@DietPi:~#, but otherwise had no effect on the power button.

I have installed the ACPID package, as I figured it might not have been installed, using this command:

apt -y install acpid


It seems it got installed successfully.

I then re run this command:

sudo t/etc/acpi/events/power_button
cat < /etc/acpi/events/power_button
event=button/power PBTN 00000080 00000000

But again - no effect.

sudo touch /etc/acpi/events/power_button
cat <<EOF > /etc/acpi/events/power_button
event=button/power PBTN 00000080 00000000

This command creates the file /etc/acpi/events/power_button and puts the two lines into it, there is no need to run it multiple times.
ACPID is of course a requirement to get this working, like said here.
Can you show us cat /etc/acpi/events/power_button?!
Maybe a reboot is needed for the changes to take effect, idk.

Instead of manually creating that file, try to remove it and install the related package instead:

apt install acpi-support-base

I did install it using this command:

apt -y install acpid

See screenshot a few posts back.

acpi-support-base is a different package

1 Like