Hey fellow self-hosters!

Not directly related to self-hosting, but since it looks like quite a few people here (like me) are using Raspberry PIs to self-host stuff, I thought some people might be interested.

I use my Raspberry Pi as a NAS, and I’m using Ansible to automate the whole setup. After trying some stuff and experimenting a bit, I like to start again with a clean install and run my Ansible playbook to have a clean setup.

But I’m not always home when I do stuff with my Pi and thought it would be useful to have a way to reflash it remotely, so I could continue to break stuff and just reflash it when it gets too messy.

So I made a script to remotely reflash the Raspberry Pi. The main idea is that after flashing the SD card with the Raspi Imager, I make a copy of the bootfs and rootfs partitions, and when I need to reset the Pi to the initial state, I restore both copies of the partitions.

I wrote a step-by-step guide explaining everything:

https://gist.github.com/lilianmallardeau/04368e95bc97eb9738fba13df3bbfe4a

Feel free to use it if you like!

  • cameos@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    For your case, you might want to switch to overlay rootfs and mount /boot as read-only, your sd card won’t get changed at all.