New computer hangs on shutdown/reboot, how to troubleshoot?

My system is working perfectly but it freezes during shutdown/reboot/suspend/hibernate: All windows and the menu bar disappear but the desktop wallpaper remains. It doesn't even show the shutdown screen (the one with the animated dots) where I could hit ESC and watch the shutdown console text. The system is brand-new and fully updated using Update Manager.

  1. How can I determine what is causing the freeze?
  2. Is there a log I can investigate?
  3. How can I fix this?

I see no obvious cause of the freeze. The only USB attachment is a mouse/keyboard; I don't have any external storage attached; and I don't have any programs running (the machine freezes even when doing shutdown right from the login screen).

What I've tried so far:

  • Based on other questions (this, this, and this) that suggest some ACPI settings, I've tried sudo shutdown -h now to see whether the shutdown console text display offers any hints, but the system doesn't even get that far - it still freezes while the screen shown the desktop background image, without any toolbars. Only sudo shutdown --force works, but that's not a solution.
  • Editing the grub menu to add acpi=off to the kernel didn't help. I guess there's not much point in trying the other (lesser) ACPI suggestions?
  • Adding noapic to the grub entry had no discernible effect. Adding nolapic instead did something (I had removed the quiet option) - the system managed to continue further with the shutdown, right until the line Checking for running unattended-upgrades: which were the last characters on the screen.
  • I've also checked the system BIOS, especially regarding power options, but didn't see anything out of the ordinary. Switching the BIOS standby setting from S3 to S1 didn't help. The standby setting can't be disabled, and there are no other ACPI-related settings AFAIK.
  • BIOS reset didn't help. Not surprised; hadn't changed anything.
  • I tried going to a virtual console (CtrlAltF1) as suggested by djeikyb and from there did a shutdown -h now and it froze there too, after this console output. I didn't try killing processes one at a time because I'm still too newbie to figure out how to do that.
  • Booting with kernel 2.6.35.22 rather than 2.6.35.25 didn't help.
  • Disabling the Nvidia drivers didn't help.
  • Booting from Live CD (USB stick in fact) didn't help; it freezes the same way.
  • Booting from Live CD, with acpi=off noapic nolapic didn't help either. Neither did just nolapic. So evidently this is not some custom setting in my install, but some sort of basic issue.
  • MemTest competed in 1 hour without errors.

This answer on Ubuntu Forums has the exact solution! (Why didn't I post there in parallel to here on AU? It would have saved a week of calendar time and several hours of computer time!)

The wrong driver is loaded which prevents shutdown. To fix it you need to do this:

Open a terminal and type: sudo modprobe -rf rt2860sta

Followed by: sudo modprobe rt2860sta

Then you need to blacklist the wrong driver:
echo blacklist rt2800pci | sudo tee -a /etc/modprobe.d/blacklist.conf

Once you have rebooted (you will need to do a hard power off for the last time!) you will find you can reboot properly.


For Ubuntu 11.10, you could try the reboot=bios option (or other options):

  1. Access the GRUB configuration file as explained here.

    cd .. && cd .. && sudo -H gedit etc/default/grub
    
  2. Edit the line GRUB_CMDLINE_LINUX="" so it says:

    GRUB_CMDLINE_LINUX="reboot=bios"
    

    and save the file.

  3. Update GRUB to write the configuration:

    sudo update-grub
    
  4. Reboot your computer

    (it may hang on the purple screen, but hopefully for the last time...)


It could be an ACPI problem. You can try to pass the kernel some parameters to disable some of ACPI functions. Note this will result in a loss of features (power management) or performance (lots of polling).

First a little explanation about how to add some kernel parameters, robbed miserably from Htorque:

  1. Start your system and wait for the GRUB menu to show (if you don't see a GRUB menu, press and hold the left Shift key right after starting the system).
  2. Now highlight the kernel you want to use, and press the c key. You should be able to see and edit the commands associated with the highlighted kernel.
  3. Go down to the line starting with linux and add one of the following parameters after a space.
  4. Now press Ctrl + x to boot.

You cant try the following options, one each time, they are ordered from more aggressive, likely to work to less aggressive but less functions disabled:

  • acpi=off , this one should completely disable acpi. It's the most likely to work, but you will lose all your power management.
  • pci=noacpi , this will make the kernel to ignore acpi for pic scanning and irq assignment.
  • acpi=noirq, this will only disable irq assignment through acpi.
  • irqpoll, this will make the kernel poll for all unattended irq interruptions.
  • noapic, this will make the kernel ignore the APIC.

I have fixed this by adding the following line to the file /etc/default/halt:

INIT_HALT = POWEROFF