2

I'm working with a few Pi zeros and I'd rather not go out to buy accessories to connect them all to the internet but I want to update them to the newest version of Raspbian.

Is there any way to load a fully up to date version of Raspbian directly on the SD card from the get go, so that I don't need to run sudo apt-get update and sudo apt-get upgrade on first boot for all of the Pis?

  • do it once, create an image from that SD card to use when creating new SD cards? – Jaromanda X Jul 27 '18 at 0:14
  • @JaromandaX I'm a bit of a noob so humour me for a second. If I'm understanding correctly, I install Raspbian normally once on say an RPI3 with internet. Update it. Then take out the SD card, put it back into my Mac/PC, and then somehow convert that back into an image again? Any chance you know the steps to convert it back to an image from the SD card? – Matt Jul 27 '18 at 0:20
  • how do you write the SD card? I've added an answer anyway, see if that helps – Jaromanda X Jul 27 '18 at 0:23
2

Here is how I'd go about it

  1. write image to SD card that is exactly the same size or smaller than your target SD cards
  2. boot this card in a pi
  3. update/upgrade, and perform any other customisations you want/need
  4. shutdown gracefully
  5. add init=/usr/lib/raspi-config/init_resize.sh at the end of the first line in cmdline.txt (if you used a smaller SD card in step 1
  6. create your new image from this SD card

Step 6 depends on your computer ... how do you do step 1? Does this process/program have a read image instead of write image function (win32disk image does)

if you use dd it's simple

to write, it's something like

dd if=raspbian.img of=/dev/someDeviceHere [other options]

to create an image, simply swap if/of

dd of=myraspbian.img if=/dev/someDeviceHere  [other options]

where [other options] are whatever else you use on the command line

  • I'm using the dd command on Mac to copy the Raspbian stretch image to an 8gig micro SD card – Matt Jul 27 '18 at 0:23
  • I've updated the answer ... if your SD cards are all identical in size, then you can skip step 5 – Jaromanda X Jul 27 '18 at 0:26
  • Very helpful thank you @Jaromanda X. One last question for you. If I edit settings on my RPI between steps 3 and 4 (i.e. resolution settings in raspi-config) will those be saved when I copy over the new image so I don't need to change those settings later? – Matt Jul 27 '18 at 0:27
  • yes, of course - do as much customisation as you want between steps 3 and 4 – Jaromanda X Jul 27 '18 at 0:27
  • Awesome, thanks for breaking it down step by step for me! Cheers – Matt Jul 27 '18 at 0:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.