DEV Community

Cover image for Tutorial: Alpine Linux on Raspberry Pi 3 with Syncthing, OpenVPN and Docker
Ivaj O'Franc
Ivaj O'Franc

Posted on • Edited on • Originally published at dev.to

Tutorial: Alpine Linux on Raspberry Pi 3 with Syncthing, OpenVPN and Docker

id: 2754302
title: "Tutorial: Alpine Linux on Raspberry Pi 3 with Syncthing, OpenVPN and Docker"
published: true
tags: ["raspberrypi", "alpinelinux", "docker", "syncthing"]
series: I Fixed It and I Don't Know How
description: "Advanced Alpine Linux installation on a Raspberry Pi 3 with disk migration, Syncthing configuration, OpenVPN, Docker and common error resolution."
canonical_url: "https://dev.to/ivajofranc/tutorial-alpine-linux-on-raspberry-pi-3-with-syncthing-openvpn-and-docker-2932"
cover_image: "https://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F670e8xzuffugf407bj2l.png"
Enter fullscreen mode Exit fullscreen mode

Tutorial: Alpine Linux on Raspberry Pi 3 with Syncthing, OpenVPN and Docker

🇪🇸 Lee también este post en español

📝 Detailed Installation and Configuration Tutorial for Alpine Linux (Raspberry Pi 3)

🧑 User

User: test

🔧 General Objective

This tutorial aims to guide you step by step to:

  • Install Alpine Linux on a Raspberry Pi 3 (v1).
  • Migrate the system from SD storage to an external hard drive.
  • Configure services like Syncthing, OpenVPN, Docker, and system tools.
  • Resolve common errors (permissions, ARM architecture, inotify, apk package issues).

🟢 STEP 1: Alpine Installation on SD (sys mode)

  1. Download the official Alpine aarch64 image from alpinelinux.org.
  2. Flash the image to the SD card (example using dd on Linux):
sudo dd if=alpine-rpi-*.img of=/dev/sdc bs=4M status=progress
sync
Enter fullscreen mode Exit fullscreen mode
  1. Connect the SD to the RPi and run the installer:
setup-alpine
Enter fullscreen mode Exit fullscreen mode

Make sure to select diskless mode sys.

  1. Verify that Alpine boots in persistent mode:
mount | grep 'on /'
# /dev/sdb2 on / type ext4 (rw,relatime)
Enter fullscreen mode Exit fullscreen mode

🟢 STEP 2: Clone the system to Hard Drive

  1. Mount the external hard drive (e.g.: /dev/sdb2) to /mnt/usbroot.

  2. Copy the SD content to the hard drive:

rsync -aAXv /mnt/sd/ /mnt/usbroot/
Enter fullscreen mode Exit fullscreen mode
  1. Edit /boot/cmdline.txt and adjust the rootfs UUID:
root=UUID=11112222-3333-4444-aaaa-bbbbccccdddd modules=sd-mod,usb-storage,ext4 rootfstype=ext4
Enter fullscreen mode Exit fullscreen mode
  1. Edit /mnt/usbroot/etc/fstab to reflect the new UUID.

  2. Remove the SD card (leave only the boot) and boot from the disk.


🟢 STEP 3: Manual Syncthing installation

🔄 Download and install the latest version

wget https://github.com/syncthing/syncthing/releases/download/v1.27.8/syncthing-linux-arm64-v1.27.8.tar.gz
tar -xzf syncthing-linux-arm64-v1.27.8.tar.gz
sudo mv syncthing /usr/bin/
sudo chmod +x /usr/bin/syncthing
Enter fullscreen mode Exit fullscreen mode

📆 Create OpenRC service for Syncthing

sudo vi /etc/init.d/syncthing.test
Enter fullscreen mode Exit fullscreen mode

Script content:

#!/sbin/openrc-run
name="Syncthing"
description="Syncthing service"
command="/usr/bin/syncthing"
command_args="--no-browser --gui-address=0.0.0.0:8384"
command_user="test"
depend() {
    need net
}
Enter fullscreen mode Exit fullscreen mode

Enable the service:

sudo chmod +x /etc/init.d/syncthing.test
sudo rc-update add syncthing.test default
sudo rc-service syncthing.test start
Enter fullscreen mode Exit fullscreen mode

🟢 STEP 4: Increase inotify watches

sudo sysctl fs.inotify.max_user_watches=65536
echo "fs.inotify.max_user_watches=65536" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Enter fullscreen mode Exit fullscreen mode

🟢 STEP 5: Configure OpenVPN Client

  1. Install OpenVPN:
sudo apk add openvpn openrc
Enter fullscreen mode Exit fullscreen mode
  1. Copy the .ovpn file as /etc/openvpn/client.conf.

  2. Remove or comment the register-dns line if it exists.

  3. Create /dev/net/tun if it doesn't exist:

sudo mkdir -p /dev/net
sudo mknod /dev/net/tun c 10 200
sudo chmod 600 /dev/net/tun
Enter fullscreen mode Exit fullscreen mode
  1. Start OpenVPN:
sudo rc-service openvpn start
Enter fullscreen mode Exit fullscreen mode

🟢 STEP 6: Docker & Docker Compose Installation

sudo apk add docker docker-cli containerd docker-cli-compose
sudo rc-update add docker default
sudo rc-service docker start
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

docker version
docker compose version
Enter fullscreen mode Exit fullscreen mode

🔴 Issues encountered and solutions

Syncthing auto-update (permission denied)

  • Cause: Syncthing tries to auto-update in /usr/bin/ without permissions.
  • Solution: Update manually from GitHub as in STEP 3.

apk issues with Syncthing and Neofetch

  • Syncthing: Didn't work due to incomplete repos ➔ manual download.
  • Neofetch: Installed by cloning from GitHub.

vcgencmd not available

  • Cause: Missing Linux headers.
  • Alternative solution: Scripts from /sys/class/thermal/.

u2vpodcast Docker image (amd64 on ARM)

  • build-arm64.sh generated invalid tags.

Corrections:

docker buildx build --platform linux/arm64 -t atareao/u2vpodcast:arm64 .
Enter fullscreen mode Exit fullscreen mode

📚 Useful Links


🧹 Final Considerations

  • Automate Syncthing updates via root script.
  • Search for or build optimized ARM64 image of u2vpodcast.
  • Replace vcgencmd with readings from /sys/class/thermal/.
  • Create a watchdog script for OpenVPN.

Top comments (0)