Baloo file indexing service can flood system resources with large file operations that requires processing large amount of indexing meta data to an extend that the system stops responding. It can cause a memory flooding leak. Although there is an option to turn baloo fis off using the terminal, I would like to propose a middle ground solution.
**Include a ram memory limiter to the baloo fis graphically in settings (KDE) or burned into the inmutable system. Something like a selector of different behaviours that can be operated via terminal. **
In the meantime I have written a manual with the help of AI to run a temporary script prior to operating large file-operations: transferring large amounts of files that requires processing and indexing large amounts of meta data.
So far the scripts run. But I am still testing its behaviour.
Here is the final manual with all updates and improvements:
Baloo Memory Limiter Script (Universal)
Purpose
Prevent Baloo from consuming excessive RAM during large file operations (e.g. moving 13k emails). Uses memory.high to throttle Baloo at 16 GB instead of killing it.
Works on cgroup v1 and v2 (openSUSE MicroOS).
Important: If the script fails, hidden Windows line endings may be present. Fix with the
trcommand below.
Fix Hidden Line Endings (Critical Step)
tr -d '\r' < ~/baloo-limit.sh > ~/temp.sh && mv ~/temp.sh ~/baloo-limit.sh
Limit Script (baloo-limit.sh)
#!/bin/bash
# Baloo RAM Limiter - Universal (cgroup v1 & v2)
# Sets memory.high to 16384M (16 GB)
# Baloo is throttled, not killed
MEMLIMIT=16384M
# Detect cgroup version: cgroup2fs = v2, tmpfs = v1
if [ "$(stat -fc %T /sys/fs/cgroup/ 2>/dev/null)" = "cgroup2fs" ]; then
# cgroup v2: Use unified hierarchy
CGROUP=/sys/fs/cgroup/baloo
[ ! -d "$CGROUP" ] && sudo mkdir "$CGROUP"
# Enable memory controller
echo "+memory" | sudo tee /sys/fs/cgroup/cgroup.subtree_control 2>/dev/null || true
# Set soft memory limit
echo $MEMLIMIT | sudo tee "$CGROUP/memory.high" > /dev/null
# Add Baloo processes
for pid in $(pgrep baloo); do
echo $pid | sudo tee "$CGROUP/cgroup.procs" > /dev/null
done
else
# cgroup v1: Use legacy memory cgroup
CGROUP=/sys/fs/cgroup/memory/baloo
[ ! -d "$CGROUP" ] && sudo mkdir -p "$CGROUP"
# Set soft memory limit
echo $MEMLIMIT | sudo tee "$CGROUP/memory.high" > /dev/null
# Add Baloo processes
for pid in $(pgrep baloo); do
echo $pid | sudo tee "$CGROUP/cgroup.procs" > /dev/null
done
fi
echo "Baloo limited to $MEMLIMIT RAM"
Reverse Script (baloo-reverse-limit.sh)
#!/bin/bash
# Baloo Reverse Limiter - Universal (cgroup v1 & v2)
# Removes the memory limit safely
# Detect cgroup version
if [ "$(stat -fc %T /sys/fs/cgroup/ 2>/dev/null)" = "cgroup2fs" ]; then
# cgroup v2
CGROUP=/sys/fs/cgroup/baloo
[ -d "$CGROUP" ] && sudo rmdir "$CGROUP"
else
# cgroup v1
CGROUP=/sys/fs/cgroup/memory/baloo
[ -d "$CGROUP" ] && sudo rmdir "$CGROUP"
fi
echo "Baloo memory limit removed (if active)"
Usage
- Save both scripts in home folder.
- Fix line endings:
tr -d '\r' < ~/baloo-limit.sh > ~/temp.sh && mv ~/temp.sh ~/baloo-limit.sh - Make executable:
chmod +x ~/baloo-limit.sh ~/baloo-reverse-limit.sh - Apply limit:
bash ~/baloo-limit.sh - Remove limit:
bash ~/baloo-reverse-limit.sh
Monitor Status
- Check cgroup version:
stat -fc %T /sys/fs/cgroup/ - View limit:
cat /sys/fs/cgroup/*/baloo/memory.high - Current usage:
cat /sys/fs/cgroup/*/baloo/memory.current - Baloo status:
balooctl status
Notes
- Works on openSUSE MicroOS Kalpa.
- Use
bash script.shif./script.shfails. - The
trcommand fixes line endings from GUI editors. - The memory amount is exemplary for my situation. I use a laptop with 8gb + 16gb ram memory. I want the script to keep 8gb for normal operation while letting the system run baloo. The memory limit can be set to you own desired situation.
- Safe: Baloo continues indexing, just slower under memory pressure.