Comment 59 for bug 750437

Revision history for this message
alcachi (alcachi) wrote :

There is a workaround that is working in my case and avoids hanged shutdowns that could damage the filesystems.

I modified /etc/acpi/events/powerbtn so when the power button is pressed it launches a custom script to do the shutdown that basically stops lightdm, kills processes from users, waits 30 seconds and then does the shutdown.

Now to shutdown I just close the session and then I press the power button, using this procedure I have avoided the kernel panics during the last month.

In case this can be useful to others experiencing the same problem here are the contents of both files:

#### Contents of /etc/acpi/events/powerbtn
event=button[ /]power
action=/etc/acpi/powerbtn_custom.sh

#### Contents of /etc/acpi/powerbtn_custom.sh
#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

# Stop lightdm
service lightdm stop
# Stop vmware
service vmware stop

# Kill all user processes that could be left behind by the desktop environment
USERS=`awk -F: '{if ($3>=1000) {print $1} }' /etc/passwd`
for user in $USERS; do
        killall -u $user
done

# Safely unmount /mnt mount points (just in case something goes wrong)
FILESYSTEMS=`mount -t ext3,ext4,xfs,btrfs|awk '{print $3}'|grep "^/mnt"`
for fs in $FILESYSTEMS; do
        umount $fs
done

# Sleep 30 seconds just in case: it seems to help avoiding hangups
sleep 30

# Shutdown
/sbin/shutdown -h now "Power button pressed"