4-Minute Read

Btrfs Raid on Arch Linux

Prologue

Over the years, more and more stuff occupied in my disks. Videos, ripped music and offline Arch Linux mirror… Just to name a few. The previous storage setup is a 128 GB SSD for the system and one 1 TB HDD for storage. But since the HDD in question is a 8 years old one, feeling insecure about the data, I added another portable 1 TB hard drive to form a Raid 1 array.

Not long after that, 1 TB became inadquate for me. Lacking proper HDDs, I hooked my 2 TB portable USB hard drive to the computer. And moved all re-downloadable data to it. Games, Linux Mirror… The setup stayed like this for 3 years.

Now, the remaining space is again in a dangerous level. The only option left for me is to transfer least used data to my two laptops, each having 500 GB space. But that would be inconvenient and awkward. Besides my family doesn’t have NAS or cloud storage solutions. So it’s time for a proper Raid build, to store all my own stuff and family videos. Basically turn my PC into a NAS.

HDD

HDDs Instead of enterprise level HDDs like redwolf, I went with ordinary seagate HDDs. The major advantage of professional NAS HDD is the high workload capacity and longevity. However, in my case, I need neither of these. The bulk of data would be mostly static, there aren’t much load. And for the longevity issue, according to my previous experience, normal HDD will do. Besides, I’ll be using Raid 10, which means I can sustain 2 breakdowns in a 4 HDD array. At last I brought four 4TB ones, this would give me 8TB storage under Raid 10.

Installation

The installation is no brainer, take a screwdriver and fidlle with some wires and you’re done. There was one unexpected delay though. I’ve checked I have enough on board sata ports and power slots, but I forgot to check if I had enough place for the drivers. After installed one disk, I found out that I’ve ran out of driver bay! Luckily, the computer case does have two CD driver bay unused, so I ordered one of those extension case online.

extension case With three driver bays and a frontal fan, this extension case can fit into two CD driver bays. My computer case only has two driver bays, plus these three, there are just enough space for my HDDs (4 new ones and 1 old).

installed

Btrfs

For those of you who don’t know what btrfs is, it’s a file system focusing on fault tolerance, repair and easy administration. I won’t go into details about it, those interested can go to their wiki.

Actually, the reputation of btrfs in Linux community isn’t that good. Btrfs was notoriously for its instablilty and performance issues. However after years of develop, I think btrfs is mature enough for everyday use. As in 2021, btrfs is the default file system for suse enterprise edition and fedora 34. Facebook also use btrfs heavily on their data servers.

I went with Raid10 for two reasons, one for Raid5/6 aren’t recommended by storage because of expected unrecoverable read error (URE) rates on modern consumer disks, another for Raid5/6 implementation on btrfs is still experimental.

Btrfs wiki has detailed guide for Raid installation, I pretty much just followed the guide and voilà, I got the btrfs raid set up. Well, nearly. One last thing I did is undocumented on the wiki, that is using fstab to mount the array. The wiki did mention one way to do this, but isn’t very ideal. I use blkid to find the UUID for the array using sudo blkid /dev/sdd. You can run this on any one of the disk, as long as it’s part of the array, they all have the same UUID. Then I added the following line to the /etc/fstab.

# /btrfs storage
UUID=94279057-7d43-4382-a39c-6f662026ae37	/storage	btrfs	defaults	0 0

This will mount the array to /storage on boot.

btrfs fstab

Final Result

I rebooted and checked if everything worked as expected, it did. Then I transferred all my data from old driver and portable ones to the array. It took hours! The new drivers are quiet, I can only hear the hissing fans. And I shutdown my PC after I go to bed anyway. Here is my computer after upgrade:

pc

And a screenshot of the array:

btrfs

Recent Posts

Categories

About

A young developer who loves Linux.