I'd like to mount /mnt/boot/config.json like supervisor service does.


I’d like to inject some information into the services which is running on balena OS. I looked into the balena_supervisor service and found that lots of files on host are mounted in the service container.
One of them is /mnt/boot/config.json which is mount on /boot/config.json.
I want to mount a file which is in /mnt/boot/. The reason why I’m doing like this is that I want to inject the additional information into the buring image especially in the FAT partition so that we can easily copy it.

I tried to mount volume in docker-compose.yml to deploy. But it stoped with error - Uploading source package to https://builder.balena-cloud.comBind mounts are not allowed

Is there a way to mount a file which is /mnt/boot directory?

Best Regards

balenaOS doesn’t allowing mounting directories from the host OS in containers (I’d hazard a guess that its to prevent you modifying files that will be reverted on reboot, but I don’t really know the reasons).

From what you’re saying about wanting to inject the information in the “burning image” though, I don’t think you need to. The Balena CLI can inject a config.json into either an OS image before it gets flashed to removable media, or directly to removable media.

You’ll need a machine with the Balena CLI installed, and after that you can use balena os configure /path/to/os.img --config config.json to add config.json from your current directory to the image.

Alternatively if you’re looking to make changes to devices that are already in the field configizer can SSH into a specified group of devices and make modifications that way.

1 Like

Hi JonWood,
First of all, thank you for your advice.

Is there a way to read the config.json(which is in /mnt/boot) in the custom service(Not balena supervisor)?

I want to make the service read some information in config.json - which I can manipulate via balena os configure command. This is the reason why I want to mount config.json in my custom service.

Thank you JsonWood

Best Regards

@JonWood is spot on here, and just to add the reasoning why we need to maintain consistency in the host OS is that when you come to run an OS update, we need to be able to predict the state that we’re upgrading from. That and of course, the OS update process needs to be able to run without wondering what individual files have been modified on the host system. Our approach with this stuff is always to make the right thing easy and the wrong thing hard - the platform is designed to handle devices at such a scale that you’re not handling them one by one. There could be hundreds of thousands or even millions of devices in a single balenaCloud fleet and so we need to aim for consistency between all of them.

So on to your question about reading config.json - I’m again going to ask what is the exact use case you’re trying to solve. What data are you trying to inject and then read? There’s a chance we’ve seen and solved the same thing before! If it’s a need we’re aware of there may be a way to do it without having to find workarounds.

Nevertheless, if you run mount in the hostOS, you’ll get a list that shows what device /mnt/boot is on, something like /dev/mmcblk0p1. Then in the container you can mount this same device to read the data there, including config.json. Something like mount /dev/mmcblk0p1 mountpoint. Check for examples of using the mount command online if you need more help with this specific part :slight_smile:

1 Like

Great to read the information from files which is in the specific partition.

You asked me the reason why I want to mount that partition. Here is our use case.

We are going to use Raspberry pi board in our remote offices to control IoT things there. Doing this, we need the location information for the devices. However the office administrators are not IT team and don’t have any authority to Balena. They are going to burn the SD card with the image for the specific office - in the image, we are going to put the location information in config.json.

Thank you so much

I’m still not convinced you need to write to config.json from a running Balena device here - it sounds like you’re going to provide a flash image to the people in the remote office, and they will then write that image to an SD card to place in the device.

You can pre-prepare the flash image to include the config.json you want the running device to have via the Balena CLI, meaning that the image the other team are flashing will already contain everything required.