OS get frequently stuck, with intensive HDD activity

Hello!

I have a notebook HP 250 G6, 4GB RAM, 500GB HDD SATA 5400rpm on which I installed OpenSuse Leap 15.0.

Almost always, after few minutes from startup, the entire system get freezed: no mouse movement, no keyboard input, and the HDD starts an intensive work with distinct noise from both HDD and cooler fan.

The problem can last for several minutes, sometimes I get impatient and make a hard reboot. Then it runs well, until the next time.

There’s no way I can work smoothly for more than half an hour without either reboot (by power button) or have a break to let it “calm down”.

What are the applications running when the system get stuck? Essentially only Firefox, or sometimes two instances of Firefox.

Mi problem is very similar to this one https://forums.opensuse.org/showthread.php/532675-intensive-HDD-read-freezes-OS-at-random-time?highlight=freeze+disk but with some differences: I have a btrfs partition.

I put here below the output of the commands you requested to the fellow user.

>>> sudo fdisk --list
Disk /dev/sda: 465,8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x7ebf80cd

Dispositivo Avvio    Start      Fine   Settori   Size Id Tipo
/dev/sda1             2048   8402943   8400896     4G 82 Linux swap / Solaris
/dev/sda2   *      8402944  73416703  65013760    31G 83 Linux
/dev/sda3         73416704 976773167 903356464 430,8G 83 Linux
>>> sudo btrfs filesystem usage /
Overall:
    Device size:         31.00GiB
    Device allocated:    16.32GiB
    Device unallocated:  14.68GiB
    Device missing:         0.00B
    Used:                14.46GiB
    Free (estimated):    15.95GiB  (min: 8.60GiB)
    Data ratio:              1.00
    Metadata ratio:          2.00
    Global reserve:      36.84MiB  (used: 0.00B)

Data,single: Size:15.01GiB, Used:13.74GiB
   /dev/sda2      15.01GiB

Metadata,DUP: Size:640.00MiB, Used:369.52MiB
   /dev/sda2       1.25GiB

System,DUP: Size:32.00MiB, Used:16.00KiB
   /dev/sda2      64.00MiB

Unallocated:
   /dev/sda2      14.68GiB

>>> sudo systemctl list-unit-files | grep -iE 'fsck|fstrim|btrfs' 
btrfsmaintenance-refresh.path                                          enabled  
btrfs-balance.service                                                  static   
btrfs-defrag.service                                                   static   
btrfs-scrub.service                                                    static   
btrfs-trim.service                                                     static   
btrfsmaintenance-refresh.service                                       enabled  
fstrim.service                                                         static   
systemd-fsck-root.service                                              static   
systemd-fsck@.service                                                  static   
btrfs-balance.timer                                                    enabled  
btrfs-defrag.timer                                                     disabled 
btrfs-scrub.timer                                                      enabled  
btrfs-trim.timer                                                       enabled  
fstrim.timer                                                           enabled  

Any help is appreciated

Thanks
Giorgio

Well, 15.0 is a bit old. Better go first to 15.2. Then it could probably be easier for people to help when the can give advice on a supported version.

Agreed with Henk that it is better to upgrade.

With that said, hanging with a lot of hard-disk activity can point to running out of memory, the disk activity is then the OS swapping data to and from the hard-disk.

Try running KSysGuard with the System Load tab active and keep the “Memory and Swap History” visible. This will show the real memory + the swap size, you can get the real memory size for example using “inxi”

Besides upgrading to a current, supported openSUSE version,
With only 4GB RAM, you should also consider minimizing unnecessary tasks, so for instance if you installed either of the standard KDE/Plasma and Gnome Desktops, they run numerous “extra” services that automate maintenance and enhance visual bling, leaving less for actual applications.

You have 3 main options…

  • Go into the Desktop settings and disable/turn off what you don’t need.
  • Install a lighter Desktop that doesn’t recommend 4GB as the minimum amount of RAM you should have installed.
    openSUSE provides some easy choices…
    If your current Desktop is KDE/Plasma, the LXQt Desktop supports the same applications (and provides alternatives if you wish) using the same Qt framework, does not install and run nearly all the unnecessary things that can make KDE/Plasma look great. And, LXQt requires only about 2GB of RAM, the rest is available for your applications.
  • You don’t have to install a full Desktop. You can run just a Window Manager to have a Desktop like experience and all openSUSE installs include IceWM by default (It’s probably already installed). On most openSUSE machines, just log out and back in selecting IceWM instead of your regular Desktop and a number of applications should already be available (like Firefox). When you run only a Window Manager, the operating system typically is using only about 512-768MB of RAM, the rest is available to your application.

HTH,
TSU

I don’t see Plasma itself using so much RAM:

# inxi -Smy
System:
  Host: i2134 Kernel: 5.3.18-lp152.41-default x86_64 bits: 64
  Desktop: KDE Plasma 5.18.6 Distro: openSUSE Leap 15.2
Memory:
  RAM: total: 3.83 GiB used: 652.9 MiB (16.6%)
  Array-1: capacity: 4 GiB slots: 2 EC: None
  Device-1: DIMM0 size: 2 GiB speed: 667 MT/s
  Device-2: DIMM1 size: 2 GiB speed: 667 MT/s
# free
              total        used        free      shared  buff/cache   available
Mem:        4018888      410196     2877004        6168      731688     3373564
Swap:       4325372           0     4325372

This can be improved by disabling automatically started unnecessaries.

BTRFS is slowing down systems with SATA 5400rpm HDDs.
KDE works OK with 4 GiB RAM. Of course, adding RAM is needed badly.
Check amount of video memory.

These two Phoronix tests seem to indicate that, Btrfs on Linux 5.0 SATA SSDs causes a performance hit – Btrfs on Linux 4.8 SATA HDDs is a little bit slower but, not by much – Linux 4.8 HDD <EXT4, Btrfs, XFS & NILFS2 HDD File-System Tests On Linux 4.8 - Phoronix; – Linux 5.0 SSD <Linux 5.0 File-System Benchmarks: Btrfs vs. EXT4 vs. F2FS vs. XFS - Phoronix.

1st article: 16 GiB of RAM, 2nd: 32 GiB of RAM.
Try to use BTRFS on system with 4 GiB RAM + SATA 5400rpm HDD and feel the difference. Here is a laptop - subtract some volume to a video memory.
I have such experience, what about you?

For some years now, ever since memory has become cheaper and, the affordable Mainboards have supported enough memory, my Linux systems have all been setup with enough 2 GiB and 4 GiB memory modules for a total of 8 GiB (module size total) – except for this one – two 8 GiB modules …

  • But yes, because Btrfs is CoW, it needs memory to buffer the writes …

After load OS starts maintenance work for BTRFS, and with 4 GiB RAM or less it stucks for ~30 min.
There is no such problem with ext4 or XFS.

Do we need to have this added to the Release Notes?

  • If we only have it noted here, it’ll never be noticed as a system issue …

Yes, of course.
Something like “Special settings for systems with volume of RAM less than 8 GiB” (no BTRFS, no GNOME, smaller dedicated video RAM, …).
How to do this? And estimation “~30 min” is very coarse.

Done – Bug 1184654System with less than 4 GiB Memory - Btrfs not suitable” <1184654 – System with less than 4 GiB available memory - Btrfs not suitable;

  • Please add you votes to this Bug Report.

Hmm, I can’t reproduce that. Just recently I have set up a system with some (obsolete) older hardware i.e. Dual Core Pentium, 4GiB RAM and a 300 GiB Seagate HDD (7200 RPM) with Btrfs and snapshots acitvated and KDE Plasma. I still got it here upstairs. Here’s some details. Maybe they can help for comparison?

**balu:~ #** systemctl list-unit-files | grep -iE 'fsck|fstrim|btrfs'  
**btrfs**maintenance-refresh.path                                          enabled   
**btrfs**-balance.service                                                  static    
**btrfs**-defrag.service                                                   static    
**btrfs**-scrub.service                                                    static    
**btrfs**-trim.service                                                     static    
**btrfs**maintenance-refresh.service                                       disabled  
**fstrim**.service                                                         static    
systemd-**fsck**-root.service                                              static    
systemd-**fsck**@.service                                                  static    
**btrfs**-balance.timer                                                    enabled   
**btrfs**-defrag.timer                                                     disabled  
**btrfs**-scrub.timer                                                      enabled   
**btrfs**-trim.timer                                                       disabled  
**fstrim**.timer                                                           enabled  

There’s quite some difference from the OP’s findings. I did not apply any changes however.

~> LANG=C di 
Filesystem         Mount               Size     Used    Avail %Used  fs Type 
/dev/sda2          /                 108.1G    12.9G    94.2G   13%  btrfs   
/dev/sda2          /.snapshots       108.1G    12.9G    94.2G   13%  btrfs   
/dev/sda2          /boot/grub2/i38   108.1G    12.9G    94.2G   13%  btrfs   
/dev/sda2          /boot/grub2/x86   108.1G    12.9G    94.2G   13%  btrfs   
tmpfs              /dev/shm            1.9G     0.0G     1.9G    0%  tmpfs   
/dev/sda3          /home             186.1G     0.4G   185.7G    0%  xfs     
/dev/sda2          /opt              108.1G    12.9G    94.2G   13%  btrfs   
/dev/sda2          /root             108.1G    12.9G    94.2G   13%  btrfs   
tmpfs              /run                1.9G     0.0G     1.9G    1%  tmpfs   
tmpfs              /run/user/1000    389.3M     0.0M   389.3M    0%  tmpfs   
/dev/sda2          /srv              108.1G    12.9G    94.2G   13%  btrfs   
tmpfs              /sys/fs/cgroup      1.9G     0.0G     1.9G    0%  tmpfs   
/dev/sda2          /tmp              108.1G    12.9G    94.2G   13%  btrfs   
/dev/sda2          /usr/local        108.1G    12.9G    94.2G   13%  btrfs   
/dev/sda2          /var              108.1G    12.9G    94.2G   13%  btrfs  
**balu:~ #** inxi -SmDGf 
**System:    Host:** balu **Kernel:** 5.3.18-lp152.69-default x86_64 **bits:** 64 **Console:** tty 2 **Distro:** openSUSE Leap 15.2  
**Memory:    RAM:****total:** 3.80 GiB **used:** 880.9 MiB (22.6%)  
           **Array-1:****capacity:** 8 GiB **slots:** 2 **EC:** None  
           **Device-1:** DIMM A1 **size:** 2 GiB **speed:** 800 MT/s  
           **Device-2:** DIMM B1 **size:** 2 GiB **speed:** 800 MT/s  
**CPU:       Topology:** Dual Core **model:** Pentium E5800 **bits:** 64 **type:** MCP **L2 cache:** 2048 KiB  
           **Speed:** 1210 MHz **min/max:** 1203/3203 MHz **Core speeds (MHz):****1:** 1210 **2:** 1210  
           **Flags:** acpi aperfmperf apic arch_perfmon bts clflush cmov constant_tsc cpuid cx16 cx8 de ds_cpl dtes64 dtherm dts  
           est flexpriority fpu fxsr ht lahf_lm lm mca mce mmx monitor msr mtrr nopl nx pae pat pbe pdcm pebs pge pni pse  
           pse36 pti rep_good sep sse sse2 ssse3 syscall tm tm2 tpr_shadow tsc vme vmx vnmi xsave xtpr  
**Graphics:  Device-1:** Intel 4 Series Integrated Graphics **driver:** i915 **v:** kernel  
           **Display:****server:** X.org 1.20.3 **driver:** modesetting **unloaded:** fbdev,vesa **tty:** 261x52  
           **Message:** Advanced graphics data unavailable in console for root.  
**Drives:    Local Storage:****total:** 298.09 GiB **used:** 13.31 GiB (4.5%)  
           **ID-1:** /dev/sda **vendor:** Seagate **model:** ST320DM000-1BD14C **size:** 298.09 GiB

This is the dmesg of Btrfs doing is homework (the first 11 lines):

   54.237726] BTRFS info (device sda2): balance: start -dusage=0 
   54.237746] BTRFS info (device sda2): balance: ended with status: 0 
   73.059698] BTRFS info (device sda2): balance: start -dusage=5 
   73.059718] BTRFS info (device sda2): balance: ended with status: 0 
   75.774909] BTRFS info (device sda2): balance: start -dusage=10 
   75.774946] BTRFS info (device sda2): balance: ended with status: 0 
   76.087482] BTRFS info (device sda2): balance: start -musage=0 -susage=0 
   76.087500] BTRFS info (device sda2): balance: ended with status: 0 
   76.463725] BTRFS info (device sda2): balance: start -musage=3 -susage=3 
   76.471025] BTRFS info (device sda2): relocating block group 22020096 flags system|dup 
   77.189855] BTRFS info (device sda2): balance: ended with status: 0 
  105.268693] fuse: init (API version 7.31) 
  189.312927] perf: interrupt took too long (2536 > 2500), lowering kernel.perf_event_max_sample_rate to 78750 
  641.765985] perf: interrupt took too long (3184 > 3170), lowering kernel.perf_event_max_sample_rate to 62750 
  660.196984] BTRFS info (device sda2): qgroup scan completed (inconsistency flag cleared)

So far, the machine is behaving quite mannerly. It’s responsive, no significant hangs, doesn’t feel laggy. Admittedly I haven’t done much with this machine but installing, setting up software and users, zypper up. Is the filesystem yet just “too clean”? Should I worry? I’m planning to give it away to a friend (with service included:)) and don’t want to start this with trouble pending.

I thank everyone for your kind replies

As first task I added 4 more GB RAM and that was obviously good.

Then I’m going to upgrade to 15.2 version, changing at the same time the root file system from btrfs to ex4.

I’ll take into account the advice of @tsu2 in order to better tune the overall system performance.