7

I'm running Ubuntu 16.04 LTS on my Lenovo G50 and everything is going fine except that I can't close the lid of my laptop without needing to reboot afterwards. When I close the lid (or if I run pm-suspend), my laptop screen goes dark for a few seconds, then turns back on.

The problem is that when I try resuming it, my laptop basically turns into a potato... For some reason, the network manager (both wifi and ethernet) doesn't work whatsoever, the terminal becomes extremely slow and I can't run any command using sudo because it will hang there forever.

I've tried changing the logind.conf file, I've tried changing the Power System Settings, I've updated my Intel Graphics driver, I've installed tools like pmi or laptop-mode... I'm running out of ideas but I would do anything to fix this issue.

If there's any system information that could be useful, let me know and I'll add it to the post.

2 Answers 2

11

To change close lid action in Ubuntu :

Open the /etc/systemd/logind.conf file in a text editor as root, for example,

sudo nano /etc/systemd/logind.conf

Change this line :

#HandleLidSwitch=ignore

To this line :

HandleLidSwitch=suspend

Make sure its commented out.

Alternately you can also add this line, but i prefer the first one :

HandleLidSwitchDocked=suspend

Then run :

sudo service systemd-logind restart

Or reboot.

To Troubleshoot the hibernate/suspend mode you should type following command in terminal :

dmesg|less

There is usually an entry what application caused the suspension to fail:

[32467.560058] Freezing of tasks failed after 20.01 seconds (1 tasks refusing to freeze, wq_busy=0):
[32467.560115] plasma-desktop D 0000000000000000 0 2065 1 0x00800004

Fix suspend on laptops

sudo apt-get install uswsusp

Now test suspend with :

sudo s2ram

If it doesn't work use :

sudo s2ram --force

Next edit this file :

sudo nano /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux

Change code to :

#!/bin/sh

/sbin/s2ram --force

Edit : Another fix :

Put a script in ' /etc/pm/sleep.d/ ' , scripts there will be run at suspend and resume. The file name should start with an ordering number, 00-49 for user scripts (for more details, see man pm-suspend).

The script could look like this

#!/bin/sh
(killall -9 mount.nfs; exit 0)

If you're having problems, check /var/log/pm-suspend.log that will log the attempt to suspend and to run your script.

Ubuntu Suspend not working FIX

Step 1: Open up a terminal and create a script file as follows:

sudo nano /etc/pm/sleep.d/20_custom-ehci_hcd

Step 2: Copy the entire script below into the file you just created and save it:

#!/bin/sh
 VERSION=1.1
DEV_LIST=/tmp/usb-dev-list
DRIVERS_DIR=/sys/bus/pci/drivers
DRIVERS="ehci xhci" # ehci_hcd, xhci_hcd
HEX="[[:xdigit:]]"
MAX_BIND_ATTEMPTS=2
BIND_WAIT=0.1
 unbindDev() {
  echo -n > $DEV_LIST 2>/dev/null
   for driver in $DRIVERS; do
    DDIR=$DRIVERS_DIR/${driver}_hcd
    for dev in `ls $DDIR 2>/dev/null | egrep "^$HEX+:$HEX+:$HEX"`; do
      echo -n "$dev" > $DDIR/unbind
      echo "$driver $dev" >> $DEV_LIST
    done
   #for bus in $EHCI_BUSES; do
     echo -n $bus > /sys/bus/pci/drivers/ehci_hcd/unbind
 # done
   done
 }
 bindDev() {
  if [ -s $DEV_LIST ]; then
    while read driver dev; do
      DDIR=$DRIVERS_DIR/${driver}_hcd
      #for bus in $EHCI_BUSES; do
          echo -n $bus > /sys/bus/pci/drivers/ehci_hcd/bind
      #done
      while [ $((MAX_BIND_ATTEMPTS)) -gt 0 ]; do
          echo -n "$dev" > $DDIR/bind
          if [ ! -L "$DDIR/$dev" ]; then
            sleep $BIND_WAIT
          else
            break
          fi
          MAX_BIND_ATTEMPTS=$((MAX_BIND_ATTEMPTS-1))
      done
     done < $DEV_LIST
  fi
  rm $DEV_LIST 2>/dev/null
   chvt 1
  chvt 7
}
 EHCI_BUSES="0000:00:1a.0 0000:00:1d.0"
case "$1" in
    hibernate|suspend)
 unbindDev;;
     resume|thaw)
 bindDev;;
 esac

Step 3: Give the script run permissions by typing:

sudo chmod 755 /etc/pm/sleep.d/20_custom-ehci_hcd
10
  • I've tried every combination of those 2 but it still completely bugs out trying to suspend
    – Girrafish
    Feb 24, 2018 at 19:13
  • What you mean with bugs out ? What happen when you suspend manually ?
    – An0n
    Feb 24, 2018 at 19:17
  • If I try to suspend by any method, the network manager stops working, the terminal becomes extremely slow and I can't run any commands using sudo because it will hang indefinitely. I pretty much have no choice but to hard reboot my laptop (the command reboot makes the laptop hang on the shutdown screen)
    – Girrafish
    Feb 24, 2018 at 19:24
  • Use the trouble shoot method i descibed in my answer to check wich program cause your ubuntu to freeze/bug.
    – An0n
    Feb 24, 2018 at 19:32
  • 1
    No problem, glad its fixed.
    – An0n
    Feb 24, 2018 at 21:29
6

After reading around, I found that the issue was with the Qualcomm Atheros QCA6164 WiFi card used in many Lenovo laptops (G50-80 in my case). Ubuntu doesn't seem to have the proper firmware for this card which makes it act up.

I also found out that turning off the Wifi before closing my laptop would prevent everything from bugging, so I put that and the solution from this post together and created a file in /etc/acpi/ to handle the lid closing event.

Add the following code using sudo nano /etc/acpi/lid.sh:

#!/bin/sh

grep -q closed /proc/acpi/button/lid/LID0/state
if [ $? = 0 ]
then
  nmcli radio wifi off
  pm-suspend
else
  nmcli radio wifi on
fi

Next, add the following lines using sudo nano /etc/acpi/events/lm_lid:

event=button/lid.*
action=/etc/acpi/lid.sh

Now, uncomment and set the following line using sudo nano /etc/systemd/logind.conf:

HandleLidSwitch=ignore

Finally, go into the System Settings > Power and put all closing lid options to Do Nothing.

Run the following to set the permissions and finalize the changes:

sudo chmod 755 /etc/acpi/lid.sh
sudo /etc/init.d/acpid restart
sudo service systemd-logind restart

Hopefully it works for you!

1
  • 1
    After trying everything across the internet to make my laptop sleep after lid close, this is the only solution for me on Ubuntu 18.10
    – Leo
    Jan 23, 2019 at 21:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .