Bertram-Fedora Setup

Deprecated

A step-by-step guide on how to setup Bertram.

Table of Contents

  1. Bertram-Fedora Setup
  2. 01 Install Fedora Server
  3. 02 Update the server
    1. Enable auto-updates
    2. Disable Sleep on lid-close
    3. Install additional software
    4. Disable unneeded services
    5. Configure HDD spin-down
  4. 03 Create an SSH key
  5. 04 Configure Storage
    1. Why BTRFS?
    2. Setup
    3. Add an SSD cache
  6. 05 Install Docker
  7. 06 Install and configure Portainer
    1. Install
    2. Configuration

01 Install Fedora Server

Download Fedora Server Edition and install it on the target machines boot drive. After installation you should be able to reach the Cockpit web-interface on port 9090. Currently Bertrams Cockpit can be reached at https://192.168.178.26:9090 (accept risks because it is a self-signed SSL certificate)

02 Update the server

In Cockpit under Tools goto Software Updates and click Install all updates and check Reboot after completion. Alternitatively run sudo dnf update -y && sudo reboot.

Enable auto-updates

In Cockpit go to Software Updates and enable automatic updates. It will download and install the package dnf-automatic. Afterwards set it to update all packages everyday at 5:00 in the morning.

Disable Sleep on lid-close

Edit the logind.conf file and restart the systemd-logind service:

  1. sudo nano /etc/systemd/logind.conf
  2. Find and edit the following lines (remove the # and set to ignore):
     HandleLidSwitch=ignore
     HandleLidSwitchExternalPower=ignore
     HandleLidSwitchDocked=ignore
     IdleAction=ignore
    
  3. sudo systemctl restart systemd-logind

Install additional software

sudo dnf install nano powertop -y 

Disable unneeded services

Disabling unneeded services can reduce power consumption.

sudo systemctl mask bluetooth.service

Configure HDD spin-down

Spinning down disks after 10 minutes of use to reduce power consumption and noise.

  1. Install hd-idle:
     sudo dnf install hd-idle -y
    
  2. Find the UUIDs of the drives you want to spin-down. For example with sudo blkid. Here we are going to use the PARTUUID instead since in a BTRFS raid both disks share the same UUID.
  3. Edit /etc/sysconfig/hd-idle set the following as HD_IDLE_OPTS:
     -i 0 -a /dev/disk/by-partuuid/0410740d-55e2-45b6-8580-c6185db9e423 -i 600 -a /dev/disk/by-partuuid/97a3764e-2086-4a10-8f57-830fcbf40b42 -i 600 -l /var/log/hd-idle.log
    

    This will spin-down (only the) both drives after 600 seconds (10 minutes) of inactivity and log all spin-downs and spin-ups in /var/log/hd-idle.log.

  4. Enable and start the hd-idle.service:
     sudo systemctl enable hd-idle.service && sudo systemctl start hd-idle.service
    

03 Create an SSH key

Work in progress.

04 Configure Storage

Overall the setup of Bertram includes a 250GB boot SSD formated as XFS (Default on Fedora Server) and two 5TB HDDs (BTRFS) in RAID 1. Later we can add a SSD as read cache.

Why BTRFS?

We could use Cockpits build-in raid capabilities, which as far as I now relies on mdadm, however the USB-HDD do not show up in the raid creation dialog within Cockpit. I do not know whether that is due to them being USB devices or improper configuration. This means we have to use the terminal anyway, so we might as well just use BTRFS as it has some extra benefits over mdadm. However it might be less mature.

Setup

Reference: BTRFS Wiki

  1. If not installed, install BTRFS user-space utils:
     sudo dnf install btrfs-progs -y
    
  2. Check out the Storage tab in Cockpit or run lsblk to find the correct disks: lsblk output Here they are /dev/sdb and /dev/sdc. The ones with numbers indicate partitions on the disks.

  3. Create the raid:
     sudo mkfs.btrfs -d raid1 -m raid1 -f -L BERTRAM_STORAGE /dev/sdb1 /dev/sdc1
    

    This will format the drives to a BTRFS RAID1 and label them as BERTRAM_STORAGE. Note that -f will force the formatting regardless of any prior formats or data! Make sure the listed partitions are correct! btrfs raid creation

  4. To mount the new raid storage, just mount one of the drives to /storage

  5. Reboot after mount to make sure the drives are mounted at boot.

Add an SSD cache

We can use LVM to create a logical volume with our raid storage and SSD(s) to enable caching. Work in progress.

05 Install Docker

Reference: Docker Documentation

  1. Remove existing installations (if there are any):

     sudo dnf remove docker \
       docker-client \
       docker-client-latest \
       docker-common \
       docker-latest \
       docker-latest-logrotate \
       docker-logrotate \
       docker-selinux \
       docker-engine-selinux \
       docker-engine
    
  2. Add Docker repository:

     sudo dnf -y install dnf-plugins-core && \
     sudo dnf config-manager \
     --add-repo \
     https://download.docker.com/linux/fedora/docker-ce.repo
    
  3. Install the Docker engine:

     sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
    
  4. Enable and start the Docker service:

     sudo systemctl enable docker && sudo systemctl start docker
    
  5. Verify that it works by running:

     sudo docker run hello-world
    

06 Install and configure Portainer

Reference: Portainer Documentation

Each application on Bertram will run in their own Docker container. Portainer is an easy web-based GUI to manage all container and to create new ones.

Install

  1. Create the volume that Portainer Server will use to store its database:
     sudo docker volume create portainer_data
    
  2. Download and install the Portainer Server container:
     sudo docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
    

    The Portainer web-interface should now be available on port 9443: https://192.168.178.26:9443

Configuration

  1. Create a new docker network for all apps that we will set up:
     sudo docker network create bertram_network
    
  2. Under Home select the local enviroment. Then click on Settings and under App Templates paste this URL to get all linuxserver.io containers as templates:
     https://raw.githubusercontent.com/technorabilia/portainer-templates/main/lsio/templates/templates-2.0.json
    

    The templates are taken from Technorabilia’s GitHub Repo and should now be available under App Templates.

  3. Head over to Bertram Applications to find out, how to set up applications on Bertram.