How can I add persistent changes in /mnt/boot/config.json

In order for some of our devices to work we need to set some UDEV rules. We added them manually to the config.json and that works. However on switching from local to release mode the config.json seems to reset to the default value and we have to change it manually again. Also for every new device we have to manually change this and we would like to have this automated. Is this possible?

Hi Toby, can you just confirm you’re using /mnt/boot/config.json and not /boot/config.json? Thanks.

Yes, is there a difference?

Yes, but you’re editing the right file so don’t worry about that! So in theory switching between local and non-local mode shouldn’t touch your udev rules. Is it changing anything else in your config.json? You mentioned it is reverting to default value, could you send me a before & after copy?

I’m pretty sure only the UDEV rules under ‘os’ were removed. I’ll see if I can reproduce it tomorrow and give you more details.

More importantly, I don’t really want to manually update this file for every new device. Is there no convenient method to do this? Other than us writing our own script?

I’m pretty sure only the UDEV rules under ‘os’ were removed. I’ll see if I can reproduce it tomorrow and give you more details.

Thanks, I will do the same now and see how I get along so we can compare results tomorrow.

More importantly, I don’t really want to manually update this file for every new device. Is there no convenient method to do this? Other than us writing our own script?

I’ll get back to you on this ASAP.

1 Like

Hi Guys…
I’ve been googeled (or Binged :):)) to this post because i am looking a way to mount on my RPI3 device an USB drive to be able to use IT on every hosted containers of my device (without the need to have a specialized container that mount the USB drive and share it via Samba or NFS …)
It seems that it can be done using a custom config.json file ? Is it possible ? And does someone know where to find a documention about what we are able to customize it.

Regards from France.

@stef2001
Your question is quite a bit different than the thread. Can you please start a new one?
I could answer, but that would drag on this thread further.

Thanks

@tobyhijzen being able to set custom udev rules via the dashboard is a feature that is wip.

Please track https://github.com/balena-io/balena-supervisor/issues/998

1 Like

Okey, thank you

I tried to reproduce the error a couple of times without effect. For now everything seems to work.

@tobyhijzen you can build an image that contains the udev rules already.

The basic steps are:

  1. Download/Build the base image for the application/device you are using and unzip
  2. Download just the configuration for that application from the balena dashboard. (A tickbox under Advanced, see screenshot below.)
  3. Add your UDEV rules to that config file, which is effectively the file that is going to end up at /mnt/boot/config.json (see example udev rules file below)
  4. Use the balena CLI to inject the the modified .json into the .img image:
    sudo balena config inject config.json --drive ~/Downloads/balena-cloud-XXX.img --type XXX
  5. Flash as usual

Screenshot to download config file:


Example config.json with udev rules to set nvpmodel -m 0 on Nvidia Jetson family. Has been beautified.

{
  "applicationId": XXXXX,
  "deviceType": "jetson-xavier-nx-devkit",
  "userId": XXX,
  "appUpdatePollInterval": 600000,
  "listenPort": 48484,
  "vpnPort": 443,
  "apiEndpoint": "https://api.balena-cloud.com",
  "vpnEndpoint": "vpn.balena-cloud.com",
  "registryEndpoint": "registry2.balena-cloud.com",
  "deltaEndpoint": "https://delta.balena-cloud.com",
  "mixpanelToken": "XXXXX",
  "apiKey": "XXXXX",
  "os": {
    "udevRules": {
      "101": "ACTION==\"add\", SUBSYSTEMS==\"usb\", RUN+=\"/usr/sbin/nvpmodel -m 0\"\n"
    }
  }
}