5

Use case:

  1. I have a lot of Utilite2 single board computers to configure

  2. On each device I installed Linaro (Ubuntu-based), booted from MicroSD card. Linaro is recommended OS for Utilite2

  3. On each device I have to do a lot of manual steps (all of them from command line):

    • Change default passwords
    • Change hostname
    • Edit resolv.conf file
    • Install some required packages
    • Set the specific timezone
    • Download few bigger files from the Internet (wget)
    • Edit PATH variable
    • Configure static IP address

I would like to automate whole manual work described in point no. 3. I can write a bash script which will do it for me, but I would like to ask you: is there any better way than scripting it?

When you work with web-apps on server side, you probably use tools like Chef or CloudFormation templates, to setup servers and clusters. You don't configure each server manually. This approach has another big advantage - you can keep your configuration as code and reuse it for each server. I need to understand how to do this for physical hardware.

When it comes to IoT, most resources and presentations which I found focus on the big picture. They show how devices "talk" to each other and how system's architecture looks like. But we can not forget that before each device is in the system, it needs to be configured somehow.

From my point of view (beginner in IoT) there are following options to achieve this:

  • Configure each device manually - this solution is not efficient one, so to speak...
  • Run parametrized setup script on each device - scripts written in bash or python
  • Create pre-configured OS image or distro - @sob in his answer mentioned Yocto, so thanks for that - I didn't know it.
  • Create a package with configuration and install it on each device - Yadt works like that
  • Use some kind of tools like Chef, but IoT-specific - I don't know any of them and I'm wondering if you know any.
  • Hi all. I've just edited my question, so please take a look now. – MrPicky Jul 7 '17 at 11:57
  • This is far too broad to be an appropriate question - it fails to specify the specific Linux being used, and there are too many sub-questions each needing to be uniquely addressed. – Chris Stratton Jul 7 '17 at 14:28
  • 1
    I'm at a loss to understand who this question is aimed at. Any IoT product framework will address provisioning properly already, so use that. If you're brewing your own, this is 'opinion based'. – Sean Houlihane Jul 7 '17 at 14:39
  • 1
    Tools are by definition specific so you can't have a meaningful answer to a non-specific question without this becoming an absurd many-to-many mapping of "well, if you were using A then you might find tool B useful" – Chris Stratton Jul 7 '17 at 18:19
  • Devices like Utilite2 by Compulab or CL100 by Logic Supply comes together with the fresh installation of Ubuntu (Linaro in case of Utilite2). Then such fresh OS needs to be configured. Configuration is a process which should be automated. My question is as follows: how do you automate this process? – MrPicky Jul 7 '17 at 18:36
4

There are several ways that you can create a modified distro, and the best approach will depend on your environment and how you anticipate that evolving over time.

  • Yocto is good if you need to apply some patches and build your own custom kernel/distribution. It seems like you are not working at this level.

  • Package Managers would be good if you want to be able to pull in your application to existing systems

  • On Device Scripts is effectively the same effect as a package manager will provide, just not as clean.

  • Configure and Clone Set-up a single SBC, un-mount the root partition and re-package it to copy onto all targets. This is (crudely) how people often make ROMs for phones and the like. You need to remember to reset any files which control the startup scripts.

  • Unpack and modify You might chose to download an existing distro, modify it using scripts, and package. This could be good if you plan to support updates to the underlying distro with minimal work.

In your case, it sounds like you probably want to take one board, perform the customisation, shut-down, and clone the uSD card as many times as necessary. If you have per-device customisation, maybe a 'run-once' script can handle the uniquification by an interaction with a server.

Deciding which of these is best will depend on your production scale and how long you plan on doing this work. Does it need to scale to next year's distro, new hardware, new platforms? Will the payloads need to auto-update, and how will you cope with keeping the base OS patched?

As an example of how a custom image can be built, you could look at this Raspian image generator: PiBakery or any others that google will offer.

  • 1
    Thanks! This answer actually gave me the biggest input and helped me to see all alternative ways to solve my issue. Regarding to your answer, scripts would be the best solution in my case because i want to keep "configuration" as code. I decided to dig a little bit more around solutions from web-app development and i found this (Chef on Raspberry Pi), and it also works very well in my case. – MrPicky Jul 25 '17 at 17:08
4

One of the choices for creating Embedded Linux distributions is Yocto.

Yocto is open source collaboration project that provides templates, tools and methods to help you create custom Linux-based systems for embedded products regardless of the hardware architecture.

When someone/device manufacturer uses Yocto to create the Linux distro, they may choose to package following tools in the Linux:

Changing hostname

vi /etc/hostname

Configuring network interfaces

ifconfig

Installing some recommended packages

Open PacKaGe management(OPKG) is a lightweight package management system based upon ipkg

Creating some files/directories

Good old mkdir/vi/touch

A build framework like Yocto gives great flexibility to create a embedded Linux distribution that packs all the tools to fit the exact needs of the product.

  • Editing /etc/hostname is probably not a good idea, as this will often be automatically overwritten, and may not be on a persistent filesystem at all. Also changing it doesn't effect everything that cares about the hostname. – Chris Stratton Jul 6 '17 at 16:30
  • FYI, question was majorly edited – Helmar Jul 7 '17 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.