I had an issue with Ubuntu freezing after suspending the system. When I tried to wake up the OS, I’d hear the ventilator restarting, the keyboard lights would turn on, but the screen remained black. No way of getting the system back, besides a hard (or soft) reset.
TLDR: If nothing else works for you, verify you’re using the recommended swap size for Ubuntu and increase it if needed.
I had used been using Ubuntu 20.04 with no issues for almost 2 years. For no apparent reason, my system started freezing after suspend. I tried many proposed fixes (see the next section), but the problem persisted.
Finally, I decided to completely reinstall the system. Since the suspend function had been working fine before, it should work again in a fresh installation.
Reinstalling seemed to solve the problem for some time. However, as I started setting up Ubuntu and installing new applications, the problem arose again. The OS would freeze after suspend.
Common solutions (that didn’t work for me)
Some reported solutions to this problem:
- Modifying your grub configuration.
- Different sources recommend different modifications.
- Updating your Nvida drivers (if applicable).
- Switching your display manager from gdm3 to lightdm.
Solution: Increase SWAP size
I then realized that issue appeared as my disk memory started running low.
For my fresh installation, I allocated more disk space. I also used the default Ubuntu new system configurations, which allocated 2 GB of swap memory.
But this new setup didn’t work very well. Besides the suspend freeze issues that reappeared, my system would crash when I was running too many applications at the same time.
htop revealed that in those situations my swap memory was almost full.
That’s when I decided to increase my swap memory and run across this Ubuntu system recommendation for the swap size:
If hibernation is used, swap size should be equal to size of RAM plus the square root of the RAM size.It’s FOSS
For example, if you have 8 GB of RAM, you should allocate about 11 GB for swap size.
To my great surprise, increasing the swap size not only remediated the system crashes, but also the suspend freezes! Yay!
So, if you’re system does not wake up after suspend, verify your swap size and increase it if necessary. You can follow this guide.