Skip to content

Add btrfs balance option to low disk space notification #28

@mmmikko

Description

@mmmikko

Problem Description

When the System Rollback feature detects low unallocated btrfs space (below 15%), it displays a notification warning users about potential file corruption and paused snapshot maintenance. However, the notification only suggests:

  • Removing files from /home
  • Purging software packages
  • Moving databases/VMs/logs
  • Using Rollback Dashboard

These suggestions address used space, but the actual problem is often fragmented btrfs chunk allocation - where plenty of free space exists within allocated chunks, but little unallocated space remains for new chunks.

Real-World Example

$ df -h /
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p6   86G   36G   46G  44% /

$ sudo btrfs filesystem usage /
Device size:           85.43GiB
Device unallocated:     6.41GiB  (~7.5%)
Free (estimated):      45.92GiB

The user sees 46GB free (56%), but kfocus correctly warns about only 7% unallocated. The fix is simply:

sudo btrfs balance start -dusage=50 /

This reclaims unused space from partially-filled chunks back to the unallocated pool.

Suggested Improvements

  1. Add "Run Balance" button to the kdialog notification that executes the balance command (with pkexec for privileges)

  2. Update notification text to explain the difference between "free space" and "unallocated space" and mention that balance can help

  3. Consider proactive balancing in _maintainBtrfsFn() - automatically run a light balance (e.g., -dusage=30) when unallocated drops below 20%, before it becomes critical

Affected Files

  • /usr/lib/kfocus/bin/kfocus-rollback-backend - _lowDiskWithHomeMsg and _lowDiskWithoutHomeMsg message templates
  • /usr/bin/kfocus-focusrx-dbus-dispatch - kdialog launcher (would need new button handler)
  • /usr/lib/kfocus/bin/kfocus-focusrx-system - _maintainBtrfsFn() for proactive balancing

Why This Matters

This is a common btrfs behavior that confuses users. The kfocus team already did the right thing by monitoring unallocated space (most distros don't), but the current remediation suggestions don't address the root cause. Users delete files unnecessarily when a simple balance would fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions