Hello everybody!
Watch this video to find out how to recover data from a software BtrFS RAID based on Linux,
how to create a BtrFS RAID5, how to replace a faulty disk, and how to recover lost data
from a damaged disk array.
Usually, mdadm and lvm are used to create a RAID system in Linux, and you can learn
more about it in other videos on our channel.
In addition to these tools, you can also find integrated RAID support in BtrFS file system.
This system uses its own features to create and manage disk arrays, and we’re going
to study them in detail.
BtrFS file system BtrFS is a modern file system with the integrated
Copy on Write feature and RAID support.
The essence of Copy on Write is that when you copy existing files, they do not overwrite
old data which makes it much easier to recover after crashes or failures, as interruptions
in the write operation don’t affect the previous state of data.
BtrFS stores metadata separately from the file system data, and its main advantage is
that you can use various RAID levels for data and metadata.
Another purpose of this journaled file system is to provide a more effective way to manage
the storage system and improve data integrity features in Linux.
Before you can start using BtrFS, you need to install special tools to manage this file
system.
Do it with the following command: sudo apt install btrfs-tools
How to create a mount point You have to create a mount point directory
for BtrFS file system before you can build a RAID array.
Use this command to create the directory: sudo mkdir -v /data
Where “data” is the directory name.
Now you can start building the array.
How to create a BtrFS RAID5 This file system doesn’t require a hard
disk to be divided into partitions if you want to build a RAID.
What is more, when building a disk array you can use physical hard disks, their partitions,
and even combine disks and partitions into a single array.
For illustration, I’ll show you how to use five hard disks to create a RAID 5 system.
To save the trouble of having to enter the root password every time, run the sudo-i command
and type the password, and now you can run all commands as administrator.
To build a RAID system, type this command in the terminal:
sudo mkfs.btrfs -L data -m raid5 -d raid5 -f /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf
where: L- is the mark or name of the file system
The parameters that can be used: d - to set raid5 for file system data;
m - to set raid5 for file system metadata; f - to force BtrFS file system even if one
of the drives has a different file system.
After that, you can mount BtrFS RAID using any of the drives included into your array.
How to mount a RAID drive In my case, I used 5 drives to create a disk
array - sdb, sdc, sdd, sde and sdf.
That is why I can mount file system data with the help of drive “sdb” in the directory
with the name “data.”
Open the disk management tool and mount the drive, and then it becomes available.
Otherwise, you can use the following command to mount a drive:
sudo mount /dev/sdb1 /data To check if everything’s OK, run the command
sudo df -h Now you can see the BtrFS RAID system mounted
in the directory with the name “/data.”
To view information on how the operating system uses the array (that is, how much space is
free and occupied), type this command: sudo btrfs filesystem usage /data
To unmount the array, you only need to use a single command: sudo umount /data
How to replace or add a drive to BtrFS RAID To replace a drive, there is BtrFS replace
command.
It is run asynchronously, and that is why the first parameter gives the command: start
- to launch the process, cancel - to stop it, and status - to see its progress and condition.
First of all, you need to identify the number of the damaged drive with the help of this
command: sudo btrfs filesystem show
Then replace it with a new one using this command:
btrfs replace start 3 /dev/sdg where:
3 – the number of the missing drive sdg – the code for a new drive
How to recover a damaged BtrFS RAID volume To recover a damaged BtrFS system, use the
mount option - recovery - by entering the following command:
sudo mount -o recovery /dev/sdb /mnt It starts the recovery process.
How to recover data from BtrFS RAID with the help of Hetman RAID Recovery
Even the most reliable and fault-tolerant system may fail someday.
A system error, drive failure, hardware issues, damaged metadata, accidental removal or wrong
settings - any of these may result in knocking the RAID down and making it lose important
information.
If you face anything from that list, just use Hetman RAID Recovery.
It can restore data from non-operational RAID systems or from drives that used to be part
of such systems.
Our utility will read all available information about the array and then rebuild the damaged
RAID so you can copy all the discovered data from there.
Connect the drives to a Windows computer, use a virtual machine, or install Windows
alongside your main Linux operating system.
The utility will scan the drives automatically and display all the information about your
array.
As you can see, in case with BtrFS RAID the program doesn’t collect the drives into
a single array (this can be explained by peculiarities of building this array type), but all the
information is stored according to the RAID type which is used.
To start the recovery process, open the Drive Manager, right-click on any drive that used
to make up this array and run the “Fast scan.”
When scanning any drive, the result should be the same as all of them are elements of
the same disk array.
When the scan is over, the program will display the files it has found; the preview feature
will help you find the required images or videos more easily.
Select the files you want to recover, click Recovery, select where you want to save them,
and click Recovery again.
In the end, you will find the recovered files in the folder you have chosen.
If the “Fast scan” can’t find the required files, then go for “Full analysis.”
This scan type takes much longer, but it’s sure to find all the information still existing
on the drive, even if it was removed a long time ago.
As this is a RAID 5 system, all the information remains intact in spite of one drive missing,
but if two drives go south, a part of the data is bound to be damaged.
Peculiarities of BtrFS file system BtrFS supports data compression at the file
system level.
It means that the information available on the disk will be compressed automatically
as more new data is written.
When accessing files stored in the file system, the data of such files will be decompressed
automatically.
The file system feature helps to save disk space - and your time because you don’t
have to look for a third-party tool for compressing your files.
BtrFS supports three main file compression methods – zlib, lzo and zstd.
They differ by the degree and speed of compression.
Our utility supports recovery of files compressed with any of these methods.
In the program’s interface, compressed volumes and files are shown like this - highlighted
in a different color.
Another serious advantage of BtrFS file system is its ability to create subvolumes.
In plain English, you can create, for example, three different disks (subvolumes) on one
hard disk.
These subvolumes may expand at the cost of free space taken from another volume.
When necessary, this feature lets you expand one disk at the expense of another without
either compressing or transferring the actual data.
These subvolumes are then displayed like this – as disks inside the main drive.
In the same way, folders containing snapshots are displayed.
Here is the command used to create subvolumes: btrfs subvolume create /mnt/btrfs/my-subvolume
To view the list of subvolumes on this drive, run the following command:
btrfs subvolume list /mnt/btrfs And this one, to mount a subvolume:
mount -o subvol=my-subvolume /dev/sdd2 /mnt/btrfs2 where sdb1 is the drive code.
There are only a few data recovery tools capable of reading BtrFS RAID systems.
When choosing which one to use, always remember that information may get erased during the
scan, so having an option to create an image of the array and then run the scan on the
image instead of the actual set of disks could be a serious advantage.
All in all, though, the best way to avoid losing important data is to back up your files
regularly.
That is all for now!
Hopefully, this video was useful.
Remember to click the Like button and subscribe to our channel.
Push the bell button to receive notifications and never miss new videos.
Leave comments to ask questions.
Thank you for watching.
Good luck.