Skip to content

Instantly share code, notes, and snippets.

@reubenmiller
Last active March 5, 2025 19:10
Show Gist options
  • Save reubenmiller/bc5e668a5aa74f302d3dfb2de757302b to your computer and use it in GitHub Desktop.
Save reubenmiller/bc5e668a5aa74f302d3dfb2de757302b to your computer and use it in GitHub Desktop.
How to get thin-edge.io working on a Raspberry Pi device running Alpine Linux

Running thin-edge.io on Alpine Linux on a Raspberry Pi

  1. Flash the latest Raspberry Pi alpine linux image to the SD CARD. See Alpine's Documentation for details

  2. Remount the sd hard on your computer (as you'll be adding some additional files to it before the SD card is inserted into your Raspberry Pi)

  3. Download the headless.apkovl.tar.gz file from the alpine-linux-headless-bootstrap repo and add it to the to the root folder of the mounted sd card (e.g. the FAT partition).

    Note: You don't need to extract the headless.apkovl.tar.gz file, just place it there (there is a magic service which will execute it on boot)

  4. Add some additional files like authorized_keys to the base folder of the FAT partition of the SD Card to enable ssh access to the device after boot

    For example, the authorized_keys keys file with your public SSH key (but this would give me access to your device, so please change it!)

    ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDxm81BGp+bQfMM0jgoMmUD7nXpBCclEq+NqVxUf5D65

    You can also add other files such as Wifi credentials. All of the instructions on how to do this are detailed in the alpine-linux-headless-bootstrap repo

  5. Put the SD Card into your Raspberry Pi Device, and boot it up

  6. Connect via SSH

    ssh root@<device_ip_address>

    e.g.

  7. Run the setup-alpine script (provided by Alpine)

    setup-alpine

    You will be prompted for a lot of entries, but try to configure the repositories if you can.

  8. Reboot after the setup has completed

  9. SSH into the device again (after the machine has rebooted)

    Note: You will need to remove the server from your host's $HOME/.ssh/known_hosts as the SSH server will have changed in the meantime!

  10. Edit the apk repository to enable the community repository (it is usually commented out at the top)

    vi /etc/apk/repositories

    Example:

    http://dl-cdn.alpinelinux.org/alpine/v3.21/community
  11. Install some base dependencies that thin-edge.io installer will need

    apk add curl bash sudo
  12. Install thin-edge.io

    wget -O - thin-edge.io/install.sh | sh -s
  13. Optional: Install podman and other dependencies like cgroups

    apk add cgroup-tools podman podman-compose fuse-overlayfs
    rc-update add podman
    sed -i 's/#mount_program/mount_program/' /etc/containers/storage.conf
    sed -i 's/.*rc_cgroup_mode=.*/rc_cgroup_mode="unified"/g' /etc/rc.conf

    Then reboot the device

    reboot
  14. Check that podman is operational

    podman run --rm -it alpine:3.21 sh

    This should bring you to a terminal within the container without any errors.

  15. Install some other useful thin-edge.io plugins

    apk add tedge-command-plugin tedge-container-plugin-ng

Troubleshooting

sm-plugin not being found

If sudo isn't installed at the time that thin-edge.io is installed, then you will need to add the sudoers rules.

echo "tedge    ALL = (ALL) NOPASSWD: /usr/bin/tedge, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init" > /etc/sudoers.d/tedge
echo "tedge    ALL = (ALL) NOPASSWD: /usr/bin/tedge-write /etc/*" >> /etc/sudoers.d/tedge
echo "tedge    ALL = (ALL) NOPASSWD: /usr/bin/tedgectl" > /etc/sudoers.d/100-tedge-tedgectl
@zhongys-c8y
Copy link

zhongys-c8y commented Mar 5, 2025

Just a very small addition, I also added the /usr/bin/tedgectl into the first line here. It solved the failed restart device problem.
Screenshot 2025-03-05 at 18 38 21
It's now like this:
Screenshot 2025-03-05 at 18 38 56

@reubenmiller
Copy link
Author

Just a very small addition, I also added the /usr/bin/tedgectl into the first line here. It solved the failed restart device problem. Screenshot 2025-03-05 at 18 38 21 It's now like this: Screenshot 2025-03-05 at 18 38 56

No need, I've updated the tedge-service packages to add the required sudoers rule for tedgectl to allow the tedge user to call it (but again only if sudo is installed at the time of installation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment