Error Codes Wiki

Linux Btrfs Balance No Space Left Error — What It Means & How to Fix It

Errorfilesystem error

About Linux Btrfs Balance No Space Left Error

Fix Btrfs file system 'no space left on device' error caused by unbalanced chunk allocation even when df shows free space. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: Btrfs can report 'no space left on device' even when df shows free space due to how chunks are allocated. Btrfs divides the disk into chunks for data and metadata, each type having separate space allocation. Metadata chunks can fill up independently of data chunks, causing write failures. This is a well-known Btrfs behavior that differs from ext4 and XFS space management. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Metadata chunks are full while data chunks have plenty of free space. Many small files consuming disproportionate metadata space relative to data. Snapshots retaining large amounts of metadata that cannot be freed. Btrfs balance has never been run, leaving chunk allocation unoptimized. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check actual usage: btrfs filesystem usage /mount-point to see data vs metadata allocation. Run a limited balance to free metadata: btrfs balance start -dusage=50 /mount-point. If that fails, delete unnecessary snapshots: btrfs subvolume delete /mount-point/snapshot-name. For emergency recovery, temporarily add space: btrfs device add /dev/sdX /mount-point, balance, then remove. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

Why does df show free space but writes fail?

df shows total used vs total available. Btrfs allocates space in separate chunks for data and metadata. If all metadata chunks are full, writes fail even if data chunks have space. Use btrfs filesystem usage for accurate info.

Overview

Fix Btrfs file system 'no space left on device' error caused by unbalanced chunk allocation even when df shows free space.

Key Details

  • Btrfs can report 'no space left on device' even when df shows free space due to how chunks are allocated
  • Btrfs divides the disk into chunks for data and metadata, each type having separate space allocation
  • Metadata chunks can fill up independently of data chunks, causing write failures
  • This is a well-known Btrfs behavior that differs from ext4 and XFS space management

Common Causes

  • Metadata chunks are full while data chunks have plenty of free space
  • Many small files consuming disproportionate metadata space relative to data
  • Snapshots retaining large amounts of metadata that cannot be freed
  • Btrfs balance has never been run, leaving chunk allocation unoptimized

Steps

  1. 1Check actual usage: btrfs filesystem usage /mount-point to see data vs metadata allocation
  2. 2Run a limited balance to free metadata: btrfs balance start -dusage=50 /mount-point
  3. 3If that fails, delete unnecessary snapshots: btrfs subvolume delete /mount-point/snapshot-name
  4. 4For emergency recovery, temporarily add space: btrfs device add /dev/sdX /mount-point, balance, then remove

Tags

btrfsbalanceno-spacemetadatachunks

Related Items

More in Filesystem Error

Frequently Asked Questions

df shows total used vs total available. Btrfs allocates space in separate chunks for data and metadata. If all metadata chunks are full, writes fail even if data chunks have space. Use btrfs filesystem usage for accurate info.