Balena Engine on platforms without systemd

Hi!

We’re preparing to use Balena engine, however on our Linux platform we use sysVinit as an init system, and systemd is disabled.

./balena-engine
./balena-engine: error while loading shared libraries: libsystemd.so.0: cannot open shared object file: No such file or directory

Is it possible to configure Balena Engine to run with sysVinit? I found this:

and this: Debian package - remove SysVinit configuration because it's not used · Issue #30936 · moby/moby · GitHub

This topic also mentions that it is possible: no systemd · Issue #87 · balena-os/balena-engine · GitHub

What are the steps to run the balena engine on a Linux device that has sysVinit as init system?

Thanks,
Filip

Hi there, it might be that it is now a requirement. I’ll check with the engine team and let you know.

Hi @tmigone! Do you know already of this is a hard requirement to have systemd? I sincerely hope it isn’t… :wink:

Hey, can you let us know where you are downloading the version of balena-engine you tried, or are you building it from source? You could try it with a build flag like no_journald to remove the systemd dependency.

So far we have tried the latest binary for armv6.

I have just tried compiling the balena-engine, but I didn’t find any documentation on building from source. Please tell me if what I did is correct:

Changed the flag from journald to no_journald in make.sh:

filip@prec:~/downloads/balena-engine$ git diff
diff --git a/hack/make.sh b/hack/make.sh
index ecd1288831..d91cd808af 100755
--- a/hack/make.sh
+++ b/hack/make.sh
@@ -93,9 +93,9 @@ add_buildtag() {
 }
 
 if ${PKG_CONFIG} 'libsystemd >= 209' 2> /dev/null ; then
-       DOCKER_BUILDTAGS+=" journald"
+       DOCKER_BUILDTAGS+=" no_journald"
 elif ${PKG_CONFIG} 'libsystemd-journal' 2> /dev/null ; then
-       DOCKER_BUILDTAGS+=" journald journald_compat"
+       DOCKER_BUILDTAGS+=" no_journald"
 fi

Then I have run make. Looks like it has created a container and run the build inside, and produced the binary of the daemon:

filip@prec:~/downloads/balena-engine$ ls -l bundles/binary-daemon/
total 44588
lrwxrwxrwx 1 root root       17 lip 16 09:59 balena-engine -> balena-engine-dev
-rwxr-xr-x 1 root root 45644336 lip 16 09:59 balena-engine-dev
-rw-r--r-- 1 root root       52 lip 16 09:59 balena-engine-dev.md5
-rw-r--r-- 1 root root       84 lip 16 09:59 balena-engine-dev.sha256

Is this correct?
Another question: I want to build it for armv6 only. How to achieve that?

Ok, by grepping the repo I found this guide: balena-engine/PACKAGERS.md at master · balena-os/balena-engine · GitHub

So I compiled with

make DOCKER_CROSSPLATFORMS=linux/arm/v7 cross

And I got a binary for armv6

$ file bundles/cross/linux/arm/v6/balena-engine-dev
bundles/cross/linux/arm/v6/balena-engine-dev: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, Go BuildID=23RRcf-7UnZBmEzbO5AH/_L4heeztWQRG3wI96n6k/Nt0bh7RxNHNDwKmLUfJ-/I4W21j2Mn7vv9ro88MI5, stripped

Hopefully will work on armv6 without systemd.

Hi @klutchell @tmigone. Do you maybe have a list of dependencies that Balena expects from the underlying Linux system?

On our system, it looks like a few dependencies are missing:

failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: Iptables not found
ERRO[2021-07-21T09:44:03.911698086Z] Failed to built-in GetDriver graph btrfs /var/lib/balena-engine
ERRO[2021-07-21T09:44:03.914922995Z] Failed to built-in GetDriver graph zfs /var/lib/balena-engine
ERRO[2021-07-21T09:44:04.170617814Z] AUFS was not found in /proc/filesystems storage-driver=aufs
ERRO[2021-07-21T09:44:04.279133766Z] Failed to built-in GetDriver graph devicemapper /var/lib/balena-engine
WARN[2021-07-21T09:44:04.459445702Z] Your kernel does not support swap memory limit
WARN[2021-07-21T09:44:04.465744526Z] Your kernel does not support cgroup rt period
WARN[2021-07-21T09:44:04.468153458Z] Your kernel does not support cgroup rt runtime
WARN[2021-07-21T09:44:04.470562390Z] Your kernel does not support cgroup blkio weight
WARN[2021-07-21T09:44:04.475898240Z] Your kernel does not support cgroup blkio weight_device
WARN[2021-07-21T09:44:04.480019125Z] Your kernel does not support cgroup blkio throttle.read_bps_device
WARN[2021-07-21T09:44:04.481125094Z] Your kernel does not support cgroup blkio throttle.write_bps_device
WARN[2021-07-21T09:44:04.481408086Z] Your kernel does not support cgroup blkio throttle.read_iops_device
WARN[2021-07-21T09:44:04.481615080Z] Your kernel does not support cgroup blkio throttle.write_iops_device
WARN[2021-07-21T09:44:04.486189951Z] Unable to find cpuset cgroup in mounts

Remember that our balenaEngine is just a fork of the Docker/moby project so the same dependencies would apply. In this case you could either install iptables or enable legacy iptables as per this forum post:

If any other dependencies are missing I would personally just search for answers on the Docker forums or the moby project GH as it’s more likely to have been answered there!

Good news is that balena-engine is already included in buildroot and most (not all) of the dependencies are taken care of: buildroot/package/balena-engine at master · buildroot/buildroot · GitHub
Kudos to Tian Yuanhao.

It also cross-compiles to a correct architecture automatically, based on the information that buildroot already has.

For future, here is the list of runtime dependencies of Balena Engine / Docker: