TrueNAS Core Upgrade

I previously had 3 servers running in my network:

I’ve consolidated these 3 onto the J4105. This reduces the network complexity, provide better backups, makes maintenance easier, and reduce electricity requirements.

The Move
In general, the steps performed are:

 

Install TrueNAS

  1. Download TrueNAS iso and load it onto a USB flash disk using Rufus.
  2. Plug the 16GB SSD DOM into an on-board SATA port. The UEFI on the J4105 will not see any disks connected to the PCIE-SATA adapter, so using on-board SATA (or external USB drive) for the boot device is required.
  3. Boot from flash disk and install TrueNAS on the DOM, make sure to specify it as a UEFI device otherwise (again) the motherboard won’t see it as a boot device.
  4. Follow the prompts and then reboot when the install completes.

Configure TrueNAS

  1. Import the pools from AD2550R.
    The disks from the data pools on the AD2550R can just be moved to the J4105 and imported.
  2. Set up Samba shares for data disks, accessible from a remote windows machine.
    Set up a user for the Samba shares. I had to manually change the owner group of the data disks with a chown -R root:(new user) /mnt/(each data folder in the pool) from the shell.
  3. Install plugins for Plex Media Server, Gitlab, Zoneminder.
  4. Create an empty jail for the OpenHAB installation.
  5. (optional) Set the network DHCP server to reserve an IP address for these jails so they’ll always be assigned the same IP, this is more important for OpenHAB since my IOT devices point to a hardcoded IP address for the MQTT server which is a part of the OpenHAB install.

Installing Plex Media Server

From the TrueNAS web interface, enter the SHELL of the Plex jail.
Make folders for each media folder on the TrueNAS system. I’ll use these folders as destination mount points for media library folders on the TrueNAS system. For example:
/mnt/movies
/mnt/tv
/mnt/music
/mnt/photos
(etc)

Stop the Plex jail, then select MOUNT POINTS.

Add the mount points:

Restart the Plex jail.

Set up Plex media libraries and access as normal.

 

Install OpenHAB

Create a new jail named OpenHab

Install prerequisites in jail

pkg
pkg install wget
pkg install nano
pkg install mosquitto
pkg install zip mkdir -p /usr/local/etc/pkg/repos echo 'FreeBSD: { url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest" }' > /usr/local/etc/pkg/repos/FreeBSD.conf pkg update -f

Install the openJDK17 (v19 does not work):

pkg install openjdk17

Download the latest openhab zip from https://www.openhab.org/download/

wget https://github.com/openhab/openhab-distro/releases/download/4.0.2/openhab-4.0.2.zip

Unzip it with:

unzip openhab-4.0.2.zip -d /opt/openhab

then change the start.sh to be executable, and run the script:

cd /opt/openhab
chmod +x start.sh ./start.sh
adduser --system --no-create-home --group --disabled-login openhab (manually create the user, since this command didn't complete automatically in the jail)

Enter the OpenHAB GUI by pointing the browser at http://(IP address):8080 and follow wizards to create the admin user, and set up the system.

Back in the console, kill OpenHAB. 

Create a startup script to allow openhab to start automatically:

 

Configure Mosquitto:

  1. Edit the file /usr/local/etc/mosquitto/mosquitto.conf:
    listener 1883 0.0.0.0
    protocol mqtt
    autosave_interval 1800
    persistence true
    persistence_file mosquitto.db
    persistence_location /usr/local/etc/mosquitto/
    allow_anonymous true
  2. Set mosquitto to start automatically:
    sysrc mosquitto_enable="YES"
  3. Start mosquitto:
    service mosquitto start

Install Gitlab

The community Gitlab plugin was very unstable for me.

I installed it manually by following these steps, based on:
https://gitlab.fechner.net/mfechner/Gitlab-docu/-/blob/master/install/13.2-freebsd.md

Make a new jail using the latest available FreeBSD release.

check allow_sysvipc:

After the shell has booted, now is a good time to reserve an IP address from your DHCP server. Changing the IP address after Gitlab is already installed will need a reconfigure which is an easy task to forget and overlook if you’re not experienced.

Inside the jail shell:

Install nice-to-have tools:

pkg
pkg install nano

Install postgresql, I could not install v15 since this didn’t work with Gitlab at the time.

pkg install postgresql13-server
pkg install postgresql13-contrib
sysrc postgresql_enable=YES
service postgresql initdb
service postgresql start
psql -d template1 -U postgres -c "CREATE USER git CREATEDB SUPERUSER;"
psql -d template1 -U postgres -c "CREATE DATABASE gitlabhq_production OWNER git;"

Try connect to the database, if successful you should see a prompt indicating successful connection:
psql -U git -d gitlabhq_production

psql -U postgres -d gitlabhq_production -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
psql -U postgres -d gitlabhq_production -c "CREATE EXTENSION IF NOT EXISTS btree_gist;"

 

pkg install gitlab-ce
sysrc gitlab_enable=YES

Add the lines to the /usr/local/etc/redis.conf. Its a huge file, so just use the echo:

echo 'unixsocket /var/run/redis/redis.sock' >> /usr/local/etc/redis.conf
echo 'unixsocketperm 770' >> /usr/local/etc/redis.conf

sysrc redis_enable=YES
service redis restart
pw groupmod redis -m git

 

cd /usr/local/www/gitlab-ce
nano config/gitlab.yml

Set the fully qualified domain name – gitlab: host:
Set port to 443 for https – gitlab: port: to 443
Set email – gitlab: email_from

Add secret key:
nano config/secrets.yml

Do some configuration:
su -l git -c "git config --global core.autocrlf input"
su -l git -c "git config --global gc.auto 0"
su -l git -c "git config --global repack.writeBitmaps true"
su -l git -c "git config --global receive.advertisePushOptions true"
su -l git -c "git config --global core.fsync objects,derived-metadata,reference"
su -l git -c "mkdir -p /usr/local/git/.ssh"
su -l git -c "mkdir -p /usr/local/git/repositories"
chown git /usr/local/git/repositories
chgrp git /usr/local/git/repositories
chmod 2770 /usr/local/git/repositories

chown git /usr/local/share/gitlab-shell
su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:setup RAILS_ENV=production"

This takes a while to execute, be patient.
Type yes when prompted to create tables in database.

 

su -l git -c "cd /usr/local/www/gitlab-ce && rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=yourpassword"
changing yourpassword with some nice secure password.

su -l git -c "cd /usr/local/www/gitlab-ce && yarn install --production --pure-lockfile"
su -l git -c "cd /usr/local/www/gitlab-ce && RAILS_ENV=production NODE_ENV=production USE_DB=false SKIP_STORAGE_VALIDATION=true NODE_OPTIONS='--max_old_space_size=3584' bundle exec rake gitlab:assets:compile"

psql -d template1 -U postgres -c "ALTER USER git WITH NOSUPERUSER;"

sysrc gitlab_enable=YES

gitlab service start

This failed with the sidekiq not running.

After rerunning this again:
su -l git -c "cd /usr/local/www/gitlab-ce && RAILS_ENV=production NODE_ENV=production USE_DB=false SKIP_STORAGE_VALIDATION=true NODE_OPTIONS='--max_old_space_size=3584' bundle exec rake gitlab:assets:compile"

the

gitlab service start

returned up and running:

 

pkg install nginx
Add line to the http configuration block in /usr/local/etc/nginx/nginx.cong
include /usr/local/www/gitlab-ce/lib/support/nginx/gitlab;

verify the nginx config is OK by:

nginx -t

Then start it automatically on boot:

sysrc nginx_enable=YES

 

su -l git -c "openssl rand -base64 32 > /usr/local/www/gitlab-ce/.gitlab_pages_secret"
chmod 640 /usr/local/www/gitlab-ce/.gitlab_pages_secret
chgrp gitlab-pages /usr/local/www/gitlab-ce/.gitlab_pages_secret

sysrc gitlab_pages_enable="YES"
service gitlab_pages start

cp /usr/local/www/gitlab-ce/lib/support/nginx/gitlab-pages /usr/local/etc/nginx/sites/gitlab-pages.conf

service nginx reload

When restarting the jail, Gitlab always displays a “Gitlab is taking too long to load” message. 

I solve this by opening the jail shell and running:

service gitlab restart

Then after services have restarted (after a couple of minutes) the web interface should be shown as expected.

← All posts
← Home NAS HDD Holder Using VS Code to Create a Windows Forms Application (View Webcam) →