I'm developing a Buildroot OS for the Raspberry Pi, and my workflow requires very frequent re-flashing of the SD card to test new iterations. The process of removing the SD card from the Pi, flashing it on a Windows PC and then re-inserting it takes a lot of time. I would like to write a script that uses the currently running OS on the Rpi (accessed over SSH) to
- Download the new SD image
- Flash it to the SD, overwriting all existing OS files
- Reboot into the new OS
Step 2 is where I'm stuck. Is it possible for an operating system to overwrite itself?