Cannot wake up from suspend

gnome3suspend

I am using Gnome 3.22.3

$ gnome-shell --version
GNOME Shell 3.22.3

Sometimes I encounter the problem of not able to wake from suspend. All I get is a black screen with mouse. Nothing can bring back the login screen and I ended up has to long press the Power button for a few seconds just before it shuts down and if the timing is precise, I can wake the system and the login screen appears. But most of the time I failed and the system is shutdown (improperly). I tried to reproduce the situation and then I went to dmesg and found the following:

[  120.135635] PM: Syncing filesystems ... done.
[  120.319898] PM: Preparing system for sleep (mem)
[  120.320047] (NULL device *): firmware: direct-loading firmware rtlwifi/rtl8192cfw.bin
[  120.320056] Freezing user space processes ... 
[  140.327451] Freezing of tasks failed after 20.006 seconds (1 tasks refusing to freeze, wq_busy=0):
[  140.327551] single          D    0  1722   1058 0x00000104
[  140.327559] Call Trace:
[  140.327574]  ? __schedule+0x3c8/0x860
[  140.327580]  ? schedule+0x32/0x80
[  140.327587]  ? io_schedule+0x12/0x40
[  140.327595]  ? generic_file_read_iter+0x3ca/0x970
[  140.327602]  ? page_cache_tree_insert+0xf0/0xf0
[  140.327611]  ? new_sync_read+0xe3/0x130
[  140.327618]  ? vfs_read+0x91/0x130
[  140.327624]  ? SyS_read+0x52/0xc0
[  140.327632]  ? do_syscall_64+0x7c/0xf0
[  140.327640]  ? entry_SYSCALL64_slow_path+0x25/0x25
[  140.327668] OOM killer enabled.
[  140.327670] Restarting tasks ... done.
[  140.352997] video LNXVIDEO:00: Restoring backlight state
[  140.353718] video LNXVIDEO:01: Restoring backlight state
[  140.354496] PM: Syncing filesystems ... done.
[  140.502578] PM: Preparing system for sleep (freeze)
[  140.502718] Freezing user space processes ... (elapsed 0.149 seconds) done.
[  140.652680] OOM killer disabled.
[  140.652681] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[  140.653866] PM: Suspending system (freeze)
[  140.653868] Suspending console(s) (use no_console_suspend to debug)
[  140.865006] sd 0:0:0:0:     [sda] Synchronizing SCSI cache
[  140.865151] sd 0:0:0:0:     [sda] Stopping disk
[  141.123985] e1000e: EEE TX LPI TIMER: 00000011
[  141.393832] thinkpad_acpi: EC reports that Thermal Table has changed
[  141.394222] nouveau 0000:01:00.0: DRM: resuming object tree...
[  141.563740] nouveau 0000:01:00.0: DRM: resuming fence...
[  141.563749] nouveau 0000:01:00.0: DRM: resuming display...
[  141.563777] nouveau 0000:01:00.0: DRM: resuming console...
[  141.563796] nouveau 0000:01:00.0: DRM: suspending console...
[  141.563798] nouveau 0000:01:00.0: DRM: suspending display...
[  141.627471] nouveau 0000:01:00.0: DRM: evicting buffers...
[  141.627473] nouveau 0000:01:00.0: DRM: waiting for kernel channels to go idle...
[  141.627504] nouveau 0000:01:00.0: DRM: suspending fence...
[  141.627997] nouveau 0000:01:00.0: DRM: suspending object tree...
[  142.579759] PM: suspend of devices complete after 1925.714 msecs
[  142.599638] PM: late suspend of devices complete after 19.871 msecs
[  142.651460] PM: noirq suspend of devices complete after 51.800 msecs
[  142.651462] PM: suspend-to-idle
[  143.964640] Suspended for 2.566 seconds
[  179.827113] Suspended for 35.999 seconds
[  179.851059] sdhci-pci 0000:0d:00.0: MMC controller base frequency changed to 50Mhz.
[  179.879075] PM: noirq resume of devices complete after 51.777 msecs
[  179.879148] PM: resume from suspend-to-idle
[  179.879747] PM: early resume of devices complete after 0.588 msecs
[  179.880010] nouveau 0000:01:00.0: DRM: resuming object tree...
[  179.880068] rtlwifi: rtlwifi: wireless switch is on
[  179.880237] ACPI: button: The lid device is not compliant to SW_LID.
[  179.890194] sd 0:0:0:0:     [sda] Starting disk
[  179.926925] tpm tpm0: A TPM error (6) occurred attempting to read a pcr value
[  179.926926] tpm tpm0: TPM is disabled/deactivated (0x6)
[  179.944247] nouveau 0000:01:00.0: DRM: resuming fence...
[  179.944259] nouveau 0000:01:00.0: DRM: resuming display...
[  179.944317] nouveau 0000:01:00.0: DRM: resuming console...
[  180.237680] ata4: SATA link down (SStatus 0 SControl 300)
[  180.237719] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[  180.237760] ata5: SATA link down (SStatus 0 SControl 300)
[  180.237810] ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[  180.239082] ata1.00: ACPI cmd ef/02:00:00:00:00:a0 (SET FEATURES) succeeded
[  180.239087] ata1.00: ACPI cmd f5/00:00:00:00:00:a0 (SECURITY FREEZE LOCK) filtered out
[  180.239091] ata1.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[  180.240808] ata2.00: ACPI cmd e3/00:1f:00:00:00:a0 (IDLE) succeeded
[  180.241447] ata2.00: ACPI cmd e3/00:02:00:00:00:a0 (IDLE) succeeded
[  180.241451] ata2.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[  180.242161] ata1.00: ACPI cmd ef/02:00:00:00:00:a0 (SET FEATURES) succeeded
[  180.242165] ata1.00: ACPI cmd f5/00:00:00:00:00:a0 (SECURITY FREEZE LOCK) filtered out
[  180.242169] ata1.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[  180.243432] ata1.00: configured for UDMA/133
[  180.247037] ata2.00: ACPI cmd e3/00:1f:00:00:00:a0 (IDLE) succeeded
[  180.247668] ata2.00: ACPI cmd e3/00:02:00:00:00:a0 (IDLE) succeeded
[  180.247673] ata2.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[  180.249438] ata2.00: configured for UDMA/100
[  180.446937] firewire_core 0000:0d:00.3: rediscovered device fw0
[  180.756489] psmouse serio1: synaptics: queried max coordinates: x     [..5888], y     [..4820]
[  180.947973] PM: resume of devices complete after 1068.203 msecs
[  180.948417] PM: Finishing wakeup.

I noticed in [140.327451] a task is refusing to sleep for 20 seconds. Not exactly sure what this "single" task is and the PID 1722 is no longer available at the time when I can see the log.

I think (not sure) the time when I long press the power button is when the system complaint about "The lid device is not compliant to SW_LID."

This is quite annoying sometimes as I may have unsaved work while it went on suspend and I will lose all the work if I wasn't able to wake the system up. My guess is some process refuses to sleep and during that waiting time when I try to wake the system it can't respond.

Best Answer

I struggled with a similar issue in Debian 9, installed on a Lenovo G40-30 Laptop. I went into Hibernate/Sleep and trying to initiate again the screen didn't show up although everything seemed working.

The solution is actually quite simple. It seems Linux OSs, in particular Debian and Ubuntu need at least a 4+GB swap partition for Hibernate/Sleep to work properly. If you installed with "default" configuration it will create a Swap the same size of your actual RAM (in practice a little less). So if you have a laptop with less or equal to 4 Gb RAM and installed "default" configuration, you are probably trying to solve this issue.

Swap allocation in Linux work in two ways:

1) in the form of a SWAP PARTITION in your hardrive.

2) in the form of a SWAP FILE.

YOU CAN CREATE THE SWAP FILE AS FOLLOWS:

sudo swapon --show 

shows if you have enabled the swap option. If not look up how to do this.

sudo fallocate -l 1G /swapfile

sets the size of the swap you add to 1Gb, change to the value you need.

sudo chmod 600 /swapfile        # sets the file to be owned by root     
sudo mkswap /swapfile           # mkswap tool to allocate swap in the file
sudo swapon /swapfile           # activate the swap 
sudo nano /etc/fstab            # open the file to make changes permanent

Add the line /swapfile swap swap defaults 0 0 to the file /etc/fstab:

sudo swapon --show              # show if its working
sudo free -h                    # show Memory and Swap 

IF YOU WANT TO UNDO CHANGES JUST:

sudo swapoff -v /swapfile

remove the line from /etc/fstab file: /swapfile swap swap defaults 0 0

sudo rm /swapfile         # remove the swap file

SWAP SIZES ACCORDING TO RAM:

I can indicate the following table with some recommended SWAP sizes according to your RAM. Last 3 columns are SWAP spaces:

    RAM       No hibernation    With Hibernation   Maximum

    1GB              1GB                 2GB        2GB
    2GB              1GB                 3GB        4GB
    3GB              2GB                 5GB        6GB
    4GB              2GB                 6GB        8GB
    5GB              2GB                 7GB       10GB
    6GB              2GB                 8GB       12GB
    8GB              3GB                11GB       16GB
   12GB              3GB                15GB       24GB
   16GB              4GB                20GB       32GB
   24GB              5GB                29GB       48GB
   32GB              6GB                38GB       64GB
   64GB              8GB                72GB      128GB
  128GB             11GB               139GB      256GB
  256GB             16GB               272GB      512GB
  512GB             23GB               535GB        1TB
    1TB             32GB              1056GB        2TB
    2TB             46GB              2094GB        4TB
    4TB             64GB              4160GB        8TB
    8TB             91GB              8283GB       16TB

MORE INFORMATION:

you can find thorough information on recommended SWAP sizes according to your RAM in the following link:

https://askubuntu.com/questions/594054/how-much-swap-should-i-take-for-1gb-to-8tb-of-ram-on-14-04-or-higher

Credit is due for the table I added here.

Related Question