ivanhercaz
Check and include files in "/data" directory when Nerves is initialized
Hi everyone!
I am working with a customized image of Nerves for Raspberry Pi 4 because I need to include some Buildroot packages to interact with a Python application that I include in the priv directory of my Nerves app. I know it is not recommend to use priv directory, but it was the fastest option to test it.
This Python application has two main components: the app and a configuration file. I need to put the configuration file on a writable path, and the one I have seen recommended is /data, but I need to include this file before Nerves start the application supervisor.
Is there any way in which I can specify that, for example, data_app directory will be included in /data when I make the firmware?
The Python application must be started when Nerves start, so I apply the next workaround:
- Nerves started.
- Check if the configuration file exists on
/data, if not, copy it from/priv/conf.fileto /data/conf.file`. - Start the supervisor with its children, where one of them start the Python application that need the bridge.
Now, at least I can replace the configuration file using sftp. But I am still interested in what I ask above, because I think it would be easier and even the Python application may be in /data.
Thanks in advance!
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #elixirconf-us
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 5 of 5 Posts!
LostKobrakai
ivanhercaz
Wuou! Thank you very much for linking to that section of the documentation! I read and read, but I overlooked that part.
ivanhercaz
Hi @LostKobrakai!
May be you or someone else could help me with the problem I am having trying to insert this extra files inside of a read and write partition.
My first try was to create a
rootfs_overlay/data/and insert in this directory the Python application and some other configuration files. However, I get:Due to this message I understand I can’t do it, thus I tried to configure a new partition following the instructions of the section Partitions from the documentation.
First, I copy the
fwup.conffile from my customized Nerves system for Raspberry Pi 4 toconfig/fwup.conf, because myfind deps -name fwup.conf(mentioned in the documentation) doesn’t returns this file from the deps directory. Then I specify this change inconfig/config.exs:In
fwup.confI don’t touch the application partition (APP_PART,/data), but addEXTRA_PART, and the result of my addition is the next fragment:In the mapping partition (
mbr) I add an extra partition (partition 3), removing theexpand = truefrom partition 2:I shared the
mbr-a, but it is the same addition inmbr-b, without touching the rest of partitions with the exception of theexpand = trueofpartition 2.And, finally I run
unsquashfs ~/.nerves/artifacts/<cached_system_name>/images/rootfs.squashfsof my system and copyerlinit.configfile fromsquasfs-root/etc/torootfs_overlay/etc/erlinit.configand, in the part to mount the partitions, I add one line for the extra partition (line 3):Before to run
mix firmwareI createrootfs_overlay/extradirectory and insert an empty test file (test.txt).After run
mix firmwareI runmix burnto burn the SD and when the device is up, I entered in its iex console with SSH and check forerlinitlog:I decided to test myself:
Then I reboot to check if I get the same warning for
/dev/mmcblk0p3:root:And effectively, I don’t get it, but I still get the "no such device for
/dev/mmcblk0p4:/extra. If I dive in the/devdirectory I can see I have the next devices:Any idea about this situation?
Thanks in advance for your effort to read this long post.
ivanhercaz
Before to begin all this process I described, that it isn’t work, I tried what @fhunleth said in the post How to deploy file resource on Nerves device? - #2 by fhunleth
However, if I touch the file or try to unzip it (it is a zip file), it returns me an error that notice is read-only:
If then I use
sftpto replace the file with the same one, it “seems” isn’t read-only more, so if I useFile.touch/1I get an:ok, not an error. But if try to unzip it I still gets the{:error, :erofs}:In addition, I want to avoid to run
sftpfor this case.ivanhercaz
Interesting, the below code works even when it is copied from the priv directory:
Or, as I use it in my code:
So at least this workaround helps me while I think in the errors of the above posts.