Fedora 17 on an Aspire V5-571 -- Reboot on Shutdown
Update on 2/13/15:
This article was originally posted on 08/12/2012 on my old blog (http://www.pbehnke.com/main/node/11). I've copied and pasted
most of it from the original. However, there's an update at the bottom for Arch users.
Original Post for Fedora
I recently purchased a new Acer Aspire V5-571 laptop. This laptop itself is beautiful. It has a new ivy bridge processor, 6GB RAM, 15.6in display, full number pad, and is super thin without the price tag of an ultrabook. Naturally, the first thing I did when I received it was wipe Windows and install Linux. Wanting to try something new, and a little less painful than an Arch install, I opted for Fedora 17 with KDE. The installation went pretty smooth with no major problems. I didn't realize the bottom of the touchpad had two click buttons, so I spend a little time editing the Xorg conf file to add tap to click and double tap to right click. Other than that, all the hardware seems to work out of the box. There was one major problem I did find when I went to shut down the laptop: when shutting down, the laptop always rebooted. The power light would turn off, and about 3 seconds later, it would start to boot again. For a couple days, I tried a couple solutions I found online for this problem. I tried turning off network boot in the BIOS, loading a watchdog timer module, shutting down with and without the AC adapter plugged in, all with no success. I was about to lose hope, but I discovered that the laptop would always shutdown correctly if any USB device was attached. I remembered one posting I saw on the Arch forums about someone who had a similar problem but with the I2C and SPI buses (https://bbs.archlinux.org/viewtopic.php?id=133108). He found that shutting off power management to those buses allowed him to shutdown correctly. I tried his approach with the USB bus system with the following command:
for i in /sys/bus/usb/devices/*/power/control;
do echo on > $i
done
After running this I could shutdown and it the computer would not turn itself back on. Now all I had to do was run this command at shutdown. This was a little tricky, having never used Fedora or systemd. Simply making an init script in /etc/rc5.d/ did not work. With a little help from the post at http://ask.fedoraproject.org/question/904/start-script-on-boot-fedora-16, I ended up having to create the following bash script in /etc/init.d/haltusbpower
#! /bin/bash
#
# haltusbpower init script
#
# chkconfig: 345 99 20
# description: A script to act as a workaround for the bug in the runtime power management module, which causes my acer aspire v5-571 laptop to restart after shutting down.
#
### BEGIN INIT INFO
# Provides: haltusbpower
# Default-Stop: 0 1 3 5
# Short-Description: Halt USB Powersave mode
# Description: A script to halt usb power control.
### END INIT INFO
# Source function library.
. /etc/init.d/functions
# Bus list for the runtime power management module.
buslist="usb"
# See how we were called.
case "$1" in
start)
echo "USB bug fix active"
#no-op on startup
;;
stop)
echo "Turning off USB Power Control"
for bus in $buslist; do
for i in /sys/bus/$bus/devices/*/power/control; do
echo on > $i
done
done
;;
*)
echo "Usage: /etc/init.d/haltusbpower {start|stop}"
exit 1
;;
esac
exit 0
Then added the script as a service with:
sudo chkconfig --add haltusbpower
After doing all this, everything is working as it should with no issues on shutdown.
Update (2/13/15) for Arch/systemd users:
@jasonnguyen_ on twitter recently tweeted at me with an update for Arch and systemd users. His approach has been documented here. I've copied and pasted his script here:
This is a script to stop power from being transfered to usb ports and turning the laptop back on after shutdown. This is for laptops running systemd.
1. Make an executable script here
/usr/local/bin/haltusbpower.sh
----------
#!/bin/bash
for i in /sys/bus/usb/devices/*/power/control;
do echo on > $i
done
----------
2. Make the script executable with the command "chmod +x /usr/local/bin/haltusbpower.sh
3. Make this script run on shutdown with systemd. Make this file here.
/usr/lib/systemd/system/haltusbpower.service
----------
[Unit]
Description=haltusbpower
Before=shutdown.target
DefaultDependencies=no
[Service]
ExecStart=/usr/local/bin/haltusbpower.sh
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=shutdown.target
----------
4. Enable the systemd service with "systemctl enable haltusbpower.service"