20.04 keeps freezing randomly

pe flag

For some reason, Ubuntu keeps freezing at random times. Sometimes i will come back from being afk and it will be frozen, other times it with freeze when I am loading an application. Even if the freezes correspond to my resource usage, I still have ample resources to be running vscode, discord, and opera at the same time. Every post I've found either has no solution or a solution that doesn't apply to me. Every time it freezes, I am forced to manually shutdown my computer which will eventually start to degrade my hardware. Additionally, this is my whole computer not just gnome, so trying to access the gnome terminal to reload doesn't work.

pixelatedlagg@pixelatedlagg-desktop:~$ inxi -Fxz
  Kernel: 5.4.0-89-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 
  Desktop: Gnome 3.36.9 Distro: Ubuntu 20.04.3 LTS (Focal Fossa) 
  Type: Desktop Mobo: ASRock model: A320M serial: <filter> 
  UEFI [Legacy]: American Megatrends v: P4.70 date: 08/27/2018 
  Topology: Quad Core model: AMD Ryzen 3 1200 bits: 64 type: MCP arch: Zen 
  rev: 1 L2 cache: 2048 KiB 
  flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm 
  bogomips: 24750 
  Speed: 3175 MHz min/max: 1550/3100 MHz Core speeds (MHz): 1: 3134 2: 1375 
  3: 1375 4: 1375 
  Device-1: NVIDIA GP107 [GeForce GTX 1050 Ti] vendor: ZOTAC driver: nvidia 
  v: 470.63.01 bus ID: 26:00.0 
  Display: x11 server: X.Org 1.20.11 driver: nvidia 
  unloaded: fbdev,modesetting,nouveau,vesa resolution: 1920x1080~60Hz 
  OpenGL: renderer: NVIDIA GeForce GTX 1050 Ti/PCIe/SSE2 
  v: 4.6.0 NVIDIA 470.63.01 direct render: Yes 
  Device-1: NVIDIA GP107GL High Definition Audio vendor: ZOTAC 
  driver: snd_hda_intel v: kernel bus ID: 26:00.1 
  Device-2: AMD Family 17h HD Audio vendor: ASRock driver: snd_hda_intel 
  v: kernel bus ID: 28:00.3 
  Device-3: JMTek LLC. USB PnP Audio Device type: USB 
  driver: hid-generic,snd-usb-audio,usbhid bus ID: 1-9:4 
  Sound Server: ALSA v: k5.4.0-89-generic 
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
  vendor: ASRock driver: r8169 v: kernel port: f000 bus ID: 25:00.0 
  IF: enp37s0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
  Device-2: Ralink MT7610U (Archer T2U 2.4G+5G WLAN Adapter type: USB 
  driver: mt76x0u bus ID: 3-1:2 
  IF: wlx503eaa895721 state: down mac: <filter> 
  Local Storage: total: 931.51 GiB used: 140.31 GiB (15.1%) 
  ID-1: /dev/sda vendor: Western Digital model: WD10EZEX-08WN4A0 
  size: 931.51 GiB 
  ID-1: / size: 915.89 GiB used: 140.31 GiB (15.3%) fs: ext4 dev: /dev/sda1 
  System Temperatures: cpu: 42.6 C mobo: N/A gpu: nvidia temp: 34 C 
  Fan Speeds (RPM): N/A gpu: nvidia fan: 47% 
  Processes: 328 Uptime: 6m Memory: 7.77 GiB used: 2.44 GiB (31.4%) 
  Init: systemd runlevel: 5 Compilers: gcc: 9.3.0 Shell: bash v: 5.0.17 
  inxi: 3.0.38 

Any help is appreciated :)

Edit: In the 20 minutes after posting this question, my computer froze 3 more times. If I don't find a fix soon, I'm f*cked.

Edit: More information

pixelatedlagg@pixelatedlagg-desktop:~$ free -h
              total        used        free      shared  buff/cache   available
Mem:          7.8Gi       2.0Gi       1.3Gi        99Mi       4.5Gi       5.4Gi
Swap:         2.0Gi       1.0Mi       2.0Gi
pixelatedlagg@pixelatedlagg-desktop:~$ swapon -s
Filename                Type        Size    Used    Priority
/swapfile                               file        4194300 0   -2
pixelatedlagg@pixelatedlagg-desktop:~$ sysctl vm.swappiness
vm.swappiness = 60
pixelatedlagg@pixelatedlagg-desktop:~$ ls -al ~/.local/share/gnome-shell/extensions
ls: cannot access '/home/pixelatedlagg/.local/share/gnome-shell/extensions': No such file or directory
pixelatedlagg@pixelatedlagg-desktop:~$ ls -al /usr/share/gnome-shell/extensions
total 72
drwxr-xr-x 18 root root 4096 Sep 28 23:25 .
drwxr-xr-x  7 root root 4096 Sep 28 23:33 ..
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  5 root root 4096 Sep 28 23:04
drwxr-xr-x  2 root root 4096 Sep 28 23:25 desktop-icons@csoriano
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  3 root root 4096 Sep 28 23:04
drwxr-xr-x  3 root root 4096 Sep 28 23:05
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  2 root root 4096 Sep 28 23:06
drwxr-xr-x  2 root root 4096 Sep 28 23:06
       description: BIOS
       vendor: American Megatrends Inc.
       physical id: 0
       version: P4.70
       date: 08/27/2018
       size: 64KiB
       capacity: 16MiB
       capabilities: pci upgrade shadowing cdboot bootselect socketedrom edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int9keyboard int14serial int17printer acpi usb biosbootspecification uefi
       description: System Memory
       physical id: b
       slot: System board or motherboard
       size: 8GiB
          description: DIMM DDR4 Synchronous Unbuffered (Unregistered) 2400 MHz (0.4 ns)
          product: DDR4 2400 2OZ
          vendor: A-DATA Technology
          physical id: 0
          serial: 3ADF0100
          slot: DIMM 0
          size: 8GiB
          width: 64 bits
          clock: 2400MHz (0.4ns)
          description: [empty]
          product: Unknown
          vendor: Unknown
          physical id: 1
          serial: Unknown
          slot: DIMM 0
       description: L1 cache
       physical id: d
       slot: L1 - Cache
       size: 384KiB
       capacity: 384KiB
       clock: 1GHz (1.0ns)
       capabilities: pipeline-burst internal write-back unified
       configuration: level=1
       description: L2 cache
       physical id: e
       slot: L2 - Cache
       size: 2MiB
       capacity: 2MiB
       clock: 1GHz (1.0ns)
       capabilities: pipeline-burst internal write-back unified
       configuration: level=2
       description: L3 cache
       physical id: f
       slot: L3 - Cache
       size: 8MiB
       capacity: 8MiB
       clock: 1GHz (1.0ns)
       capabilities: pipeline-burst internal write-back unified
       configuration: level=3
       description: CPU
       product: AMD Ryzen 3 1200 Quad-Core Processor
       vendor: Advanced Micro Devices [AMD]
       physical id: 10
       bus info: cpu@0
       version: AMD Ryzen 3 1200 Quad-Core Processor
       serial: Unknown
       slot: AM4
       size: 1315MHz
       capacity: 3450MHz
       width: 64 bits
       clock: 100MHz
       capabilities: lm fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp x86-64 constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate sme ssbd sev ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca cpufreq
       configuration: cores=4 enabledcores=4 threads=4

Edit: still freezing weeks later :<

heynnema avatar
ru flag
Edit your question and show me `free -h`. Start comments to me with @heynnema or I'll miss them.
Pixelated Lagg avatar
pe flag
@heynnema Like I said, I should have enough resources, but I added the results of `free -h` nevertheless.
heynnema avatar
ru flag
Show me `swapon -s` and `sysctl vm.swappiness`.
heynnema avatar
ru flag
It certainly looks like you may have a swap problem. See my answer. If it helps to solve your freezing, please remember to accept it by clicking on the checkmark icon that appears just to the left of my answer.
Pixelated Lagg avatar
pe flag
@heynnema After completing the allocation process you described in your answer, I added the output of `swapon -s` and `sysctl vm.swappiness` in my question.
heynnema avatar
ru flag
Does `free -h` now show 8G RAM and 4G swap?
Pixelated Lagg avatar
pe flag
`free -h` returns this: 7.8GI Mem and 4GI Swap
heynnema avatar
ru flag
Good job! Now load up vscode, discord, and opera and see if it freezes.
Pixelated Lagg avatar
pe flag
Ok, will @ you if it does again :)
heynnema avatar
ru flag
After our last exchange I see that you added your gnome-shell extension list. For testing purposes, disable ALL extensions EXCEPT `desktop-icons` and `ubuntu-appindicators` and `ubuntu-dock` and see if this improves the situation. Start comments to me with @heynnema or I'll miss them.
it flag

After a "sudden shutdown", aka "system crash", and reboot, the terminal command sudo journalctl -b -1 -e will show you the end of the previous boot's log's. If there is no hint there, suspect power/ overheating.

Overheating is most likely caused by dust. Power down your system. Unblock your fans and vents, clean out the dust. Ensure air circulation. Dust that coats heat exchangers and chips is a good insulator, and bad for cooling. Don't disassemble your computer until you have downloaded the manufacturer's manual, and researched how-to-clean. Make this information available for when your computer isn't (paper, other computer) Don't use water.

Read man journalctl to see how to extract information from the logs.

You can find how I make use of journalctl easier at

Pixelated Lagg avatar
pe flag
It seems like right before each log ends, there is a bunch of errors thrown from opera_opera.desktop.
Pixelated Lagg avatar
pe flag
Guess it is an opera desktop problem, I will still clean out my hardware. Thanks for the straightforward answer :)
cn flag

Not sure if it's related but I have an ASRock Z77 and kernel 5.4.0-89 randomly freezes. After I soft reset, I get a System Timer error from the bios (4 beeps) and a boot loop, then I have to power cycle. With 5.4.0-88 it looks stable.

Edit after some days: it's definitely stable with 88.

ctrl avatar
cn flag
Looks like 5.4.0-90 fixed it.,
ru flag

Your /swapfile is too small at 2G. Let's increase it to 4G and see if that helps.

Note: Incorrect use of the rm and dd commands can cause data loss. Suggest copy/paste.

In the terminal...

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 8G RAM and 4G swap

Edit /etc/fstab, using sudo -H gedit /etc/fstab or sudo pico /etc/fstab.

Confirm this /swapfile line in /etc/fstab... and confirm no other “swap” lines... use SPACES in this line... confirm NO TABS...

/swapfile  none  swap  sw  0  0

reboot                    # reboot and verify operation

Update #1:

CPU and RAM are not overclocked.

Mobo: ASRock model: A320M firmware: P4.70

ADATA 8G DIMM part # is AX4U240038G16-BRZ, and it doesn't appear on any of the compatible memory charts.

memtest fails. Need to check the CPU name for Ryzen 3 1200, and Memory Compatibility lists at

cn flag
Comments are not for extended discussion; this conversation has been [moved to chat](
pe flag

Fixed the freezing issue by ditching ubuntu and switching to a far more stable operating system, windows 10.

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.