hugo-learning-docs
Homelabs

Building your first Homelab

I want to put in place a Homelab server, to run all my small home apps like a Media center server (plex, jellyfin, emby..? who knows!) in a first step.

This is a Repo that recap’s every step that I will achieve to setup my homelab. This will allows me to remember each step of the architecture, automatized the best as possible, and also don’t forget how everything is working.

First - Choosing the PC

The machine

I bought a ~200€ fanless mini-pc from amazon the 1th april 2023. This is not a joke. amazon link

The config is mostly:

  • Intel Celeron n4020, just enough so the Intel QuickSync allows Plex to transcode properly enough video format in 1080p60fps
  • fanless -> I live in a small flat, I don’t want any noise from this engine if I want to sleep in peace.
  • 4GB RAM, just enough so everything in the stack can run with ease
  • 64GB SSD, whatever, I’ll store my media in a spare 1To external HDD
  • 2.5 SATA slot, awesome if I want to add a SSD inside the device, and maybe put in place a backup cronjob in an external device

A Intel to transcode

For the Processor, I viewed a YT video speaking about ‘How to choose a minipc’, but in fact it shows what are the requirement for your Plex server.

This chart is mentionned: image

It is from this wiki. It shows the different video encoding format and what processor code name generation is supporting it.

I personally took a Intel Celeron N4020, so it can support the HEVC-10bit format that is very commonly used in our days.

Setup the PC

Preparing the OS

The target architecture for this PC is to be a simple headless server with a docker engine and some dashboard to remotly manage it.

KISS: No kubernetes.. for now There won’t be a Kubernetes cluster for1 now, I find it a bit overkill for a first step. I’d rather just install docker, and docker-compose only. That’s enough …But in few days maybe I’ll change my mind, because I wanna play with a small in-house kubernetes cluster, let’s see !

The specs:

  • Debian OS - requires a DebianStick (a usb key to install the os)
    • I download the simple debian iso netinstall from the official website here
      • Make sure you install debian with the live+nonfree version (https://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/) so the ISO you install includes non-free firmwares (for example the WIFI) so you don’t ragequit/destroy your keyboard trying to install debian.
    • I used Etcher (from Balena) to install the Iso in a spare USB from my windows pc. It’s a light, powerfull and easy to use tool to load any Bootable ISO to a usb key, perfect for this use case.
  • Docker
    • I’ll use this Rancher doc to install a docker engine easily, let’s hope it doesn’t install a GUI

The Jellyfin server

The torrent-infra repo hosts all the files I used to try different server setup. I may need to update it a little, but it’s a good start to use this.

Specs

There will be a bunch of container to install. A bunch of them are here to download series & movies, and one is in fact the plex server

  • portainer - the container manager, awesome to push / update docker container, and even read docker-compose files, that makes the life so easy!
  • OpenVPN - to protect the torrents download
    • requires a VPN subscription (Surfshark is cheap! ~50€/year)
  • transmission-server - a Torrent server to download torrents
  • jacket - Sort of a google for torrents websites, that plugs torrents website to Series/Movie collection managers (like sonarr, radarr, etc.)
  • sonarr - a Series collection manager, that search torrents for your series, download them and prettyfy them to be ready to be used by your Plex server

Installing the DebianOS

I’ll just make a small batch of commands runs to install some usefull packages.

Here, I was still in the server from my screen

Add my user to sudoers group: (logged in as root)

usermod -aG sudo <username> #add in sudo group your username
getent group sudo #check the users
 
 #switch to <username> and do
 su - <username> to log as fabou
 sudo ls -la /root #to check you are a sudoer

Install SSH server: (https://phoenixnap.com/kb/how-to-enable-ssh-on-debian)

sudo apt update
sudo apt install openssh-server
sudo service status ssh #see the ssh server status
sudo service ssh start #starts the server if not
sudo service enable ssh #start the server on debian boot

Install Git:

sudo apt install git
git config --global user.name <pseudo>
git config --global user.email <mail>
git config --global core.editor nano
git config --global pull.rebase true

Github authent (SSH): First get you github email from this page (the no.reply one)

ssh-keygen -t ed25519 -C <your_email_address> #use your noreply address
#in the prompt, type enter everytime, use a passphrase if your want (don't forget it!!)
ssh-add ~/.ssh/id_ed25519 #add the file in the Identity
cat ~/.ssh/id_ed25519.pub #print your public key so you can copy paster it in GitHub after

If the ssh-add fails, try this:

eval `ssh-agent -s`
ssh-add

It should start the agent and do the trick. source

Finally, add you your SSH key to GitHub here

Test your GitHub authent - no credentials should be asked

mkdir ~/git
cd ~/git
ssh -T git@github.com #this should just prompt small message to say yes, then it should be ok!
git clone git@github.com:Fabbbou/homelab.git 

Install dotfiles: to work smoothly

Just follow the readme from this repo

Install login without password from your PC to your homelab: You need to create a public ssh rsa key for your PC, then copy paste your rsa Public key to the authorized_keys file in the homelab

#from your PC
ssh-keygen #if it says "already exists" or nothing, your good to continue
cat ~/.ssh/id_rsa.pub | ssh user@123.45.67.89 "cat >> ~/.ssh/authorized_keys" # replace user with you ssh account. This will copy paste the rsa public key to your homelab

That’s all, now when you do a simple ssh user@1.2.3.4 it won’t ask a password

Installing docker: Source here

First kill any lock on dpkg just in case

sudo killall -9 dpkg
sudo killall -9 apt-get
sudo rm -f /var/lib/dpkg/lock
sudo rm /var/lib/dpkg/lock-frontend

Set line APT::Periodic::Download-Upgradeable-Packages to "0"; in the following file

sudo nano /etc/apt/apt.conf.d/20auto-upgrades

Installing docker

curl https://releases.rancher.com/install-docker/20.10.sh | sh

Installing rootless docker:

  • Follow this doc: https://docs.docker.com/engine/security/rootless/

Try the docker install doing this:

docker run hello-world

Install docker-compose:

sudo apt update
sudo apt-get install docker-compose-plugin

Note that this docker compose is call without dash ! Example: docker compose version

Start docker on system boot:

sudo systemctl enable docker.service
sudo systemctl enable containerd.service

The ultimate best way to try the rootless install of docker is to run portainer. Try installing portainer:

  • https://docs.portainer.io/start/install/server/docker/linux
  • OR launch portainer with the Torrent-infra repo.

This is the end of the installation for the OS. The next step is to setup the Containers in docker that will be used day-to-day to run the homelab setup !

Next step should be Torrent-infra repo !

One last thing: For portainer, getting the GPU index:

lspci  -v -s  $(lspci | grep ' VGA ' | cut -d" " -f 1)

For me it was 00:02.0 for example

How to mount a SSD automatically on startup

sudo nano /etc/fstab

Add following at the end of the file :

Format: UUID=$UUID_partition_to_mount /mnt/ssd $format uid=$user,gid=$user $uid $gid

Example: UUID=b5169137-4327-4a5f-81ab-d146e4ff7239 /mnt/ssd ntfs uid=fabou,gid=fabou 1000 1000

To get your partition UUID :

sudo blkid

Monitoring

Best CLI tool - htop: Useful to check if transcoding / FFMPEG is working !

sudo apt-get install htop

htop

Docker stats:

docker stats
© hugo-learning-docs 2025