Reinstall your Raspberry over the Network

Sometimes you want to reinstall your Raspberry Pi without switching the SD-card or via remote since it is located on another physical location. Here is a solution to reinstall the operating system remotely.


1. First you must activate the magic SysRq option:
This will enable the reset of the Raspberry without regular commands.

2a. Transfer the image and write it to SD:
  • Login via SSH to the system on which the image is located and read it via dd. The stdout is tunneled through SSH to the local system.
  • Using pv you can see how much data is transferred. (You may need to install it with apt-get, but you can also omit this.)
  • funzip extracts the first file and sends it to stdout.
  • dd writes it to the SD-card.
 2b. You can also pull the image direct from the Internet:
3. Reset the Raspberry:


There are many ways how to transfer an image over the network. The methods described here pull the image from a remote location. After the transfer process has been completed, you are still logged in. With other ways, if you are logged out, you are lost because you cannot log in any more…

Be sure that you have DHCP enabled on the network.

Good luck. ;)


Featured image “raspberry pi” by Clive Darra is licensed under CC BY-SA 2.0.

15 thoughts on “Reinstall your Raspberry over the Network

  1. I know this is an older entry..

    But seems the best so far, I am about to start this..

    You are installing this over a network because the Pi is in another, remote location..

    How do you access it after resetting it?

    When I write the image locally I have to “touch ssh” in the boot partition..

    I am not seeing that step in your instructions..? Am I missing something?

    1. This article was created before the Raspberry Pi Foundation decided to block SSH on all new installs.. Personally, I strongly feel that -lite- should have SSH enabled.. The average 1D10T user isn’t going to be using -lite- to worry about not changing the default password..

      I use (and modified) this a little bit

      Then I put it on a web server and use 2b.. Zipped or unzipped (remove the funzip if it is already unzipped)

  2. important!!!

    don’t forget new releases of raspbian come with ssh blocked; if you’re doing this in headless mode active ssh before dd

  3. I like to create a new image of my RPi after I’ve configured it to my needs, i.e. enable ssh, setup samba, setup dhcp, dns, etc.

    Now, if you need to re-image the SD card, it’ll be exactly how you want it.

    Example to create image:
    sudo dd bs=4M if=/dev/sdb of=raspbian.img

    1. Jenifer,

      By doing just that, you won’t have remote access after it reboots anyway… See the other comments about enabling SSH on a new image before installing.

      Not the worst method ever.. This is my primary way of re-installing a Pi board.. I typically host the image file myself or save it to the Pi board if it has a big enough SD card, so one isn’t dependant on the internet/external servers for the image.

      There are more complicated ways of checking the image download before it gets written too.

      1. it was working 1 or 2 times for me. I did not changed anything, but since than I was not able to get it working again. And I always end up with a system not able to boot (kernel panic)

            1. No,

              The 2020 images changed the ‘boot’ directory size, so the offsets need to be adjusted.

              Personally, it is on my todo list, but still further down the list.

              1. Hopefully it gets up your list :-)

                I tried many tricks, but it didn’t worked.

  4. Many thanks for this guide. It’s working quite well. Just one question. I know it’s require a ZIP file but would it be possible to use similar with a 7z file?

Leave a Reply

Your email address will not be published. Required fields are marked *