ACPI shutdown with locked user session

I try to backup an Ubuntu VirtualBox guest. VirtualBox save state is not a solution, because it's VirtualBox version dependent. So I need to do an ACPI shudown (with VirtualBox acpipowerbutton). The problem is that, the ACPI shutdown for Ubuntu seems to work if no user session exists or user session is not locked.

What I have done so far is writing a (Windows cmd) script to acpi shutdown (acpipowerbutton) VirtualBox the Linux guests (Ubuntu and MINT). Works perfect, but not with locked guest system user sessions.

Again: ACPI for unlocked sessions works already. But not for locked sessions. systemctl status acpid.service tells me 'active (running)'. So I think the ACPI service itself is existing and working but needs to be configured?

Is there a way to change settings within Ubuntu to allow an ACPI shutdown for locked sessions?

Or maybe is there any "force" option in VirtualBox to do an ACPI shutdown for locked Ubuntu guests?

2

1 Answer

You will likely need to install the acpid service to accomplish this goal. Here are the full set of steps to follow:

  1. Open a Terminal (if not already open)

  2. Install the acpid service:

    $ sudo apt install acpid
  3. Configure acpid to run a script called doevents.sh on events:

    $ sudo echo -e 'event=.*\naction=/etc/acpi/doevents.sh %e' > /etc/acpi/events/anything

    Note: The file name can be anything. If you'd rather use something other than doevents.sh, feel free to substitute it.

  4. Create the doevents.sh file:

    $ sudo echo -e '#!/bin/bash\n\ncase "$1" in\nbutton/power)\ncase "$2" in\nPBTN) shutdown -h now ;;\nesac\nesac\n' > /etc/acpi/doevents.sh
    $ sudo chmod +x /etc/acpi/doevents.sh
  5. Restart the acpid service:

    sudo systemctl restart acpid.service 
  6. Simulate a power-button press on the VM. It should gracefully shut down.

Hope this solves your problem 👍🏻

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like