Short Bytes: Btrfs is a cutting edge filesystem that offers many features like Copy-on-Write, snapshots, and RAID which we’ll be looking at in this article. A wide variety of configurations can be achieved using just the Btrfs mkfs command.
First thing we need to do is to make sure that we have the Btrfs package installed on our system:
Find your dream job
In order to create the filesystem we use the age-old mkfs tool:
Here, we’ve indicated the device and partition as sdx1. This creates a simplistic Btrfs filesystem on the first partition of the sdx device.
Now, let’s say we want to create a larger volume using RAID. We can accomplish this using the following command:
Since we provided two volumes to the command, the mkfs utility will assume we want RAID. The default RAID is RAID 0 but there’s a little more to it than that. Btrfs distinguishes between the data and the metadata. So, while the data is in RAID 0, the metadata defaults to RAID 1, which is more fault tolerant.
RAID 0 is great for performance, but performance is not what is always needed. In many instances, redundancy is the key.
RAID 1 is very common in web servers and small business servers due to the effectiveness of the solution and the relatively low price to implement it. To create a RAID 1 volume using Btrfs, we can use the below command.
In the command, the d and m mean ‘data’ and ‘metadata’ respectively. The ability to specify the RAID level of both the data and metadata separately brings up a really neat feature. The ability to specify different RAID levels for data and metadata allows for a variety of RAID level combinations, many of which might not offer any feasible benefit, but it puts more control in the hands of the administrator.
Sometimes, you want a compromise between speed and redundancy or storage volume and redundancy, but equipment is expensive, this is where RAID 5 and 6 are handy.
It’s as simple as that to create a RAID 5 or 6 volume. Just a single command.
Lastly, we’ll look at RAID10, which used to be more difficult to setup due it’s nested nature. But, again, Btrfs makes it much easier.
mkfs.btrfs –d RAID10 –m RAID10 /dev/sdw1 /dev/sdx1 /dev/sdy1 /dev/sdz1
And, again, with a single command, you have a powerful RAID 10 array. Furthermore, since Btrfs reads RAID1 as a stripe (RAID0), there are amazing read speeds.
Now that you know how to create a RAID volume using Btrfs, you’re probably going to want to mount it. Again, that’s very simple.
What makes this even more simple is that sdx1 can be any physical volume within your RAID volume.
Although it’s not recommended to use unmatching drives in RAID arrays, it’s perfectly fine for the sake of education. If you don’t have the drives to try it with, a virtual machine is more than suffice.
Check back for more about administrating Btrfs and its vast feature set.
How many fossBytes readers are sporting Btrfs setups? What does your setup look like and what are the advantages? Let us know below.