As a new-generation file system, Btrfs has brought many advanced features into the picture, which accounts for its resilience. This file system can replace the regular Linux volume management tool. However, there are times when you delete files on the Btrfs file system or lose them to malware attack.
You’re in luck if you have no idea how to recover your files. This article walks you through three different Btrfs undelete methods to recover deleted files from the Btrfs file system within a few minutes.
In this article
Overview of Btrfs Recovery
Btrfs is a modernized file system with a copy-on-write feature and RAID support. It was designed explicitly for Linux-based systems. This file system is essential because you don’t have to overwrite old data when you copy them. This feature makes file recovery relatively easy after crashes and failures because an interruption or error during the copying process doesn’t affect the previous state of the files.
Btrfs effectively stores metadata separately from the file system data so that you can use varying RAID levels for data and metadata. This file system also effectively manages the storage system and improves its integrity features in Linux.
Btrfs Recovery Specifics
The many features of the Btrfs file system help to avoid data loss. However, like most file systems, Btrfs can fail. Btrfs is still under development and, therefore, not stable in many ways. Therefore, below are some Btrfs recovery specifics you should know.
Data Recovery Might Be Affected by Fragmentation
The Btrfs file recovery process might be affected by fragmentation. Due to the copy-on-write feature of the Btrfs file system used to avoid data loss in case of errors and failures during the write operation, there might be data fragmentation. If a file system’s metadata is damaged, it can be challenging to recover fragmented files.
Additionally, storing snapshots when the original version of files and modified parts of the file are stored separately also requires that different sets of metadata are undamaged during recovery.
The Btrfs File Recovery Process Might Take a While
Another main specific is that the Btfrs recovery could take a while. The Btrfs file system uses the copy-on-write feature, which is commonly used for large storage devices. This could lead to many versions of metadata being scattered around the volume. Sorting these versions requires extra time, which is why the Btrfs undelete file process might be slow. File systems without the copy-on-write feature are usually analyzed faster.
There Might Be Bugs
Although the first versions of the Btrfs file system were released in 2007, it is still considered quite unstable. Although the Btrfs file system has become quite popular and is being used by many corporations, there’s no way to tell with certainty that it is entirely reliable and free of bugs.
3 Methods to Recover Deleted Files/Directory on Btrfs File System
Method 1. Undelete Files/Directory on Btrfs File System Using Recoverit (GUI Tool)
Now that you know the main features of the Btrfs file system and the recovery specifics, you’re probably wondering about the best Btrfs undelete files method. One of the best methods is using a Btrfs recovery software.
Wondershare Recoverit is highly recommended because of its high success rate and seamless process. With this software, you can perform recovery on any type of file system, including Btrfs. The best part about Recoverit is that, unlike other Btrfs recovery tools, the steps for the recovery process are few and simple.
Wondershare Recoverit - Your Safe and Reliable Btrfs Recovery Software
5,481,435 people have downloaded it.
Recovers lost or deleted documents, photos, videos, music, emails, and other 1000+ file types effectively, safely, and completely.
Compatible with all popular file systems, including FAT32, exFAT, NTFS, APFS, HFS+, EXT4, Btrfs, etc.
Assists in 500+ data loss scenarios, such as deletion, disk formatting, OS crash, power outage, virus attack, lost partition, and many more.
The NAS and Linux recovery works through a remote connection. No need to pull out the hard drives from these devices.
Since Btrfs is a file system of Linux, this guide will show you the steps to recover deleted files from a Linux computer in Btrfs file system using this GUI Btrfs data recovery tool.
For Windows Vista/7/8/10/11
For macOS X 10.10 or later
Step 1: Select the Linux Recovery Option
Launch the Btrfs data recovery software after downloading and installing. On the homepage, tap the NAS and Linux option from the sidebar and click Linux Recovery to proceed with the Btrfs recovery process.
Step 2: Connect to Btrfs Device
You are required to enter the IP address, username, password, and port address to connect this Btrfs file recovery tool to your Linux device with the Btrfs file system.
Step 3: Scan Deleted Files
The Btrfs recovery tool will begin scanning deleted files in the Linux device automatically after a successful connection. This is an all-around scan that will be completed within a few minutes. In addition, you can filter the files by several filters like date modified, file type, and many more to locate your desired files quickly.
Step 4: Preview and Recover Files
Previewing the scanned files is possible in Recoverit Btrfs Recovery. After previewing, select the files or directory you want to restore and hit the Recover button to save them to a safe location.
For Windows Vista/7/8/10/11
For macOS X 10.10 or later
Method 2: Restore Deleted Files/Directory on Btrfs File System Using Undelete-Btrfs Script
The undelete-btrfs script is a tool that generates the path regex for the Btrfs restore process. It also helps to attempt the restoration process in three levels. The longer a file has existed before the recovery process, the easier it is to recover. However, the script might not work well in test environments. This refers to situations where a file is newly created and deleted; then you try to recover it. Regardless, the undelete btrfs script should work well on a real system.
Syntax:
./undelete.sh <source dev> <recovery destination>
Example:
sudo ./undelete.sh /dev/sda1 /mnt/
When launching this script, it is worthy of note that you will be asked to provide the path to the file you want to recover. When entering the path, you must remove the regular mount point for the Brtfs volume. If it is the root path of your OS, then it’s best to boot from a live USB.
Recover Deleted Files Using Undelete-Btrfs
To recover a file using this script, write the actual path to the file in the script. An example is if the real path to the file is /data/documents/bills/electric.pdf. To write it in the script, you would enter /document/bills/electric.pdf.
Recover Deleted Directory Using Undelete-Btrfs
Suppose the actual path to the directory is /data/pictures/2023/Iceland/. Then, the step to write it in the script is /Pictures/2023/Iceland/. Unlike file recovery using the Btrfs script, directory recovery must end with a slash. This indicates that you’re dealing with a directory and not a script.
When the script is provided, it automatically generates the regex syntax required by the Btrfs restore tool and begins three varying depths of recovery. It goes through the depths one by one, and if your data is discovered on any of these depth levels, the script will prompt you. However, if the data isn’t found, it will ask you if you want to look deeper.
Notes
When recovering a file, you might also find that the recovered file is an older version. The script would try to recover the most recent version. However, there’s no guarantee that the recovered version would be the most current version of the file.
It is also crucial to note that the path and file names are case-sensitive. Therefore, confirm the name and cases before entering the script. Additionally, this script uses btrfs restore and btrfs-find-root to recover files. There’s no guarantee that it will recover your files.
Method 3: Recover Deleted Files on Btrfs File System Using Btrfs Restore Utility
The Btrfs restore utility tool is an effective method to recover data from an unmountable file system. It doesn’t try to repair the file system, which means it can result in further damage if you run it. Running this recovery tool is quite simple. If your device is /dev/sda1, once you launch the restore utility tool, all you have to do is enter the code:
# ./btrfs restore /dev/sda1 /mnt/restore
However, this simple code might not work out for you. Here are other options you can try out.
Option |
Description |
-s | Without including this option, it will not restore snapshots |
-x | This option allows you to recover extended attributes. |
-m | This helps to recover metadata like time, owner, and mode. |
-S | This option works to recover symbolic links. |
-i | This option helps to ignore command errors because the restore tool automatically exists when there’s an error. However, this command ensures that the tool keeps going regardless. |
-v | This command increases verbosity, and you can enter it many times. |
-t | This option informs the tool about the tree location. |
-o | This tool works to overwrite existing files: If files exist at the output location with the exact name, the restore utility using skips the restoration of that file. However, this command works to overwrite the existing file instead. |
-f | This option refers to the filesystem location. |
-u | It is a superblock mirror. This means it specifies an alternate superblock copy that the tool can use. It is pretty useful when the 0th superblock is damaged. |
-c | This refers to case-insensitive regex matching. |
-d | This command causes the tool only to list files it would recover. |
FAQs
Is btrfs unstable?
Btrfs is relatively stable and a well-tested single-disk filesystem. Although it isn’t unstable, you should be cautious when using some advanced features like Btrfs-RAID.
Is it worth using Btrfs?
Yes, it is worth using this file system for many reasons. It offers many features like data compression, increasing the lifespan of many storage devices, and improving the performance of many processes. It also supports more drive space than ext4.
Is btrfs still supported?
Yes, the Btrfs file system is supported. Many of its new features are under development. However, it is fully supported for use in Linux.
Is Btrfs faster than NTFS?
This can be hard to tell. However, there are reports that Btrfs is faster than the NTFS file system because it has a higher limit than NTFS.
Conclusion
Btrfs is a new and reliable file system for your Linux-based computer. However, many things could cause data loss on your Btrfs file system. The good news is that there are three methods you can use to recover Btrfs partitions, files, and directories. This article clearly explains them all. By following the Btrfs undelete steps in this article, you’ll have your files back in no time.
For Windows Vista/7/8/10/11
For macOS X 10.10 or later