Yet another blog on the Web.

What to do with an old PC? I guess lot of poeple ask the same question regarding older PC hardware. In my case, it was about reusing my old workstation computer, namley an AMD II Phenom (x6 1055t) based machine with 16 GB RAM. Besides that I had an Intel SSD with 80GB and two Crucial MX300 500GB SSDs lying around.

Since the hardware is still usable and in very good condition, I decided to turn this machine into a second home server and development server, which I call Poseidon :-).

Overall, my plans were to turn this machine into a nice GNU/Linux server that runs a Gitea server for managing my software development work, a DNS server, a nginx server as a reverse proxy, and a file server for my music files.

As server operating system, I decided to give Arch Linux a go, since it's pretty straightforward to install and configure software with the help of the great Arch Linux Wiki. And yes, so far I'm in love with Arch Linux. So why not using Arch Linux on a home server?

No sooner said than done :-) So here is my tiny guide on setting up a BTRFS RAID1 system with two SSDs.

Simple BTRFS Raid 1 Setup

The starting point is a fresh Arch system. The following output shows the installed SSD drives in the system. Note that Arch is installed on the device /dev/sda.

[root@poseidon ~]# lsblk
sda      8:0    0  74.5G  0 disk
├─sda1   8:1    0     3M  0 part
├─sda2   8:2    0     8G  0 part [SWAP]
└─sda3   8:3    0  66.5G  0 part /.snapshots
sdb      8:16   0 489.1G  0 disk
sdc      8:32   0 489.1G  0 disk
sr0     11:0    1  1024M  0 rom

Here I used the devices /dev/sdb and /dev/sdc to form a RAID1 system. Overall, creating a BTRFS RAID1 system is pretty simple. We just need to run a single command, as shown below:

mkfs.btrfs -L btrfs_volume1 -m raid1 -d raid1 /dev/sdb /dev/sdc

In short, this command creates a RAID1 system where the data and metadata are duplicated on both drives. The option -d stands for data profile, while the option -m stands for metadata profile.

To double check that everything worked, we can exploit the command btrfs filesystem show, which lists all btrfs filesystems on a machine:

[root@poseidon ~]# btrfs filesystem show
Label: 'Arch Linux'  uuid: 924860ba-1a5d-4a3a-b516-a793afc05105
        Total devices 1 FS bytes used 6.57GiB
        devid    1 size 66.53GiB used 12.02GiB path /dev/sda3

Label: 'btrfs_volume1'  uuid: 4cc2d30c-7ffc-4604-9c09-8fccf3e61a53
        Total devices 2 FS bytes used 640.00KiB
        devid    1 size 489.05GiB used 2.01GiB path /dev/sdb
        devid    2 size 489.05GiB used 2.01GiB path /dev/sdc

As one can see, sdb and sdc are both partitionless disks that form the RAID1 system, while sda3 is the partition where I installed Arch Linux.

Once we have created the RAID1 system, we can mount it. For this reason, we need to create a new mounting point and mount one of the devices. In brief, it doesn't matter if we mount sdb or sdc.

In my case, I created the directory /media/volume1 to mount /dev/sdb. Moreover, I used the lzo compression option to save disk space.

mkdir -p /media/volume1
mount -o compress=lzo /dev/sdb /media/volume1

Lastly, we need to generate a new /etc/fstab config so the RAID1 system is mounted on every boot.

genfstab -U / > /etc/fstab

And that's it! We have created a BTRFS RAID1 system.


© Alexander Rüedlinger, 2017-2018
Proudly powered by Pelican, which takes great advantage of Python.