Btrfs is a modern Copy-on-Write (CoW) filesystem with built-in RAID support. So, you do not need any third-party tools to create software RAIDs on a Btrfs filesystem.

The Btrfs filesystem keeps the filesystem metadata and data separately. You can use different RAID levels for the data and metadata at the same time. This is a major advantage of the Btrfs filesystem.

This article shows you how to set up Btrfs RAIDs in the RAID-0, RAID-1, RAID-1C3, RAID-1C4, RAID-10, RAID-5, and RAID-6 configurations.

Abbreviations

  • Btrfs – B-tree Filesystem
  • RAID – Redundant Array of Inexpensive Disks/Redundant Array of Independent Disks
  • GB – Gigabyte
  • TB – Terabyte
  • HDD – Hard Disk Drive
  • SSD – Solid-State Drive

Prerequisites

To try out the examples included in this article:

  • You must have the Btrfs filesystem installed on your computer.
  • You will need at least four same-capacity HDDs/SSDs to try out the different RAID configurations.

In my Ubuntu machine, I have added four HDDs (sdb, sdc, sdd, sde). Each of them is 20 GB in size.

Note: Your HDDs/SSDs may have different names than mine. So, be sure to replace them with yours from now on.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid1-1.jpg" data-lazy- height="317" src="data:image/svg xml,” width=”821″>

For assistance with installing the Btrfs filesystem in Ubuntu, check out the article Install and Use Btrfs on Ubuntu 20.04 LTS.

For assistance with installing the Btrfs filesystem in Fedora, check out the article Install and Use Btrfs on Fedora 33.

Btrfs Profiles

A Btrfs profile is used to tell the Btrfs filesystem how many copies of the data/metadata to keep and what RAID levels to use for the data/metadata. The Btrfs filesystem contains many profiles. Understanding them will help you to configure a Btrfs RAID just the way you want.

The available Btrfs profiles are as follows:

single: If the single profile is used for the data/metadata, only one copy of the data/metadata will be stored in the filesystem, even if you add multiple storage devices to the filesystem. So, 100% of the disk space of each of the storage devices added to the filesystem can be utilized.

dup: If the dup profile is used for the data/metadata, each of the storage devices added to the filesystem will keep two copies of the data/metadata. So, 50% of the disk space of each of the storage devices added to the filesystem can be utilized.

raid0: In the raid0 profile, the data/metadata will be split evenly across all the storage devices added to the filesystem. In this setup, there will be no redundant (duplicate) data/metadata. So, 100% of the disk space of each of the storage devices added to the filesystem can be used. If in any case one of the storage devices fails, the entire filesystem will be corrupted. You will need at least two storage devices to set up the Btrfs filesystem in the raid0 profile.

raid1: In the raid1 profile, two copies of the data/metadata will be stored in the storage devices added to the filesystem. In this setup, the RAID array can survive one drive failure. But, you can use only 50% of the total disk space. You will need at least two storage devices to set up the Btrfs filesystem in the raid1 profile.

raid1c3: In the raid1c3 profile, three copies of the data/metadata will be stored in the storage devices added to the filesystem. In this setup, the RAID array can survive two drive failures, but you can use only 33% of the total disk space. You will need at least three storage devices to set up the Btrfs filesystem in the raid1c3 profile.

raid1c4: In the raid1c4 profile, four copies of the data/metadata will be stored in the storage devices added to the filesystem. In this setup, the RAID array can survive three drive failures, but you can use only 25% of the total disk space. You will need at least four storage devices to set up the Btrfs filesystem in the raid1c4 profile.

raid10: In the raid10 profile, two copies of the data/metadata will be stored in the storage devices added to the filesystem, as in the raid1 profile. Also, the data/metadata will be split across the storage devices, as in the raid0 profile.

The raid10 profile is a hybrid of the raid1 and raid0 profiles. Some of the storage devices form raid1 arrays and some of these raid1 arrays are used to form a raid0 array. In a raid10 setup, the filesystem can survive a single drive failure in each of the raid1 arrays.

You can use 50% of the total disk space in the raid10 configuration. You will need at least four storage devices to set up the Btrfs filesystem in the raid10 profile.

raid5: In the raid5 profile, one copy of the data/metadata will be split across the storage devices. A single parity will be calculated and distributed among the storage devices of the RAID array.

In a raid5 configuration, the filesystem can survive a single drive failure. If a drive fails, you can add a new drive to the filesystem and the lost data will be calculated from the distributed parity of the running drives.

You can use 100x(N-1)/N % of the total disk spaces in the raid5 configuration. Here, N is the number of storage devices added to the filesystem. You will need at least three storage devices to set up the Btrfs filesystem in the raid5 profile.

raid6: In the raid6 profile, one copy of the data/metadata will be split across the storage devices. Two parities will be calculated and distributed among the storage devices of the RAID array.

In a raid6 configuration, the filesystem can survive two drive failures at once. If a drive fails, you can add a new drive to the filesystem, and the lost data will be calculated from the two distributed parities of the running drives.

You can use 100x(N-2)/N % of the total disk space in the raid6 configuration. Here, N is the number of storage devices added to the filesystem. You will need at least four storage devices to set up the Btrfs filesystem in the raid6 profile.

Creating a Mount Point

You need to create a directory to mount the Btrfs filesystem that you will create in the next sections of this article.

To create the directory/mount point /data, run the following command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid2.jpg" data-lazy- height="128" src="data:image/svg xml,” width=”519″>

Setting Up RAID-0

In this section, you will learn how to set up a Btrfs RAID in the RAID-0 configuration using four HDDs (sdb, sdc, sdd, and sde). The HDDs are 20 GB in size.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid3.jpg" data-lazy- height="319" src="data:image/svg xml,” width=”663″>

To create a Btrfs RAID in the RAID-0 configuration using four HDDs (sdb, sdc, sdd, and sde) run the following command:

$ sudo mkfs.btrfs -L data -d raid0 -m raid0 -f /dev/sdb /dev/sdc /dev/sdd /dev/sde

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid4.jpg" data-lazy- height="94" src="data:image/svg xml,” width=”1122″>

Here,

  • The –L option is used to set the filesystem label data.
  • The –d option is used to set the RAID profile raid0 for the filesystem data.
  • The –m option is used to set the RAID profile raid0 for the filesystem metadata.
  • The –f option is used to force the creation of the Btrfs filesystem, even if any of the HDDs have an existing filesystem.

The Btrfs filesystem data in the RAID-0 configuration should now be created, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid5.jpg" data-lazy- height="615" src="data:image/svg xml,” width=”1116″>

You can mount the Btrfs RAID using any HDD/SSD you used to create the RAID.

For example, I used the HDDs sdb, sdc, sdd, and sde to create the Btrfs RAID in the RAID-0 configuration.

So, I can mount the Btrfs filesystem data in the /data directory using the HDD sdb, as follows:

$ sudo mount /dev/sdb /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid6.jpg" data-lazy- height="85" src="data:image/svg xml,” width=”555″>

As you can see, the Btrfs RAID is mounted in the /data directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid7.jpg" data-lazy- height="188" src="data:image/svg xml,” width=”524″>

To find the filesystem usage information of the data Btrfs filesystem mounted in the /data directory, run the following command:

$ sudo btrfs filesystem usage /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid8.jpg" data-lazy- height="84" src="data:image/svg xml,” width=”747″>

As you can see,

The RAID size (Device size) is 80 GB (4×20 GB per HDD).

About 78.98 GB (Free (estimated)) of 80 GB of disk space can be used in the RAID-0 configuration.

Only one copy of the data (Data ratio) and one copy of the metadata (Metadata ratio) will be stored in the Btrfs filesystem in the RAID-0 configuration.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid9.jpg" data-lazy- height="874" src="data:image/svg xml,” width=”747″>

As the Btrfs RAID is working, you can unmount it from the /data directory, as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid10.jpg" data-lazy- height="92" src="data:image/svg xml,” width=”485″>

Setting Up RAID-1

In this section, you will learn how to set up a Btrfs RAID in the RAID-1 configuration using four HDDs (sdb, sdc, sdd, and sde). The HDDs are 20 GB in size.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid11.jpg" data-lazy- height="319" src="data:image/svg xml,” width=”663″>

To create a Btrfs RAID in the RAID-1 configuration using four HDDs (sdb, sdc, sdd, and sde), run the following command:

$ sudo mkfs.btrfs -L data -d raid1 -m raid1 -f /dev/sdb /dev/sdc /dev/sdd /dev/sde

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid12.jpg" data-lazy- height="91" src="data:image/svg xml,” width=”1087″>

Here,

  • The –L option is used to set the filesystem label data.
  • The –d option is used to set the RAID profile raid1 for the filesystem data.
  • The –m option is used to set the RAID profile raid1 for the filesystem metadata.
  • The –f option is used to force the creation of the Btrfs filesystem, even if any of the HDDs have an existing filesystem.

The Btrfs filesystem data in the RAID-1 configuration should now be created, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid13.jpg" data-lazy- height="618" src="data:image/svg xml,” width=”1111″>

You can mount the Btrfs RAID using any HDD/SSD you used to create the RAID.

For example, I used the HDDs sdb, sdc, sdd, and sde to create the Btrfs RAID in the RAID-1 configuration.

I can mount the Btrfs filesystem data in the /data directory using the HDD sdb, as follows:

$ sudo mount /dev/sdb /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid14.jpg" data-lazy- height="81" src="data:image/svg xml,” width=”556″>

As you can see, the Btrfs RAID is mounted in the /data directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid15.jpg" data-lazy- height="163" src="data:image/svg xml,” width=”515″>

To find the filesystem usage information of the data Btrfs filesystem mounted in the /data directory, run the following command:

$ sudo btrfs filesystem usage /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid16.jpg" data-lazy- height="84" src="data:image/svg xml,” width=”747″>

As you can see,

The RAID size (Device size) is 80 GB (4×20 GB per HDD).

About 38.99 GB (Free (estimated)) of 80 GB of disk space can be used in the RAID-1 configuration.

In the RAID-1 configuration, two copies of the data (Data ratio) and two copies of the metadata (Metadata ratio) will be stored in the Btrfs filesystem.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid17.jpg" data-lazy- height="732" src="data:image/svg xml,” width=”788″>

As the Btrfs RAID is working, you can unmount it from the /data directory, as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid18.jpg" data-lazy- height="84" src="data:image/svg xml,” width=”476″>

Setting Up RAID-1C3

In this section, you will learn how to set up a Btrfs RAID in the RAID-1C3 configuration using four HDDs (sdb, sdc, sdd, and sde). The HDDs are 20 GB in size

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid19.jpg" data-lazy- height="319" src="data:image/svg xml,” width=”663″>

To create a Btrfs RAID in the RAID-1C3 configuration using the four HDDs sdb, sdc, sdd, and sde, run the following command:

$ sudo mkfs.btrfs -L data -d raid1c3 -m raid1c3 -f /dev/sdb /dev/sdc /dev/sdd /dev/sde

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid20.jpg" data-lazy- height="89" src="data:image/svg xml,” width=”1124″>

Here,

  • The –L option is used to set the filesystem label data.
  • The –d option is used to set the RAID profile raid1c3 for the filesystem data.
  • The –m option is used to set the RAID profile raid1c3 for the filesystem metadata.
  • The –f option is used to force the creation of the Btrfs filesystem, even if any of the HDDs have an existing filesystem.

The Btrfs filesystem data in the RAID-1C3 configuration should now be created, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid21.jpg" data-lazy- height="626" src="data:image/svg xml,” width=”1127″>

You can mount the Btrfs RAID using any HDD/SSD you used to create the RAID.

For example, I used the HDDs sdb, sdc, sdd, and sde to create the Btrfs RAID in the RAID-1C3 configuration.

So, I can mount the Btrfs filesystem data in the /data directory using the HDD sdb, as follows:

$ sudo mount /dev/sdb /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid22.jpg" data-lazy- height="102" src="data:image/svg xml,” width=”544″>

As you can see, the Btrfs RAID is mounted in the /data directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid23.jpg" data-lazy- height="220" src="data:image/svg xml,” width=”791″>

To find the filesystem usage information of the data Btrfs filesystem mounted in the /data directory, run the following command:

$ sudo btrfs filesystem usage /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid24.jpg" data-lazy- height="84" src="data:image/svg xml,” width=”747″>

As you can see,

The RAID size (Device size) is 80 GB (4×20 GB per HDD).

About 25.66 GB (Free (estimated)) of 80 GB of disk space can be used in the RAID-1C3 configuration.

In the RAID-1C3 configuration, three copies of the data (Data ratio) and three copies of the metadata (Metadata ratio) will be stored in the Btrfs filesystem.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid25.jpg" data-lazy- height="792" src="data:image/svg xml,” width=”754″>

As the Btrfs RAID is working, you can unmount it from the /data directory, as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid26.jpg" data-lazy- height="89" src="data:image/svg xml,” width=”482″>

Setting Up RAID-1C4

In this section, you will learn how to set up a Btrfs RAID in the RAID-1C4 configuration using the four HDDs sdb, sdc, sdd, and sde. The HDDs are 20 GB in size.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid27.jpg" data-lazy- height="319" src="data:image/svg xml,” width=”663″>

To create a Btrfs RAID in the RAID-1C4 configuration using the four HDDs sdb, sdc, sdd, and sde, run the following command:

$ sudo mkfs.btrfs -L data -d raid1c4 -m raid1c4 -f /dev/sdb /dev/sdc /dev/sdd /dev/sde

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid28.jpg" data-lazy- height="87" src="data:image/svg xml,” width=”1136″>

Here,

  • The –L option is used to set the filesystem label data.
  • The –d option is used to set the RAID profile raid1c4 for the filesystem data.
  • The –m option is used to set the RAID profile raid1c4 for the filesystem metadata.
  • The –f option is used to force the creation of the Btrfs filesystem, even if any of the HDDs have an existing filesystem.

The Btrfs filesystem data in the RAID-1C4 configuration should now be created, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid29.jpg" data-lazy- height="618" src="data:image/svg xml,” width=”1131″>

You can mount the Btrfs RAID using any HDD/SSD you used to create the RAID.

For example, I used the HDDs sdb, sdc, sdd, and sde to create the Btrfs RAID in the RAID-1C4 configuration.

So, I can mount the Btrfs filesystem data in the /data directory using the HDD sdb, as follows:

$ sudo mount /dev/sdb /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid30.jpg" data-lazy- height="89" src="data:image/svg xml,” width=”548″>

As you can see, the Btrfs RAID is mounted in the /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid31.jpg" data-lazy- height="155" src="data:image/svg xml,” width=”521″>

To find the filesystem usage information of the data Btrfs filesystem mounted in the /data

$ sudo btrfs filesystem usage /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid32.jpg" data-lazy- height="84" src="data:image/svg xml,” width=”747″>

As you can see,

The RAID size (Device size) is 80 GB (4×20 GB per HDD).

About 18.99 GB (Free (estimated)) of 80 GB of disk space can be used in the RAID-1C4 configuration.

In the RAID-1C4 configuration, four copies of the data (Data ratio) and four copies of the metadata (Metadata ratio) will be stored in the Btrfs filesystem.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid33.jpg" data-lazy- height="862" src="data:image/svg xml,” width=”738″>

As the Btrfs RAID is working, you can unmount it from the /data directory, as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid34.jpg" data-lazy- height="87" src="data:image/svg xml,” width=”470″>

Setting Up RAID-10

In this section, you will learn how to set up a Btrfs RAID in the RAID-10 configuration using the four HDDs sdb, sdc, sdd, and sde. The HDDs are 20 GB in size.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid35.jpg" data-lazy- height="319" src="data:image/svg xml,” width=”663″>

To create a Btrfs RAID in the RAID-10 configuration using the four HDDs sdb, sdc, sdd, and sde, run the following command:

$ sudo mkfs.btrfs -L data -d raid10 -m raid10 -f /dev/sdb /dev/sdc /dev/sdd /dev/sde

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid36.jpg" data-lazy- height="87" src="data:image/svg xml,” width=”1110″>

Here,

  • The –L option is used to set the filesystem label data.
  • The –d option is used to set the RAID profile raid10 for the filesystem data.
  • The –m option is used to set the RAID profile raid10 for the filesystem metadata.
  • The –f option is used to force the creation of the Btrfs filesystem, even if any of the HDDs have an existing filesystem.

The Btrfs filesystem data in the RAID-10 configuration should now be created, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid37.jpg" data-lazy- height="615" src="data:image/svg xml,” width=”1119″>

You can mount the Btrfs RAID using any HDD/SSD you used to create the RAID.

For example, I used the HDDs sdb, sdc, sdd, and sde to create the Btrfs RAID in the RAID-10 configuration.

So, I can mount the Btrfs filesystem data in the /data directory using the HDD sdb, as follows:

$ sudo mount /dev/sdb /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid38.jpg" data-lazy- height="87" src="data:image/svg xml,” width=”555″>

As you can see, the Btrfs RAID is mounted in the /data directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid39.jpg" data-lazy- height="222" src="data:image/svg xml,” width=”532″>

To find the filesystem usage information of the data Btrfs filesystem mounted in the /data directory, run the following command:

$ sudo btrfs filesystem usage /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid40.jpg" data-lazy- height="84" src="data:image/svg xml,” width=”747″>

As you can see,

The RAID size (Device size) is 80 GB (4×20 GB per HDD).

About 39.48 GB (Free (estimated)) of 80 GB of disk space can be used in the RAID-10 configuration.

In the RAID-10 configuration, two copies of the data (Data ratio) and two copies of the metadata (Metadata ratio) will be stored in the Btrfs filesystem.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid41.jpg" data-lazy- height="869" src="data:image/svg xml,” width=”759″>

As the Btrfs RAID is working, you can unmount it from the /data directory, as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid42.jpg" data-lazy- height="84" src="data:image/svg xml,” width=”476″>

Setting Up RAID-5

In this section, you will learn how to set up a Btrfs RAID in the RAID-5 configuration using the four HDDs sdb, sdc, sdd, and sde. The HDDs are 20 GB in size.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid43.jpg" data-lazy- height="345" src="data:image/svg xml,” width=”567″>

To create a Btrfs RAID in the RAID-5 configuration using the four HDDs sdb, sdc, sdd, and sde, run the following command:

$ sudo mkfs.btrfs -L data -d raid5 -m raid5 -f /dev/sdb /dev/sdc /dev/sdd /dev/sde

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid44.jpg" data-lazy- height="87" src="data:image/svg xml,” width=”1041″>

Here,

  • The –L option is used to set the filesystem label data.
  • The –d option is used to set the RAID profile raid5 for the filesystem data.
  • The –m option is used to set the RAID profile raid5 for the filesystem metadata.
  • The –f option is used to force the creation of the Btrfs filesystem, even if any of the HDDs have an existing filesystem.

The Btrfs filesystem data in the RAID-5 configuration should now be created, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid45.jpg" data-lazy- height="634" src="data:image/svg xml,” width=”1044″>

You can mount the Btrfs RAID using any HDD/SSD you used to create the RAID.

For example, I used the HDDs sdb, sdc, sdd, and sde to create the Btrfs RAID in the RAID-5 configuration.

So, I can mount the Btrfs filesystem data in the /data directory using the HDD sdb, as follows:

$ sudo mount /dev/sdb /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid46.jpg" data-lazy- height="88" src="data:image/svg xml,” width=”488″>

As you can see, the Btrfs RAID is mounted in the /data directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid47.jpg" data-lazy- height="281" src="data:image/svg xml,” width=”543″>

To find the filesystem usage information of the data Btrfs filesystem mounted in the /data directory, run the following command:

$ sudo btrfs filesystem usage /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid44-1.jpg" data-lazy- height="87" src="data:image/svg xml,” width=”1041″>

As you can see,

The RAID size (Device size) is 80 GB (4×20 GB per HDD).

About 59.24 GB (Free (estimated)) of 80 GB of disk space can be used in the RAID-5 configuration.

In the RAID-5 configuration, 1.33 copies of the data (Data ratio) and 1.33 copies of the metadata (Metadata ratio) will be stored in the Btrfs filesystem.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid49.jpg" data-lazy- height="875" src="data:image/svg xml,” width=”788″>

As the Btrfs RAID is working, you can unmount it from the /data directory, as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid50.jpg" data-lazy- height="82" src="data:image/svg xml,” width=”405″>

Setting Up RAID-6

In this section, you will learn how to set up a Btrfs RAID in the RAID-6 configuration using the four HDDs sdb, sdc, sdd, and sde. The HDDs are 20 GB in size.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid51.jpg" data-lazy- height="345" src="data:image/svg xml,” width=”567″>

To create a Btrfs RAID in the RAID-6 configuration using the four HDDs sdb, sdc, sdd, and sde, run the following command:

$ sudo mkfs.btrfs -L data -d raid6 -m raid6 -f /dev/sdb /dev/sdc /dev/sdd /dev/sde

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid52.jpg" data-lazy- height="90" src="data:image/svg xml,” width=”1034″>

Here,

  • The –L option is used to set the filesystem label data.
  • The –d option is used to set the RAID profile raid6 for the filesystem data.
  • The –m option is used to set the RAID profile raid6 for the filesystem metadata.
  • The –f option is used to force the creation of the Btrfs filesystem, even if any of the HDDs have an existing filesystem.

The Btrfs filesystem data in the RAID-6 configuration should now be created, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid53.jpg" data-lazy- height="632" src="data:image/svg xml,” width=”1054″>

You can mount the Btrfs RAID using any HDD/SSD you used to create the RAID.

For example, I used the HDDs sdb, sdc, sdd, and sde to create the Btrfs RAID in the RAID-6 configuration.

So, I can mount the Btrfs filesystem data in the /data directory using the HDD sdb, as follows:

$ sudo mount /dev/sdb /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid54.jpg" data-lazy- height="91" src="data:image/svg xml,” width=”498″>

As you can see, the Btrfs RAID is mounted in the /data directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid55.jpg" data-lazy- height="207" src="data:image/svg xml,” width=”577″>

To find the filesystem usage information of the data Btrfs filesystem mounted in the /data directory, run the following command:

$ sudo btrfs filesystem usage /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid56.jpg" data-lazy- height="74" src="data:image/svg xml,” width=”788″>

As you can see,

The RAID size (Device size) is 80 GB (4×20 GB per HDD).

About 39.48 GB (Free (estimated)) of 80 GB of disk space can be used in the RAID-6 configuration.

In the RAID-6 configuration, two copies of the data (Data ratio) and two copies of the metadata (Metadata ratio) will be stored in the Btrfs filesystem.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid57.jpg" data-lazy- height="877" src="data:image/svg xml,” width=”832″>

As the Btrfs RAID is working, you can unmount it from the /data directory, as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid58.jpg" data-lazy- height="85" src="data:image/svg xml,” width=”431″>

Problems with Btrfs RAID-5 and RAID-6

The built-in Btrfs RAID-5 and RAID-6 configurations are still experimental. These configurations are very unstable and you should not use them in production.

To prevent data corruption, the Ubuntu operating system did not implement RAID-5 and RAID-6 for the Btrfs filesystem. So, you will not be able to create a Btrfs RAID in the RAID-5 and RAID-6 configurations using the built-in RAID feature of the Btrfs filesystem on Ubuntu. That is why I have shown you how to create a Btrfs RAID in the RAID-5 and RAID-6 configurations in Fedora 33, instead of Ubuntu 20.04 LTS.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid59.jpg" data-lazy- height="505" src="data:image/svg xml,” width=”833″>

Mounting a Btrfs RAID Automatically on Boot

To mount a Btrfs RAID automatically at boot time using the /etc/fstab file, you will need to know the UUID of the Btrfs filesystem.

You can find the UUID of a Btrfs filesystem with the following command:

$ sudo blkid –match-token TYPE=btrfs

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid60.jpg" data-lazy- height="85" src="data:image/svg xml,” width=”762″>

As you can see, the UUID of the storage devices that are added to the Btrfs filesystem for configuring the RAID is the same.

In my case, it is c69a889a-8fd2-4571-bd97-a3c2e4543b6b. It will be different for you. So, be sure to replace this UUID with yours from now on.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid61.jpg" data-lazy- height="245" src="data:image/svg xml,” width=”1322″>

Now, open the /etc/fstab file with the nano text editor, as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid62.jpg" data-lazy- height="89" src="data:image/svg xml,” width=”495″>

Add the following line to the end of the /etc/fstab file.

UUID=<strong>c69a889a-8fd2-4571-bd97-a3c2e4543b6b</strong>  /data   btrfs   defaults    0   0

Once you are finished, press X followed by Y and to save the /etc/fstab file.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid63.jpg" data-lazy- height="616" src="data:image/svg xml,” width=”1026″>

For the changes to take effect, restart your computer, as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid64.jpg" data-lazy- height="84" src="data:image/svg xml,” width=”399″>

As you can see, the Btrfs RAID is correctly mounted in the /data directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid65.jpg" data-lazy- height="154" src="data:image/svg xml,” width=”577″>

As you can see, the Btrfs RAID mounted in the /data directory is working just fine.

$ sudo btrfs filesystem usage /data

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/set-up-btrfs-raid66.jpg" data-lazy- height="735" src="data:image/svg xml,” width=”759″>

Conclusion

This article explained various Btrfs RAID profiles in detail. The article showed you how to set up a Btrfs RAID in the RAID-0, RAID-1, RAID-1C3, RAID-1C4, RAID-10, RAID-5, and RAID-6 configurations. You also learned about some of the problems with the Btrfs RAID-5 and RAID-6 configurations, as well as how to mount the Btrfs RAID automatically at boot time.

References

About the author

<img alt="Shahriar Shovon" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/01/echo/photo2-150×150.png6007b7313bd9a.jpg" height="112" src="data:image/svg xml,” width=”112″>

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.