We have a large number of Raspberry Pi 4’s deployed in the field. The SD cards occasionally fail and need to be replaced. When that happens, field staff typically replace the SD card with a new preloaded card that they keep on hand. The problem is that it then becomes a new device in balena with a new UUID. We have no way of tracking the boards themselves to know if it is an old board with new card in it.
It is my understanding that the Raspberry Pi has a serial number hardcoded on the board which can be read:
cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2
Is there any chance that this serial number could be exposed via the API so that we can read this serial number into our system for tracking?
Thanks, I may consider writing a script to ssh to devices and log their serial number to a database, but that’s less than ideal since we have >1000 devices.
I have used this trick in the past and do want to warn you to be cautious when assigning different versions (balenaOS, supervisor, preloaded services) to the same UUID; things can get a little weird because of changes in supported configuration or environment variables.
If you keep the same versions, it should “just work”.
Also be wary of any reliance on data stored in volumes, rather than in the image itself (think SSH keys, configs).
For the (admittedly few) devices I roll out, I generally save an image after commissioning, so I can always re-create the devices.
I have considered configuring the image with the UUID of the one being replaced, and that might be helpful in some instances. However, the field staff carry extra SD cards with an image preloaded on them. This allows them to quickly swap the cards out when they come across a device that is having issues. Otherwise, it could take several days for us build a preconfigured SD card and mail it to them. This is for digital signage, so minimizing downtime is important.
Also, sometimes a device gets deleted from balena, but then the physical Raspberry Pi gets reused later with a fresh SD card. In this case there may be no way of knowing what the old UUID was.
Being able to track the serial number would be very helpful for inventory and lifecycle purposes. Currently, support staff have no way of knowing if a Raspberry Pi has been in the field for 1 year or 5.
The SD cards occasionally fail, necessitating replacements. When our field staff swaps the SD card with a new preloaded one, a new device UUID is generated in Balena. This poses a tracking issue for us, as we lack a mechanism to associate the new UUID with the original Raspberry Pi hardware. In my exploration, I discovered the Raspberry Pi has a hardcoded serial number that can be obtained using the cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2 command.