What I want to do!

I am using a mini PC "Cubietruck / Cubieboard 3" as server for DocBox and a Raspberry Pi 3 for home-automation with Openhabian. Now I have the LoRa-Node (Server) on an ESP8266. I want to run it all on one system and have some peace for the next years. I think Raspberry is a good platform with long maintenance and good support.


Setting up the RPI-4


  1. RPI4 with 4 GB Ram (the best version)
  2. Samsung SSD T5 500 GB
  3. dezen USB Charger


Prepare SD Card

I want to directly install Raspbian and on initial boot access it via SSH (no HDMI needed). For this SSH and WLAN have to be configured on the boot SD card.

Download latest Raspbian Buster Lite

Copy it to SD Card (e.g. for linux using Etcher) and manipulate the SD card folder and files on your linux PC before inserting into the RPI as follow:

1) Enable SSH: Place a file named 'ssh', without any extension, onto the boot partition of the SD card
2) Enable remote-login with su, edit: //etc/ssh/sshd_config and set PermitRootLogin yes
3) Update WIFI Configuration /etc/wpa_supplicant with following:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

Boot from USB

New RPI can not yet boot directly from USB, but can be "tricked" by give him the SD card for boot, and set the SSD as root folder. A really good description can be found here:


Security and Login via SSH

Connection to the Pi goes via SSH, to avoid typing in the PWD each time - we use SSH keys. For testing purpose the PI runs on SSH-Keyfile without passphrase question (less secure, but its only for a test-system). I also have another SSH-Keyfile (for other purposes) with a passphrase, so I need to create a new SSH-Keyfile only for the PI.

Concept: The PI will contain a file "authorized_keys" that has a list of *trusted* clients that can connect via SSH. The client will generate a key-pair and copy his public-key to the PI "authorized_key". On authentication the client will use his private-key to prove that he own the public-key.

On PI - first create a new user:

sudo adduser username
sudo usermod -aG sudo username

Log-Off and Log-In with new user via SSH and PWD - to prepare the ssh folder. It will contain a file with public keys of authenticated servers that can login into the PI.

cd ~
mkdir .ssh
chmod 700 ~/.ssh

On your PC (descriptions are for Linux/Ubuntu) edit the file ~./ssh/config. Each line is one key-file use (Tip from Stackoverflow)

IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_rsa_pi

Generate a new key-file via ssh-keygen, make sure to use the file-name from above and copy the file to the authorized_keys of the PI with

ssh-copy-id -i ~/.ssh/id_rsa_pi new_user@pi

Login into the PI from the PC should now be possible just with ssh user_name@pi.

Latest News
  • Get a douchdisplay running for the RPI4 (from china) (22.09.2019)


    I am using a 1.8 Inch LCD Screen SPI Serial Port Module TFT Color Display Touch Screen ST7735 (128*160)  for Arduino”, bought for 9€ from aliexpress.com.

    Details: Display Processor: ST7735, Touch Processor: XPT2046, Display Type: ZJY180-TV2.0,128*160

    Its part of my Project “BigPi” to use the PI4 as my central home server. I decided it needs a display 🙂

    Software – TFT Display

    Enabling SPI via sudo raspi-config

    After some search I found a nice git-hub to start from: https://github.com/nopnop2002/ili9340spi_rpi
    On RPI4 the libbcm2835 library does not work, but wiringPi.
    Needs to be installed via

    sudo apt-get install wiringpi
    adduser YOUR_USER spi

    !!! We need version 52 to run with RPI 4, so installation is a bit different !!!

    cd /tmp
    wget https://project-downloads.drogon.net/wiringpi-latest.deb
    sudo dpkg -i wiringpi-latest.deb
    adduser YOUR_USER spi

    Had to adjust only some value in tft.conf according to my display dimensions:

    width=128 height=160
    #If TFT have GRAM offset

    🙂 cool working

  • Migrating from MySQL to Postgres (25.07.2019)

    I am having some trouble on the RPI 4 to get Rails installed and finding the right version of MYSQL (MariaDB) and ActiveRecord while running an older version of Rails and a newer version of Sphinx (search index). Anyway I always wanted to move to PostgreSQL...thats the time to do.

    The tool of my choise: PGLoader

    I realized pgloader does not like to run on the RPI, but the solution is easy:

    SourceDB (Cubietrack) <-> Linux PC (my desktop) = Running PG-Loader <-> TargetDB (RPI4)

    I wanted to have the schema on the target-db, as original as possible for Rails, so I used rake:

    rake db:create
    rake db:schema:load

    to have an original Rails DB set-up. PGLoader is used for data-migration.


    FROM mysql://export:xxx@ct/CTCD2Server_production
    INTO pgsql://docbox:xxx@pi:5432/docbox_production
    with data only
    ALTER SCHEMA 'CTCD2Server_production' RENAME TO 'public';

    Two important points:

    1. The last statement "alter schema" is important, as pgloader creates a schema with the same name as the source db and creates all table in this schema - and rails may not expect this.
    2. "with data only" - tells pgloader that the schema is already existing (rake db:schema:load)

    Once, I got the script working - data migration is just a "button press".