koleto
How to deploy file resource on Nerves device?
I am trying to deploy I simple text file on a Nerves BBB device application partition. For this I created custom config/fwup.conf where I add an custom file-resource just below the rootfs.img like this:
file-resource test.txt {
host-path = "${NERVES_APP}/config/test.txt"
}
The text file is also under config/test.txt
In the task upgrade.b …
on-resource test.txt { fat_write(${ROOTFS_B_PART_OFFSET}, "test.txt") }
When I start ./upload.sh I get fwup message:
./upload.sh
Path: ./_build/bbb_dev/nerves/images/hello_nerves.fw
Product: hello_nerves 0.1.0
UUID: 4cc602a0-71dc-5398-5a5c-bf4727494331
Platform: bbb
Uploading to nerves.local...
Running fwup...
fwup: Upgrading partition B
fwup: Can't open file on FAT partition(test.txt): FATFS: There is no valid FAT volume
Is there a way deploy a file or file bundle resource on the application partition?
Most Liked
fhunleth
Hi Koleto,
There are several ways of putting files on Nerves devices. Here are the compile-time ways:
- Add the file to your application’s or library’s
privdirectory. Then use:code.priv_dir/1orApplication.app_dir/2to get a path to it. The file will be read-only on the device. - Configure a
rootfs_overlay. This lets you put a file in any directory on the root filesystem. It will still be read-only. - Edit the
fwup.confto add a file to the boot partition. Unless you need to modify the bootloader or update kernel device tree overlays, I’d stay away from this. The boot filesystem is small and since your device depends on it to boot up, it’s generally a good idea to leave it be.
I highly recommend sticking with option 1 if you can.
If you need a file to be writable, the recipe is to add code to your app that initializes files or directories under /root. For example, if you have a sqlite database that’s been pre-seeded, you’d add the database file to a priv directory. Then at run time, you’d check if /root/mydb.sqlite3 exists. If not, you’d copy over the pre-seeded one from your priv directory.
When the device is running, you can run sftp to get and put files on the device.
If none of these options works for you, let me know more about the constraints on the files that you have.
koleto
sftp is working very well I don’t know why I didn’t try this by myself it is probably because I try to use scp but this didn’t work. For my first test evaluation sftp is working perfect…
Thank you Frank!
fhunleth
The rootfs_overlay can put a file most places, but anything in /tmp won’t be visible since a tmpfs filesystem is mounted there. The other special locations are /proc, /sys, and /dev. /opt should have worked. Of course, using priv directories is still better since it’s namespaced and keeps with Erlang/OTP conventions.
Since it sounds like you’re just making one device, running sftp to copy your current database on /root would be easiest, right? Or could the database magically replicate there if you start CouchDB with an empty database there.
Frank
Popular in Questions
Other popular 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
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








