Jacob Weimer

Home Server Build Part 2: Setup and Storage

Installing Ubuntu Server

At first I installed Unraid on this server, but quickly decided that this was a very good “out of the box” solution, but I wanted more control, more FOSS, and more learning by doing. Ubuntu Server was a good middle man between unraid and something like barebones debian.

This was quick and easy using the offical Setup Guide

Then I set up some basic privacy measures based on the guide from Digital Ocean

Mounting Storage Locations with MergerFS

We now have ubuntu server setup with an ssh key for my user. It has a connection and a static IP. The next thing to do is to mount the spinning drives and start using them for storage. When designing the parity and backup solution for this server, I wanted as much space as possible for the hardwared I have. I decided that the server itself would have NO parity, giving me the 4TB’s of storage total. There will be multiple backups in different locations for this data, and that was enough for me. This, after all, is a learning server.

Putting files in different drives on the server sounded messy, so I opted for MergerFS. Normally people use this in combination with snapraid, giving them a nice easy RAID solution for servers with many drives. I only want to combine the storage into a single folder location. From the readme,

mergerfs is a union filesystem geared towards simplifying storage and management of files across numerous commodity storage devices. It is similar to mhddfs, unionfs, and aufs.

This guide from serverbuilds made it straightforward.

  1. Find the Drives

    sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
    
  2. Format the drives

    sudo parted /dev/<DRIVE> mklabel gpt
    sudo parted -a opt /dev/<DRIVE> mkpart primary ext4 0% 100%
    sudo mkfs.ext4 -L disk<NUMBER> -m 1 -T largefile4 /dev/<DRIVE>1
    
  3. Install mergerfs

    sudo apt install mergerfs fuse
    
  4. Make the Mount Locations

    mkdir /mnt/disk{1,2}
    
  5. Edit /etc/fstab for automounting based on the disk labels. The last line configures mergerfs for the /mnt/storage location. I can still get to the other drives at /mnt/disk1 and /mnt/disk2.

     LABEL=disk1     /mnt/disk1      ext4    defaults 0 0
     LABEL=disk2     /mnt/disk2      ext4    defaults 0 0
    
     /mnt/disk*     /mnt/storage     fuse.mergerFS direct_io,defaults,allow_other,minfreespace=50G,fsname=mergerFS 0 0
    
  6. Mount and Test

    sudo mount -a
    df -h -x tmpfs -x devtmpfs
    echo "success" | sudo tee /mnt/storage/test_file
    cat /mnt/storage/test_file
    sudo rm /mnt/storage/test_file
    

Installing Docker and Docker Compose

Next Up: Profit

I am obviously going to start spinning up some custom containers now and get my backup solution in place.