The Raspberry Pi machines are great when one needs a low-power home server or similar. Current machines are not as cheap and simple as the first generations but they are still very convenient little computers.
Sometimes however one wants to blow everything away and start from scratch with a clean OS. The traditional way how this is done is by downloading the Raspberry Pi Imager and write the customized image to an SD card.
That card can then be inserted into the Raspberry Pi and the machine will boot the freshly installed OS from the SD card.
Great. But for myriad reasons one might not want to do it. Hey, maybe walking to the other room and fetching the SD card is just too much effort.
For those situations, just flashing the SD Card from the running Raspberry Pi OS is an option. It's not recommended because you're destroying the filesystem the machine is running on which is obviously a bad idea and can go wrong quick. But it works. 🙈
Have netcat listen on port 9000 and write the data to the mmc block device, which is the sdcard:
nc -l 9000 | dd of=/dev/mmcblk0 bs=4M status=progress conv=fsync iflag=fullblock
Then on another machine, stream the image to the raspberrypi machine:
pv 2026-10-06-raspios-trixie-arm64-lite.img | nc raspberrypi 9000
Using pv gives some nice progress meter, but just using cat is fine too.
After the file has been transferred, reboot the raspberry pi:
echo b > /proc/sysrq-trigger
Don't run any other commands, do not use tab completion for filenames or something because your filesystem is pretty much shot at that point.
And presto, freshly installed OS.