BTRFS: Persisting Deleted Files Scrub Errors

Abstract: Resolve BTRFS scrub errors on deleted files by stopping writes, removing snapshots, and running btrfs scrub start -r to fix metadata inconsistencies.

Created: 2026-10-09 by

BTRFS scrub errors involving deleted files typically stem from metadata inconsistencies, delayed inode updates, or background tasks like snapshots and balance operations interfering with the deletion process. Resolving these issues requires stopping all write operations, running a full scrub with repair mode enabled, and verifying that no active snapshots are holding references to the removed data.

Understanding Scrub Errors on Deleted Files

When you encounter scrub errors specifically related to files that have already been deleted, it indicates that the file system metadata is out of sync with the actual state of the disk blocks. The BTRFS scrub tool reads every block in the file system to check for checksum mismatches. If a file has been logically deleted but its metadata (such as directory entries or inode structures) still points to valid data chunks, or if those chunks contain stale data, the scrub will report an error.

This scenario often arises because BTRFS uses Copy-on-Write (CoW). When a file is deleted, the operation does not immediately wipe the underlying data; it simply removes the reference count. If a snapshot exists at the time of deletion, the old version of the file remains accessible through that snapshot, keeping the data alive. If the data was corrupted before deletion, or if the metadata update failed partially, the scrub detects the inconsistency. It is crucial to distinguish between a simple reporting glitch and actual data corruption, which can be determined by the severity and type of error reported during the scrub.

Preparation and Safety Measures

Before attempting any repairs, you must ensure that no other processes are writing to the file system. Background tasks such as snapper, btrfs-send, or automated backups can interfere with the scrub process and mask the true state of the file system. Additionally, running a scrub while the file system is mounted read-write can lead to race conditions where new writes occur simultaneously with the verification process.

  1. Unmount the File System: Ideally, unmount the affected partition. If this is not possible due to it being the root file system, mount it read-only using mount -o remount,ro /mount/point.
  2. Stop Services: Halt any services that might access the file system, including database servers, web servers, or backup agents.
  3. Check for Snapshots: List all existing subvolumes and snapshots using btrfs subvolume list /mount/point. If there are snapshots that include the deleted files, you must decide whether to keep them. Keeping them preserves the old data but may prevent the scrub from fully cleaning up the metadata references.

If you suspect that the deleted files were part of a critical backup, consider creating a raw image of the partition using dd or clonezilla before proceeding. This ensures that you have a fallback if the repair process causes further instability.

Running the Scrub with Repair Mode

The standard scrub command only checks for errors without fixing them. To resolve inconsistencies caused by deleted files, you must use the repair flag. This tells the kernel to attempt to fix correctable errors, such as mismatched checksums or missing tree roots.

btrfs scrub start -r /mount/point

The -r flag enables repair mode. Note that this operation can take a significant amount of time depending on the size of the file system. Monitor the progress using:

btrfs scrub status /mount/point

If the scrub reports that it fixed errors, verify the integrity again by running a non-repairing scrub. If errors persist, it indicates more severe corruption that cannot be automatically repaired, potentially requiring manual intervention or recovery tools.

Handling Persistent Metadata Issues

If scrub errors continue after a repair run, the issue may lie deeper within the file system tree structure. In such cases, checking the health of specific subvolumes is essential. You can inspect the status of individual subvolumes to see if they are flagged as inconsistent.

Another common cause is incomplete transactions. BTRFS relies on transaction commits to finalize changes. If the system crashed during a deletion, the transaction might be left in a limbo state. Running a filesystem check with btrfs-check (formerly btrfsck) can help identify and fix structural issues. However, btrfs-check should always be run on an unmounted file system, and it is recommended to use the --repair flag only if btrfs scrub fails to resolve the issue, as repair modes in btrfs-check can sometimes cause data loss if misapplied.

btrfs-check --readonly /dev/sdXN

Use the --readonly flag first to assess the damage without making changes. If the output suggests minor inconsistencies that align with the scrub errors, you may then proceed with a repair run. Always back up your data before executing any repair commands in btrfs-check.

Post-Repair Verification

After successfully running the scrub with repair, remount the file system normally and verify that the errors no longer appear. Check the system logs using dmesg | grep btrfs for any residual warnings. It is also advisable to run a second scrub without the repair flag to confirm that the file system is now clean. If the errors return, it may indicate hardware issues, such as failing sectors on the disk, rather than file system corruption.

Frequently Asked Questions

Can I run btrfs scrub while the system is running?

Yes, you can run a scrub on a mounted file system, but it is less accurate and slower. For deleting file issues, running it read-only or unmounted is strongly recommended to prevent new writes from masking or complicating the errors.

What does it mean if scrub says "no errors found" but I still see issues?

This usually means the file system metadata is consistent, but application-level issues or user errors are causing the perceived problems. It could also indicate that the error lies outside the scope of scrub checks, such as in the kernel drivers or hardware controllers.

Should I delete snapshots before running scrub?

If the deleted files are referenced by snapshots, the scrub cannot fully remove their metadata until the snapshots are deleted. You should delete unnecessary snapshots first to allow the scrub to clean up all orphaned data references.

Is btrfs-check safe to use on a production server?

No, btrfs-check is a diagnostic and repair tool that should only be used when necessary. Using it incorrectly can corrupt the file system further. Always have a recent backup before running any repair functions.

How do I know if my disk hardware is failing?

If scrub errors persist after repairing the file system and checking for metadata issues, check SMART data using smartctl on the device. Recurring checksum errors on different files over time are a strong indicator of physical disk failure.

Can I recover files that were deleted before the scrub error appeared?

Recovery is difficult because BTRFS CoW makes traditional file carving ineffective. If you have snapshots, restore from them. Otherwise, specialized forensic tools may attempt recovery, but success is not guaranteed, especially if the space has been overwritten.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More