Is it possible in nerves to watch for external storage devices?


is it possible in nerves to setup a genserver watching for external usb storage devices connected, and when they are detected, make a backup of the content of the sdcard?

I have a RPI3 running nerves, and I’d like the users to plug an USB storage device, and make an automatic backup.

I don’t know how to interact with usb devices.



1 Like

This will be kind of subjective to your application/system.
nerves_runtime has a uevent subsystem that gets published via system_registry.

You can subscribe to system_registry and get messages whenever there is a systemregistry change. Unfortunately working with system_registry kind of sucks sometimes. If your server dies, you have about zero chance of seeing what went wrong because of the log barf because of the size of the message. see #37 for more info.

on the other hand, on rpi3 when you plug a usb device in, it will likely show up as /dev/sdaX. you can just poll for that device to exist, mount it do your backup and un mount it. (i do this in production to some extent.)


thanks a lot @ConnorRigby! probably the second option is the best one for my case.

1 Like